/* ─────────────────────────────────────────────────────────────────────────────
   Admiral Insights — styles
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --sidebar-w: 220px;
  --color-bg:       #f0f2f8;
  --color-surface:  #ffffff;
  --color-sidebar:  #111827;
  --color-sidebar-hover: #1f2937;
  --color-accent:   #6366f1;
  --color-accent2:  #10b981;
  --color-warn:     #f59e0b;
  --color-danger:   #ef4444;
  --color-text:     #111827;
  --color-muted:    #6b7280;
  --color-border:   #e5e7eb;
  --color-nav-text: #d1d5db;
  --radius:         8px;
  --shadow:         0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #111827 60%, #0f172a 100%);
}

.login-card {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 48px 40px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  text-align: center;
}

.login-logo img {
  height: 36px;
  margin-bottom: 20px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}

.login-sub {
  color: var(--color-muted);
  margin-bottom: 28px;
  font-size: 13px;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-form input {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
.login-form input:focus { border-color: var(--color-accent); }

.login-error {
  color: var(--color-danger);
  font-size: 13px;
}

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

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo img {
  height: 26px;
  filter: brightness(10) saturate(0); /* make logo white */
}

.sidebar-app-name {
  font-size: 13px;
  font-weight: 600;
  color: #e5e7eb;
  white-space: nowrap;
}

.sidebar-nav {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: none;
  color: var(--color-nav-text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
  transition: background .15s, color .15s;
  width: 100%;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-item:hover { background: var(--color-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--color-accent); color: #fff; }

.sidebar-files {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  border-top: 1px solid rgba(255,255,255,.06);
  margin-top: 8px;
}

.sidebar-files-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.4);
  padding: 4px 0 8px;
}

.sidebar-file-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}

.sidebar-file-name {
  color: #e5e7eb;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-file-meta {
  color: rgba(255,255,255,.35);
  font-size: 11px;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  background: none;
  color: rgba(255,255,255,.4);
  font-size: 13px;
  cursor: pointer;
  transition: color .15s;
  border-top: 1px solid rgba(255,255,255,.06);
  width: 100%;
  text-align: left;
}
.sidebar-logout:hover { color: var(--color-danger); }
.sidebar-logout svg {
  width: 15px; height: 15px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Main ──────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tab-panel { display: none; padding: 28px 32px; flex: 1; }
.tab-panel.active { display: block; }

.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--color-text); }
.page-header p  { color: var(--color-muted); margin-top: 4px; font-size: 13px; }

/* ── Filters bar ───────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 14px 32px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.filter-group label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-muted);
  font-weight: 600;
}

.filter-group input,
.filter-group select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--color-surface);
  color: var(--color-text);
  min-width: 130px;
  outline: none;
}

.filter-group input:focus,
.filter-group select:focus { border-color: var(--color-accent); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-bg); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Upload zone ───────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: 12px;
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--color-surface);
  max-width: 560px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--color-accent);
  background: rgba(99,102,241,.04);
}

.upload-icon svg {
  width: 44px; height: 44px;
  stroke: var(--color-accent); fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  margin-bottom: 14px;
}

.upload-primary { font-size: 15px; font-weight: 600; color: var(--color-text); }
.upload-secondary { color: var(--color-muted); margin-top: 6px; font-size: 13px; }
.upload-browse { color: var(--color-accent); cursor: pointer; text-decoration: underline; }

.upload-status {
  margin-top: 16px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  background: #f0fdf4;
  color: #166534;
  max-width: 560px;
}
.upload-status.error { background: #fef2f2; color: #991b1b; }
.upload-status.success { background: #f0fdf4; color: #166534; }

/* ── Loaded files ──────────────────────────────────────────────────────────── */
.loaded-files-list {
  margin-top: 28px;
  max-width: 560px;
}
.loaded-files-list h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

.files-table { width: 100%; border-collapse: collapse; }
.files-table th, .files-table td {
  padding: 8px 12px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}
.files-table th { font-weight: 600; color: var(--color-muted); }

/* ── KPI grid ──────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-muted); font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--color-text); }
.kpi-small { font-size: 15px; font-weight: 600; }

/* ── Charts ────────────────────────────────────────────────────────────────── */
.chart-row { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }

.chart-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  flex: 1;
  min-width: 0;
}
.chart-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--color-text); }
.chart-card--half { flex: 0 0 calc(50% - 10px); min-width: 280px; }
.chart-card--full { flex: 0 0 100%; }

.chart-wrap { position: relative; height: 260px; }
.chart-wrap--tall { height: 300px; }

/* ── Gantt ─────────────────────────────────────────────────────────────────── */
.page-header .gantt-controls {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}
.gantt-controls label {
  font-size: 12px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.gantt-controls select {
  padding: 5px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

.gantt-scroll {
  overflow-x: auto;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Frappe Gantt overrides */
.gantt .bar-label { font-size: 11px; }
.gantt .grid-header { fill: #f9fafb; }

/* ── Insights ──────────────────────────────────────────────────────────────── */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.insight-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}
.insight-card--blue    { border-left-color: #6366f1; }
.insight-card--green   { border-left-color: #10b981; }
.insight-card--warn    { border-left-color: #f59e0b; }
.insight-card--red     { border-left-color: #ef4444; }
.insight-card--neutral { border-left-color: #9ca3af; }
.insight-card--info    { border-left-color: #3b82f6; }

.insight-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.insight-icon  { font-size: 18px; line-height: 1; }
.insight-title { font-size: 13px; font-weight: 700; color: var(--color-text); }

.insight-rows {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.insight-rows li {
  font-size: 13px;
  color: var(--color-muted);
  line-height: 1.45;
}
.insight-rows li strong { color: var(--color-text); font-weight: 600; }

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-project  { background: #ede9fe; color: #5b21b6; }
.badge-employee { background: #d1fae5; color: #065f46; }

.empty-msg { color: var(--color-muted); padding: 32px 0; text-align: center; }
.error-msg { color: var(--color-danger); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 56px; }
  .sidebar-app-name, .nav-item span, .sidebar-files,
  .sidebar-logout span { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .main { }
  .tab-panel { padding: 16px; }
  .filters-bar { padding: 10px 16px; }
  .chart-card--half { flex: 0 0 100%; }
}
