/* ═══════════════════════════════════════════════════════════
   ProjectFlow Pro — Main CSS
   Design System: CSS Custom Properties + Utility Classes
   Font: Inter (Google Fonts)
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── CSS Custom Properties ─────────────────────────────── */
:root {
  --color-primary:  #2563EB;
  --color-dark:     #1A2B4A;
  --color-accent:   #0EA5E9;
  --color-success:  #16A34A;
  --color-warning:  #D97706;
  --color-danger:   #DC2626;
  --color-surface:  #F8FAFC;
  --color-border:   #E2E8F0;
  --color-text:     #1A2B4A;
  --color-muted:    #64748B;
  --color-bg:       #F1F5F9;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 2px 8px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12);

  --sidebar-w:  260px;
  --header-h:   64px;
  --transition: 200ms ease;
}

/* ─── Dark Mode ──────────────────────────────────────────── */
[data-theme="dark"] {
  --color-bg:      #0F172A;
  --color-surface: #1E293B;
  --color-border:  #334155;
  --color-text:    #E2E8F0;
  --color-muted:   #94A3B8;
  --color-dark:    #E2E8F0;
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: Inter, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-dark);
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--color-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 24px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img { width: 32px; height: 32px; border-radius: 8px; }

.sidebar-nav { padding: 16px 0; flex: 1; }

.nav-section { padding: 8px 16px 4px; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.4); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: rgba(255,255,255,.75);
  font-size: .9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  cursor: pointer;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  text-decoration: none;
}

.nav-item.active { border-left: 3px solid var(--color-primary); }

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 1.1rem; font-weight: 700; flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-content { padding: 24px; flex: 1; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title { font-size: 1rem; font-weight: 700; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; text-decoration: none; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); text-decoration: none; }
.btn-success   { background: var(--color-success); color: #fff; }
.btn-danger    { background: var(--color-danger);  color: #fff; }
.btn-warning   { background: var(--color-warning); color: #fff; }
.btn-ghost     { background: transparent; color: var(--color-muted); }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.btn-sm        { padding: 5px 10px; font-size: .8rem; }
.btn-lg        { padding: 12px 24px; font-size: 1rem; }
.btn-icon      { padding: 8px; border-radius: var(--radius-sm); }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-hint { font-size: .8rem; color: var(--color-muted); margin-top: 4px; }
.form-error { font-size: .8rem; color: var(--color-danger); margin-top: 4px; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-low      { background: #DCFCE7; color: #166534; }
.badge-medium   { background: #FEF9C3; color: #854D0E; }
.badge-high     { background: #FEE2E2; color: #991B1B; }
.badge-critical { background: #7F1D1D; color: #fff; }
.badge-todo        { background: #F1F5F9; color: #475569; }
.badge-in_progress { background: #DBEAFE; color: #1E40AF; }
.badge-review      { background: #FEF3C7; color: #92400E; }
.badge-done        { background: #DCFCE7; color: #166534; }
.badge-planning    { background: #F1F5F9; color: #475569; }
.badge-active      { background: #DBEAFE; color: #1E40AF; }
.badge-on_hold     { background: #FEF3C7; color: #92400E; }
.badge-complete    { background: #DCFCE7; color: #166534; }

/* ─── Urgency chips ──────────────────────────────────────── */
.urgency-ok       { color: var(--color-success); }
.urgency-warning  { color: var(--color-warning); }
.urgency-critical { color: var(--color-danger); }
.urgency-overdue  { color: var(--color-danger); font-weight: 700; }
.urgency-none     { color: var(--color-muted); }

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: 10px 12px; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); border-bottom: 2px solid var(--color-border); }
td { padding: 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-bg); }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--color-primary); }

/* ─── Alerts / Flash ─────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ─── Progress Bar ───────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width .6s ease;
}
.progress-fill.success { background: var(--color-success); }

/* ─── Avatar ─────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-group { display: flex; }
.avatar-group .avatar { margin-left: -8px; border: 2px solid var(--color-surface); }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-body  { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 8px; justify-content: flex-end; }

/* ─── Skeleton Loading ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-bg) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-card  { height: 120px; border-radius: var(--radius-md); }

/* ─── Dropdown ───────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 150;
  display: none;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: .875rem;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--color-bg); text-decoration: none; }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--color-border); margin-bottom: 20px; gap: 0; }
.tab-btn {
  padding: 10px 20px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-btn.active, .tab-btn:hover { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Search ─────────────────────────────────────────────── */
.search-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  display: none;
}
.search-overlay.open { display: flex; }
.search-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  overflow: hidden;
}
.search-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.1rem;
  border: none;
  background: transparent;
  color: var(--color-text);
  outline: none;
  font-family: inherit;
}
.search-results { max-height: 400px; overflow-y: auto; }
.search-result-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-top: 1px solid var(--color-border);
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--color-bg); }

/* ─── Notification Bell ──────────────────────────────────── */
.notif-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--color-danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-surface);
}

/* ─── Milestone Banner ───────────────────────────────────── */
.milestone-banner {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
.milestone-banner.show { display: flex; }
.milestone-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  max-width: 480px;
  animation: milestone-pop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes milestone-pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.milestone-emoji { font-size: 4rem; margin-bottom: 16px; }
.milestone-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; }
.milestone-sub   { color: var(--color-muted); margin-bottom: 24px; }

/* ─── Streak Tracker ─────────────────────────────────────── */
.streak-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border-radius: var(--radius-md);
  border: 1px solid #FCD34D;
}
.streak-flame { font-size: 1.8rem; }
.streak-count { font-size: 1.5rem; font-weight: 700; color: #92400E; }
.streak-label { font-size: .8rem; color: #78350F; }

/* ─── Stats Bar ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--color-primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--color-muted); margin-top: 4px; font-weight: 500; }
.stat-card.success .stat-value { color: var(--color-success); }
.stat-card.warning .stat-value { color: var(--color-warning); }
.stat-card.danger  .stat-value { color: var(--color-danger); }

/* ─── Project Card ───────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.project-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.project-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.project-card-color { height: 4px; }
.project-card-body  { padding: 20px; }
.project-card-title { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.project-card-desc  { font-size: .85rem; color: var(--color-muted); margin-bottom: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }

/* ─── Colour Picker ──────────────────────────────────────── */
.colour-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.colour-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color var(--transition);
}
.colour-swatch.selected { border-color: var(--color-dark); }

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state-title { font-size: 1.1rem; font-weight: 700; color: var(--color-text); margin-bottom: 8px; }
.empty-state-sub   { font-size: .9rem; margin-bottom: 20px; }

/* ─── Utility Classes ────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-3   { margin-top: 12px; }
.mt-4   { margin-top: 16px; }
.mb-2   { margin-bottom: 8px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.p-4    { padding: 16px; }
.text-sm   { font-size: .875rem; }
.text-xs   { font-size: .75rem; }
.text-muted { color: var(--color-muted); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.font-bold { font-weight: 700; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full    { width: 100%; }
.hidden    { display: none !important; }
.sr-only   { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .project-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; margin: 0; border-radius: var(--radius-md) var(--radius-md) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
}
