/* ============================================================
   GLOBAL DESIGN SYSTEM — FRP Hull Cost Estimator
   Dark Navy + Amber industrial/engineering aesthetic
   ============================================================ */

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

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  --navy-950:  #080d1a;
  --navy-900:  #0c1225;
  --navy-850:  #0f1830;
  --navy-800:  #132040;
  --navy-700:  #1a2d55;
  --navy-600:  #1f3566;
  --navy-500:  #2a4480;

  --amber-300: #fcd34d;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;

  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;

  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #3b82f6;

  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --topbar-h:  0px;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --glow-amber: 0 0 20px rgba(251,191,36,0.15);
  --glow-amber-strong: 0 0 32px rgba(251,191,36,0.3);

  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.4s cubic-bezier(0.4,0,0.2,1);
}

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

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--navy-950);
  color: var(--slate-300);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Sidebar Navigation ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy-900);
  border-right: 1px solid var(--navy-800);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--navy-800);
  min-height: 72px;
  overflow: hidden;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--amber-500), var(--amber-600));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: var(--glow-amber);
}

.sidebar-logo .logo-text {
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-logo .logo-text span:first-child {
  font-size: 12px; font-weight: 700; color: var(--amber-400);
  letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
.sidebar-logo .logo-text span:last-child {
  font-size: 10px; color: var(--slate-400); white-space: nowrap; margin-top: 1px;
}

.sidebar-collapse-btn {
  margin: 0 8px 4px auto;
  background: none; border: none;
  color: var(--slate-400); cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: var(--amber-400); background: var(--navy-800); }

.sidebar-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--slate-400);
  padding: 16px 16px 6px; white-space: nowrap; overflow: hidden;
  opacity: 1; transition: opacity var(--transition-slow);
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; }

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

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  color: var(--slate-400);
  text-decoration: none;
  border-radius: 0;
  font-size: 13px; font-weight: 500;
  transition: color var(--transition), background var(--transition);
  position: relative; overflow: hidden;
  white-space: nowrap;
  border-left: 3px solid transparent;
}
.nav-link .nav-icon { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }
.nav-link .nav-label { overflow: hidden; transition: opacity var(--transition-slow); }
.sidebar.collapsed .nav-link .nav-label { opacity: 0; pointer-events: none; }

.nav-link:hover { color: var(--amber-300); background: var(--navy-800); }
.nav-link.active {
  color: var(--amber-400); background: rgba(251,191,36,0.08);
  border-left-color: var(--amber-400);
}
.nav-link.active::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(251,191,36,0.06), transparent);
}

.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid var(--navy-800);
  font-size: 10px; color: var(--navy-600); white-space: nowrap; overflow: hidden;
  transition: opacity var(--transition-slow);
}
.sidebar.collapsed .sidebar-footer { opacity: 0; }

/* ── Main Content Area ────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  transition: margin-left var(--transition-slow);
  display: flex; flex-direction: column;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-w-collapsed); }

.page-header {
  padding: 28px 32px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--slate-200); }
.page-subtitle { font-size: 13px; color: var(--slate-400); margin-top: 3px; }

.page-body { padding: 24px 32px 40px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--navy-900);
  border: 1px solid var(--navy-800);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--glow-amber); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--slate-200); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--amber-500), var(--amber-600));
  color: #000;
  box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--amber-400), var(--amber-500)); box-shadow: var(--glow-amber-strong); }

.btn-secondary {
  background: var(--navy-800);
  color: var(--slate-300);
  border: 1px solid var(--navy-700);
}
.btn-secondary:hover { background: var(--navy-700); color: var(--slate-200); }

.btn-ghost {
  background: transparent;
  color: var(--slate-400);
  border: 1px solid var(--navy-700);
}
.btn-ghost:hover { color: var(--slate-200); background: var(--navy-800); }

.btn-danger { background: rgba(239,68,68,0.12); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.22); }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-icon {
  padding: 7px; background: var(--navy-800); border: 1px solid var(--navy-700);
  color: var(--slate-400); border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.btn-icon:hover { color: var(--amber-400); background: var(--navy-700); border-color: var(--amber-600); }
.btn-icon.danger:hover { color: var(--danger); border-color: var(--danger); background: rgba(239,68,68,0.1); }

/* ── Inputs ───────────────────────────────────────────────── */
.input, .select, .textarea {
  background: var(--navy-850);
  border: 1px solid var(--navy-700);
  color: var(--slate-200);
  border-radius: var(--radius-md);
  padding: 9px 13px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--navy-500); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--amber-500);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.1);
}
.select option { background: var(--navy-900); }

.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--slate-400); margin-bottom: 5px; letter-spacing: 0.03em;
}
.form-group { display: flex; flex-direction: column; }
.form-hint { font-size: 11px; color: var(--navy-500); margin-top: 4px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em; white-space: nowrap;
}
.badge-amber   { background: rgba(251,191,36,0.12); color: var(--amber-400); border: 1px solid rgba(251,191,36,0.2); }
.badge-blue    { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.badge-green   { background: rgba(34,197,94,0.12);  color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.badge-red     { background: rgba(239,68,68,0.12);  color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-purple  { background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.2); }
.badge-slate   { background: rgba(148,163,184,0.1); color: var(--slate-400); border: 1px solid rgba(148,163,184,0.15); }
.badge-teal    { background: rgba(20,184,166,0.12); color: #2dd4bf; border: 1px solid rgba(20,184,166,0.2); }
.badge-orange  { background: rgba(249,115,22,0.12); color: #fb923c; border: 1px solid rgba(249,115,22,0.2); }

/* ── Table ────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--navy-800);
}

table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
thead { background: var(--navy-850); }
th {
  padding: 11px 14px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--slate-400);
  border-bottom: 1px solid var(--navy-800);
  white-space: nowrap;
  cursor: pointer; user-select: none;
}
th.sortable:hover { color: var(--amber-400); }
th .sort-icon { margin-left: 4px; opacity: 0.4; font-size: 10px; }
th.sort-asc .sort-icon, th.sort-desc .sort-icon { opacity: 1; color: var(--amber-400); }

tbody tr {
  border-bottom: 1px solid rgba(19,32,64,0.7);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(26,45,85,0.4); }

td { padding: 12px 14px; color: var(--slate-300); vertical-align: middle; }
td .mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--amber-400); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,8,20,0.8);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--navy-900);
  border: 1px solid var(--navy-700);
  border-radius: var(--radius-xl);
  width: min(560px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), var(--glow-amber);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition);
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--navy-800);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--slate-200); }
.modal-close {
  background: none; border: none; color: var(--slate-400); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--slate-200); background: var(--navy-800); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--navy-800);
}

/* ── Search & Filter Bar ──────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.search-wrapper {
  position: relative; flex: 1; min-width: 200px; max-width: 340px;
}
.search-wrapper .search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--navy-500); font-size: 16px; pointer-events: none;
}
.search-wrapper .input { padding-left: 36px; }

/* Filter chip tabs */
.filter-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.filter-tab {
  padding: 5px 13px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: var(--navy-800); color: var(--slate-400);
  border: 1px solid var(--navy-700); cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.filter-tab:hover { color: var(--slate-200); border-color: var(--navy-600); }
.filter-tab.active {
  background: rgba(251,191,36,0.1); color: var(--amber-400);
  border-color: rgba(251,191,36,0.3);
}

/* ── Toast Notifications ──────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--radius-md);
  background: var(--navy-900); border: 1px solid var(--navy-700);
  box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--slate-200);
  pointer-events: all;
  animation: toastIn 0.3s ease forwards;
  max-width: 340px;
}
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.success .toast-icon { color: var(--success); }
.toast.error   { border-color: rgba(239,68,68,0.3); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    { border-color: rgba(59,130,246,0.3); }
.toast.info    .toast-icon { color: var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 32px; text-align: center; gap: 12px;
}
.empty-state .empty-icon { font-size: 48px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--slate-400); }
.empty-state p { font-size: 13px; color: var(--navy-600); max-width: 280px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-row { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 140px;
  background: var(--navy-900); border: 1px solid var(--navy-800);
  border-radius: var(--radius-lg); padding: 18px 20px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--glow-amber); }
.stat-value { font-size: 26px; font-weight: 800; color: var(--slate-200); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--slate-400); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; }
.stat-accent { color: var(--amber-400); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--navy-900); }
::-webkit-scrollbar-thumb { background: var(--navy-700); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy-600); }

/* ── Utilities ────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-4 { margin-top: 16px; }
.text-muted { color: var(--slate-400); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-amber { color: var(--amber-400); }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Form Grid ────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid .full-width { grid-column: 1 / -1; }

/* ── Skeleton loader ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--navy-800) 25%, var(--navy-700) 50%, var(--navy-800) 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; }
}

/* ── Confirm Dialog ───────────────────────────────────────── */
.confirm-dialog .modal-header { border-color: rgba(239,68,68,0.2); }
.confirm-dialog .modal-body p { color: var(--slate-300); line-height: 1.6; font-size: 13px; }
.confirm-dialog .highlight { color: var(--amber-400); font-weight: 600; }

/* ── Page transition ──────────────────────────────────────── */
.page-enter { animation: pageEnter 0.35s ease forwards; }
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Divider ──────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--navy-800); margin: 16px 0; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile First (≤768px)
══════════════════════════════════════════════════════════════ */

/* ── Hamburger toggle button (hidden on desktop) ─────────── */
.mobile-menu-btn {
  display: none;
  background: none; border: 1px solid var(--navy-700);
  color: var(--slate-300); border-radius: var(--radius-sm);
  padding: 8px 10px; cursor: pointer;
  position: fixed; top: 12px; left: 12px; z-index: 200;
  transition: background var(--transition);
}
.mobile-menu-btn:hover { background: var(--navy-800); }

/* ── Sidebar overlay on mobile ───────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 768px) {
  /* Show hamburger */
  .mobile-menu-btn { display: flex; align-items: center; gap: 6px; }

  /* Sidebar slides in from left */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    z-index: 100;
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* Main content takes full width */
  .main-content { margin-left: 0 !important; padding-top: 56px; }

  /* Page header */
  .page-header-strip { padding: 14px 16px 12px; }
  .header-row { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Touch targets — all interactive elements min 44px */
  .btn, .input, .select, .nav-link,
  .filter-tab, .auth-tab, .tab-btn {
    min-height: 44px;
    box-sizing: border-box;
  }
  .btn { width: 100%; justify-content: center; }
  .btn.btn-sm { min-height: 38px; width: auto; }
  .btn-icon { min-height: 36px; min-width: 36px; }

  /* Form grids → single column */
  .form-grid { grid-template-columns: 1fr; }
  .resin-grid { grid-template-columns: 1fr; }

  /* Tables → horizontal scroll */
  .table-outer, .table-container, .parts-table { overflow-x: auto; }
  table { min-width: 500px; }
  .layup-table { min-width: 800px; }

  /* Section cards padding */
  .section-card { margin: 12px; padding: 14px; }

  /* Mat grid → single column */
  .mat-grid { grid-template-columns: 1fr; padding: 12px 16px; }

  /* Font scaling */
  .page-title { font-size: 17px; }
  .modal { margin: 12px; width: calc(100vw - 24px) !important; max-height: 90vh; overflow-y: auto; }

  /* Totals grid → 2 columns */
  .totals-grid { grid-template-columns: 1fr 1fr; }

  /* Admin panel user grid → 1 column */
  .user-grid { grid-template-columns: 1fr; }

  /* Auth card */
  .auth-container { padding: 12px; }

  /* Client header */
  .client-header { flex-direction: column; text-align: center; padding: 12px 16px; }
  .client-welcome { order: -1; }
  .client-body { padding: 12px; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .quoted-value { font-size: 28px; }

  /* Toolbar */
  .mat-toolbar { padding: 10px 16px; }
  .filter-tabs { gap: 4px; }
  .filter-tab { padding: 6px 10px; font-size: 11px; min-height: 36px; }

  /* Project bar */
  .project-bar { width: 100%; }
  .project-bar select { width: 100%; }

  /* Add layer bar */
  .add-layer-bar { flex-wrap: wrap; padding: 8px 16px; }

  /* Sidebar footer label */
  .sidebar-footer span { display: none; }

  /* Admin tabs */
  .tabs-nav { flex-wrap: wrap; gap: 6px; }
  .tab-btn { flex: 1; min-width: 100px; min-height: 40px; }

  /* Table cells */
  th, td { padding: 8px 10px; font-size: 12px; }
}

@media (max-width: 480px) {
  .info-grid { grid-template-columns: 1fr; }
  .totals-grid { grid-template-columns: 1fr; }
  .total-card { min-width: unset; }
  .mat-grid { padding: 10px; }
  .client-body { padding: 8px; }
}

