/* ============================================================
   Kasana — Styles
   Adapted from WorkersCrawler with Kasana-specific additions
   ============================================================ */

:root {
  --primary: #003682;
  --primary-light: #1d4ed8;
  --accent: #F6821F;
  --accent-light: #fb923c;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --orange: #ea580c;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Auth pages ---- */
.auth-page {
  background: linear-gradient(135deg, #003682 0%, #0f172a 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-container { width: 100%; max-width: 400px; }
.auth-logo {
  display: flex; align-items: center; gap: 0.75rem;
  justify-content: center; margin-bottom: 1.5rem;
}
.auth-logo h1 { color: white; font-size: 1.5rem; font-weight: 700; }
.auth-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.auth-card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1.25rem; }
.auth-link { margin-top: 1rem; font-size: 0.875rem; color: var(--text-muted); text-align: center; }
.auth-note { margin-top: 0.5rem; font-size: 0.8rem; color: var(--text-muted); text-align: center; }

/* ---- App layout ---- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-title { font-weight: 700; font-size: 1rem; color: white; }
.nav-links { list-style: none; padding: 0.5rem 0; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1rem;
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
  border-radius: 0;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: white; text-decoration: none; }
.nav-link.active { background: var(--accent); color: white; font-weight: 600; }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.1); }
.btn-logout {
  width: 100%; background: none; border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.75); padding: 0.5rem; border-radius: var(--radius);
  cursor: pointer; font-size: 0.85rem; transition: all 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); color: white; }
.sidebar-user {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user-name {
  color: white; font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-email {
  color: rgba(255,255,255,0.5); font-size: 0.72rem; margin-top: 0.15rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
.page-content { padding: 2rem; max-width: 1100px; }

/* ---- Page header ---- */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); margin-top: 0.25rem; font-size: 0.9rem; }
.back-link { color: var(--text-muted); font-size: 0.875rem; display: inline-flex; align-items: center; gap: 0.3rem; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card > *:not(.card-header) { padding: 1.25rem; }

/* ---- Stats grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; text-align: center; box-shadow: var(--shadow);
}
.stat-card.loading { color: var(--text-muted); font-size: 0.875rem; }
.stat-card.high { border-top: 3px solid var(--danger); }
.stat-card.medium { border-top: 3px solid var(--warning); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ---- Dashboard grid ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 768px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ---- Task rows (compact) ---- */
.tasks-list { padding: 0; }
.task-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.25rem; border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.task-row:last-child { border-bottom: none; }
.task-title { flex: 1; font-weight: 500; color: var(--text); }
.task-title:hover { color: var(--primary-light); text-decoration: underline; }
.task-due { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.task-due.overdue { color: var(--danger); font-weight: 600; }
.task-owner { font-size: 0.8rem; color: var(--text-muted); }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.5rem; flex-wrap: wrap;
}

/* ---- Task cards (list view) ---- */
.tasks-container { display: flex; flex-direction: column; gap: 0.75rem; }
.task-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; box-shadow: var(--shadow);
}
.task-card.task-overdue { border-left: 3px solid var(--danger); }
.task-card-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.5rem; flex-wrap: wrap;
}
.task-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.task-card-title a { color: var(--text); }
.task-card-title a:hover { color: var(--primary-light); }
.task-card-desc { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }
.task-card-date { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }
.task-card-owner { font-size: 0.8rem; color: var(--text-muted); }
.task-card-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; }

/* ---- Task detail ---- */
.task-detail { max-width: 780px; }
.task-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem;
}
.task-detail-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.task-detail-actions { display: flex; gap: 0.5rem; }
.task-detail-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 1rem; }
.task-detail-meta {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem; margin-bottom: 1.25rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.meta-item { display: flex; flex-direction: column; gap: 0.25rem; }
.meta-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.task-detail-desc { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.25rem; font-size: 0.9rem; line-height: 1.6; }
.task-detail-section { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1.25rem; }
.task-detail-section h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.section-header h3 { margin-bottom: 0; }

.status-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.dep-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.dep-row:last-child { border-bottom: none; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 0.75rem; padding: 0 0.25rem; }
.btn-icon:hover { color: var(--danger); }

.collabs-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.collab-pill {
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.25rem 0.75rem; font-size: 0.8rem; display: flex; align-items: center; gap: 0.3rem;
}
.collab-remove { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 0.75rem; }

.comments-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.comment { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; }
.comment-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; font-size: 0.875rem; }
.comment-date { color: var(--text-muted); font-size: 0.8rem; }
.comment-body { font-size: 0.875rem; line-height: 1.5; }
.comment-form { display: flex; flex-direction: column; gap: 0.5rem; }
.comment-form textarea { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.875rem; resize: vertical; }

/* ---- Team / Admin tables ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { text-align: left; padding: 0.6rem 0.75rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* ---- Forms ---- */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.form-group label { font-size: 0.875rem; font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); }
.required { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], textarea, .select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  width: 100%;
  background: white;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}
.select-sm { width: auto; padding: 0.3rem 0.5rem; font-size: 0.8rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem; border-radius: var(--radius); font-size: 0.875rem;
  font-weight: 500; cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: #002a6b; }
.btn-ghost { background: white; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; white-space: nowrap;
}
.badge-critical { background: #fee2e2; color: #dc2626; }
.badge-high { background: #ffedd5; color: #ea580c; }
.badge-medium { background: #fef9c3; color: #a16207; }
.badge-low { background: #dcfce7; color: #16a34a; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #ffedd5; color: #ea580c; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* ---- Alerts ---- */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.875rem; margin-bottom: 1rem; }
.alert-error { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #16a34a; border: 1px solid #86efac; }
.alert-warning { background: #fef9c3; color: #a16207; border: 1px solid #fde047; }

/* ---- Modals ---- */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal.hidden { display: none; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); }
.modal-content {
  background: white; border-radius: 12px; padding: 1.75rem;
  width: 100%; max-width: 480px; position: relative; z-index: 1;
  box-shadow: var(--shadow-md); max-height: 90vh; overflow-y: auto;
}
.modal-lg { max-width: 600px; }
.modal-content h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ---- Misc ---- */
.empty { color: var(--text-muted); font-size: 0.875rem; padding: 1rem 0; }
.checkbox-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 150px; overflow-y: auto; padding: 0.25rem 0; }
.checkbox-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; cursor: pointer; }
.checkbox-item input[type="checkbox"] { width: auto; cursor: pointer; }
.hidden { display: none !important; }
.loading-spinner { color: var(--text-muted); padding: 2rem; text-align: center; }
.overdue { color: var(--danger); font-weight: 600; }
