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

:root {
  --bg: #0f172a;
  --card: rgba(17, 24, 39, 0.65);
  --border: rgba(255, 255, 255, 0.1);
  --text: #e5e7eb;
  --text-dark: #cbd5e1;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --secondary: #1e293b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.15);
  --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
  --glass-blur: blur(16px);
}

:root[data-theme='light'] {
  --bg: #f4f7f6;
  --card: rgba(255, 255, 255, 0.85);
  --border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --text-dark: #334155;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #ffffff;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.container-gp {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Card Styling - Premium Glassmorphism */
.card {
  background: var(--card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-header-title h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text), var(--text-dark));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.page-header-title span {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.95rem;
  font-weight: 500;
}

/* Grids */
.grid-4, .grid-2, .form-grid { display: grid; gap: 24px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2, .form-grid { grid-template-columns: repeat(2, 1fr); }

/* Custom Dashboard Stat Card */
.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
}
.stat-info { display: flex; flex-direction: column; gap: 4px; }
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--text), var(--text-dark));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05); /* overridden per card inline */
}

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  box-sizing: border-box;
  transition: all 0.2s ease;
}
:root[data-theme='dark'] input,
:root[data-theme='dark'] select,
:root[data-theme='dark'] textarea { background: rgba(255, 255, 255, 0.03); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
  background: transparent;
}
textarea { min-height: 120px; resize: vertical; }

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s ease;
}
.btn:hover::after { left: 100%; }

.btn-sm { padding: 9px 16px; font-size: 0.85rem; }
.btn-primary { 
  background: linear-gradient(135deg, var(--primary), var(--primary-hover)); 
  color: #fff; 
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.btn-secondary { background: var(--secondary); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { transform: translateY(-2px); background: rgba(255,255,255,0.05); }

/* Tables */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.table th {
  background: rgba(0,0,0,0.03);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 2;
}
:root[data-theme='dark'] .table th { background: rgba(255,255,255,0.02); }
.table tbody tr { transition: background-color 0.15s ease; }
.table tbody tr:hover { background: rgba(0, 0, 0, 0.02); }
:root[data-theme='dark'] .table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* Typography */
.small { font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.badge { 
  display: inline-flex; padding: 6px 12px; border-radius: 999px; 
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em;
  background: rgba(37, 99, 235, 0.15); color: var(--primary); 
  border: 1px solid rgba(37, 99, 235, 0.2);
}

/* Alerts */
.alert-danger, .alert-success, .alert-warning {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.2);
}
.alert-success {
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.2);
}
.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.2);
}

/* Non-hoverable cards (forms, settings) */
.card-static:hover {
  transform: none;
  box-shadow: var(--shadow);
}

/* List Toolbar (search + count) */
.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.list-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.list-search-input {
  width: 100% !important;
  max-width: 320px;
  padding: 10px 16px 10px 38px !important;
  border-radius: 999px !important;
  font-size: 0.88rem !important;
  border: 1px solid var(--border) !important;
  background: rgba(0,0,0,0.02) !important;
  transition: all 0.25s ease !important;
}
.list-search-input:focus {
  max-width: 400px;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1) !important;
  background: transparent !important;
}
.list-search-wrap {
  position: relative;
  flex: 1;
  max-width: 400px;
}
.list-search-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}
.list-search-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  background: rgba(0,0,0,0.04);
  padding: 5px 12px;
  border-radius: 999px;
}
:root[data-theme='dark'] .list-search-count { background: rgba(255,255,255,0.04); }

/* Badge variants */
.badge-success {
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.2);
}
.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.2);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.2);
}
.badge-muted {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.2);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.empty-state-desc {
  font-size: 0.9rem;
}

/* Grid-3 */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {
  .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; gap: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .list-toolbar { flex-direction: column; align-items: stretch; }
  .list-search-input { max-width: 100% !important; }
  .list-search-wrap { max-width: 100%; }
  /* 2-col stat grid on tablet */
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── Mobile (≤ 768px) ── */
@media (max-width: 768px) {
  .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }

  /* Tables: card-mode on mobile */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-card-mobile table,
  .table-card-mobile thead,
  .table-card-mobile tbody,
  .table-card-mobile th,
  .table-card-mobile td,
  .table-card-mobile tr { display: block; width: 100%; }
  .table-card-mobile thead { display: none; }
  .table-card-mobile tbody tr {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: var(--card);
  }
  .table-card-mobile tbody td {
    padding: 6px 8px;
    border: none;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }
  .table-card-mobile tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Forms */
  .form-grid { grid-template-columns: 1fr !important; gap: 14px; }
  .form-actions { flex-direction: column; gap: 8px; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Buttons: better tap targets */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; padding: 8px 14px; font-size: 0.82rem; }

  /* Page header */
  .page-header { gap: 10px; margin-bottom: 16px; }
  .page-header-title h1 { font-size: 1.5rem !important; }
  .page-header-actions { width: 100%; flex-wrap: wrap; gap: 8px; }

  /* Cards */
  .card { padding: 16px !important; }
  .stat-card { padding: 14px 16px !important; }
  .stat-value { font-size: 2rem !important; }
  .stat-icon { width: 44px !important; height: 44px !important; }

  /* Project nav menu: horizontal scroll */
  .project-nav-tabs { flex-wrap: nowrap !important; overflow-x: auto !important; scrollbar-width: none; }
  .project-nav-tabs::-webkit-scrollbar { display: none; }
  .project-nav-link { padding: 12px 9px !important; font-size: 0.78rem !important; }
  /* Hide dropdown on mobile, show inline */
  .nav-dropdown { position: static !important; display: none !important; box-shadow: none !important; }
  .nav-item-wrapper.mobile-open .nav-dropdown { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; gap: 4px !important; padding: 4px 0 !important; background: transparent !important; border: none !important; }

  /* Filter bar in projects list */
  .filter-nav-bar { flex-wrap: wrap !important; gap: 6px !important; }
  .filter-btn { font-size: 0.75rem !important; padding: 5px 10px !important; }

  /* Projects toolbar: stack on mobile */
  .projects-toolbar { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; padding: 16px 14px 8px !important; }
  .projects-toolbar > div:last-child { flex-wrap: wrap !important; gap: 8px !important; }
  .year-select, .customer-filter-input, .list-search-input { width: 100% !important; max-width: 100% !important; }
  .customer-filter-wrap, .list-search-wrap { flex: 1 1 calc(50% - 4px) !important; min-width: 120px; }

  /* Table dropdown: position fix */
  .table-dropdown-content { right: 0; left: auto; }

  /* Modal / pool calc */
  #poolCalcModal > div { padding: 1.5rem 1rem !important; margin: 0.5rem !important; }
}

/* ── Very small (≤ 480px) ── */
@media (max-width: 480px) {
  .container-gp { padding: 12px 10px; }
  .page-header-title h1 { font-size: 1.2rem !important; }
  .card { padding: 12px !important; border-radius: 14px !important; }
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .btn-text-hide-xs { display: none !important; }
  /* Full-width action buttons in project rows */
  .project-actions-row { flex-direction: column !important; align-items: stretch !important; }
  .project-actions-row .btn { width: 100% !important; justify-content: center; }
  /* Unscheduled floating panel: make inline */
  .unscheduled-floating-panel { position: relative !important; right: auto !important; top: auto !important; width: 100% !important; margin-top: 16px; }
}

/* ── Print ── */
@media print {
  .sidebar-gp, .topbar-gp, .project-nav-container, .form-actions, .page-header-actions { display: none !important; }
  .main-wrap { margin-left: 0 !important; padding-top: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; }
}
