/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg: #0f0f13;
  --surface: #18181f;
  --surface2: #22222d;
  --surface3: #2a2a38;
  --border: rgba(255,255,255,0.07);
  --primary: #7c3aed;
  --primary-light: #9f5ff5;
  --primary-dim: rgba(124,58,237,0.15);
  --accent: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --text: #f1f1f5;
  --text-2: #a0a0b8;
  --text-3: #6b6b85;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --sidebar-w: 240px;
  --transition: 0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 0.95rem; }
.hidden { display: none !important; }
.page { width: 100%; }

/* ── Loading Overlay ───────────────────────────────────── */
.loading-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 9999; transition: opacity 0.3s; }
.loading-overlay.fade-out { opacity: 0; pointer-events: none; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--surface3); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ─────────────────────────────────────────────── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500; backdrop-filter: blur(12px); box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s ease; max-width: 340px; border: 1px solid var(--border); }
.toast.success { background: rgba(16,185,129,0.15); color: #6ee7b7; border-color: rgba(16,185,129,0.3); }
.toast.error { background: rgba(239,68,68,0.15); color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.toast.info { background: rgba(59,130,246,0.15); color: #93c5fd; border-color: rgba(59,130,246,0.3); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Auth ──────────────────────────────────────────────── */
.auth-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at top right, rgba(124,58,237,0.2) 0%, transparent 50%), radial-gradient(circle at bottom left, rgba(79,70,229,0.15) 0%, transparent 50%), var(--bg); }
.auth-card { background: rgba(24, 24, 31, 0.65); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,0.08); border-radius: 24px; padding: 48px; width: 100%; max-width: 440px; box-shadow: 0 24px 64px rgba(0,0,0,0.6); position: relative; overflow: hidden; }
.auth-logo { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 800; margin-bottom: 32px; color: var(--text); }
.auth-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--text-2); margin-bottom: 28px; font-size: 0.9rem; }
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-switch { margin-top: 20px; text-align: center; color: var(--text-2); font-size: 0.9rem; }
.hint { color: var(--text-3); font-size: 0.82rem; }

/* ── Role Selector ─────────────────────────────────────── */
.role-selector { display: flex; gap: 6px; background: rgba(0,0,0,0.2); padding: 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.role-selector input[type="radio"] { display: none; }
.role-btn { flex: 1; text-align: center; padding: 10px; font-size: 0.88rem; font-weight: 600; color: var(--text-2); cursor: pointer; border-radius: 6px; transition: all var(--transition); letter-spacing: 0.03em; }
.role-btn:hover { color: var(--text); }
.role-selector input[type="radio"]:checked + .role-btn { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(124,58,237,0.4); }

/* ── Fields ────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 7px; }
.field-group label { font-size: 0.87rem; font-weight: 500; color: var(--text-2); }
.field-group input, .field-group textarea, .field-group select {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 10px 14px; outline: none; transition: border-color var(--transition);
  width: 100%;
}
.field-group input:focus, .field-group textarea:focus, .field-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.field-group select option { background: var(--surface2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500; border: none; transition: all var(--transition); white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(124,58,237,0.4); }
.btn-secondary { background: var(--surface3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface2); border-color: var(--primary); }
.btn-danger { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.22); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-3); }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }

/* ── Layout ────────────────────────────────────────────── */
#page-app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transition: transform var(--transition); z-index: 200; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 16px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 9px; font-size: 1.1rem; font-weight: 800; color: var(--text); }
.sidebar-close { display: none; background: none; border: none; color: var(--text-2); font-size: 1rem; }
.sidebar-nav { flex: 1; padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 0.92rem; font-weight: 500; transition: all var(--transition); text-decoration: none; }
.nav-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-dim); color: var(--primary-light); }
.sidebar-footer { padding: 14px 10px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0; }
.user-info { min-width: 0; }
.user-name { display: block; font-size: 0.88rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { display: block; font-size: 0.75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Main Wrapper ──────────────────────────────────────── */
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Topbar ────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 24px; height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar-title { font-size: 1rem; font-weight: 600; flex: 1; color: var(--text-2); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; padding: 4px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text-2); border-radius: 2px; }

/* ── Content ───────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 28px 28px 40px; }
.view { animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; transform-origin: center top; opacity: 0; }
@keyframes scaleIn { 0% { opacity: 0; transform: scale(0.97) translateY(10px); filter: blur(4px); } 100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); } }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.page-desc { color: var(--text-2); font-size: 0.9rem; }

/* ── Stat Cards ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; position: relative; overflow: hidden; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.stat-card:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 12px 32px rgba(0,0,0,0.5); border-color: rgba(255,255,255,0.15); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-card.purple::before { background: linear-gradient(90deg, var(--primary), var(--accent)); }
.stat-card.green::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.amber::before { background: linear-gradient(90deg, var(--warning), #fcd34d); }
.stat-card.red::before { background: linear-gradient(90deg, var(--danger), #f87171); }
.stat-label { font-size: 0.82rem; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text); }
.stat-sub { font-size: 0.8rem; color: var(--text-3); margin-top: 4px; }

/* ── Dashboard Sections ────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.dash-card-title { font-size: 0.9rem; font-weight: 600; color: var(--text-2); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Status Bar Chart ──────────────────────────────────── */
.status-bars { display: flex; flex-direction: column; gap: 12px; }
.status-bar-row { display: flex; align-items: center; gap: 12px; }
.status-bar-label { font-size: 0.85rem; color: var(--text-2); width: 90px; flex-shrink: 0; }
.status-bar-track { flex: 1; height: 8px; background: var(--surface3); border-radius: 99px; overflow: hidden; }
.status-bar-fill { height: 100%; border-radius: 99px; transition: width 0.6s ease; }
.bar-todo { background: var(--text-3); }
.bar-in-progress { background: var(--warning); }
.bar-done { background: var(--success); }
.status-bar-count { font-size: 0.85rem; font-weight: 600; color: var(--text); width: 24px; text-align: right; }

/* ── Task List Items ───────────────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; background: var(--surface2); border-radius: var(--radius-sm); border: 1px solid var(--border); transition: border-color var(--transition); cursor: pointer; }
.task-item:hover { border-color: var(--primary); }
.task-item-info { flex: 1; min-width: 0; }
.task-item-title { font-size: 0.9rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-item-meta { font-size: 0.78rem; color: var(--text-3); margin-top: 3px; }

/* ── Status & Priority Badges ──────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-todo { background: rgba(107,107,133,0.2); color: var(--text-3); }
.badge-in-progress { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-done { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-high { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-medium { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-low { background: rgba(59,130,246,0.15); color: #93c5fd; }
.badge-admin { background: rgba(124,58,237,0.15); color: var(--primary-light); }
.badge-member { background: var(--surface3); color: var(--text-2); }

/* ── Projects Grid ─────────────────────────────────────── */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; cursor: pointer; transition: all var(--transition); position: relative; overflow: hidden; }
.project-card::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius); border: 1px solid transparent; transition: border-color var(--transition); }
.project-card:hover { transform: translateY(-3px); box-shadow: 0 8px 30px rgba(124,58,237,0.2); }
.project-card:hover::after { border-color: var(--primary); }
.project-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.project-card-name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.project-card-desc { font-size: 0.87rem; color: var(--text-2); line-height: 1.5; margin-bottom: 16px; min-height: 40px; }
.project-card-footer { display: flex; align-items: center; justify-content: space-between; }
.project-meta { display: flex; align-items: center; gap: 14px; }
.meta-item { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; color: var(--text-3); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 0.9rem; color: var(--text-3); }

/* ── Project Detail ────────────────────────────────────── */
.project-detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.back-btn { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 0.88rem; background: none; border: none; padding: 0; margin-bottom: 12px; transition: color var(--transition); }
.back-btn:hover { color: var(--text); }
.tabs { display: flex; gap: 4px; background: var(--surface2); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 24px; }
.tab { padding: 8px 18px; border-radius: 6px; font-size: 0.88rem; font-weight: 500; color: var(--text-2); background: none; border: none; transition: all var(--transition); }
.tab.active { background: var(--surface3); color: var(--text); }
.tab:hover:not(.active) { color: var(--text); }

/* ── Kanban Board ──────────────────────────────────────── */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .kanban { grid-template-columns: 1fr; } }
.kanban-col { background: var(--surface2); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.kanban-col-header { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.kanban-col-title { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.col-todo .kanban-col-title { color: var(--text-3); }
.col-in-progress .kanban-col-title { color: var(--warning); }
.col-done .kanban-col-title { color: var(--success); }
.kanban-count { background: var(--surface3); color: var(--text-2); padding: 2px 8px; border-radius: 99px; font-size: 0.78rem; font-weight: 600; }
.kanban-cards { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 80px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; cursor: pointer; transition: all var(--transition); }
.kanban-card:hover { border-color: var(--primary); box-shadow: 0 2px 12px rgba(124,58,237,0.15); }
.kanban-card-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 10px; color: var(--text); }
.kanban-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kanban-card-assignee { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-3); }
.avatar-xs { width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.due-tag { font-size: 0.75rem; padding: 2px 7px; border-radius: 4px; font-weight: 500; }
.due-overdue { background: rgba(239,68,68,0.15); color: #f87171; }
.due-soon { background: rgba(245,158,11,0.12); color: var(--warning); }
.due-ok { background: rgba(16,185,129,0.1); color: var(--success); }

/* ── Members Table ─────────────────────────────────────── */
.members-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.members-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
.members-toolbar-title { font-size: 0.95rem; font-weight: 600; }
.members-list { }
.member-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); transition: background var(--transition); }
.member-row:last-child { border-bottom: none; }
.member-row:hover { background: var(--surface2); }
.member-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.88rem; color: #fff; flex-shrink: 0; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.member-email { font-size: 0.78rem; color: var(--text-3); }
.member-actions { display: flex; align-items: center; gap: 8px; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 500px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: modalIn 0.25s ease; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-2); font-size: 1.1rem; padding: 4px 8px; border-radius: 6px; transition: all var(--transition); }
.modal-close:hover { background: var(--surface3); color: var(--text); }
.modal-body { padding: 20px 24px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ── Skeleton Loader ───────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-line { height: 14px; margin-bottom: 10px; }
.skel-card { height: 140px; border-radius: var(--radius); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 720px) {
  .hamburger { display: flex; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100%; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-close { display: block; }
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .kanban { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ── Divider / Helpers ─────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.text-danger { color: var(--danger); font-size: 0.82rem; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.ml-auto { margin-left: auto; }
