/* ═══════════════════════════════════════════════════════════════
   Cast Internal Tools — Shared Design System
   app.css — tokens, layout, sidebar, auth, common components
═══════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────── */
:root {
  /* Brand */
  --pink:        #D4007A;
  --pink-dark:   #B8006A;
  --pink-pale:   #fce8f3;

  /* Semantic colours */
  --green:       #3a7d44;
  --green-pale:  #eaf4ec;
  --amber:       #b45309;
  --amber-pale:  #fef3c7;
  --red:         #c62828;
  --red-pale:    #fce4ec;
  --blue:        #0369a1;
  --blue-pale:   #e0f2fe;
  --purple:      #5b21b6;
  --purple-pale: #ede9fe;

  /* Surfaces — white → light grey → white (depth system) */
  --surface-app:   #ffffff;   /* app shell + sidebar */
  --surface-panel: #f4f4f4;   /* main panel */
  --surface-card:  #ffffff;   /* cards on panel */

  /* Text — all WCAG AA on --surface-panel (#f4f4f4) */
  --text:        #111111;     /* headings / primary */
  --text-sec:    #333333;     /* body / nav */
  --text-muted:  #666666;     /* subtitles — 5.7:1 */
  --text-label:  #777777;     /* section labels — 4.5:1 */

  /* Borders */
  --border:      #e8e8e8;
  --border-med:  #d1d5db;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
  --shadow-pink: 0 2px 8px rgba(212,0,122,0.12);

  /* Layout */
  --sidebar-w: 220px;

  /* Radii */
  --r-sm:  7px;
  --r-md:  10px;
  --r-lg:  12px;
  --r-xl:  16px;

  /* Font */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--surface-app);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Icon fix (Tabler outline font) ─────────────────────────── */
i[class*="ti"] {
  background: none !important;
  background-color: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  display: inline-block;
  line-height: 1;
  font-style: normal;
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Auth states ─────────────────────────────────────────────── */
.auth-loading-full {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--surface-panel);
}

.auth-screen-full {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--surface-panel);
}

.auth-card {
  background: var(--surface-card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pink);
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}
.auth-card img  { height: 36px; margin-bottom: 28px; display: block; margin-left: auto; margin-right: auto; }
.auth-card h2   { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.auth-card p    { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; line-height: 1.5; }

/* ── Auth spinner ────────────────────────────────────────────── */
.auth-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--pink-pale);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Microsoft sign-in button ────────────────────────────────── */
.ms-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1.5px solid var(--border-med);
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font);
  width: 100%;
  justify-content: center;
}
.ms-btn:hover { background: var(--surface-panel); border-color: #9ca3af; }

/* ── App shell ───────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--surface-app);
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-app);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-logo {
  padding: 22px 20px 16px;
  flex-shrink: 0;
}
.sidebar-logo .logo-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  object-position: left center;
}
.sidebar-logo .logo-sub { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 8px;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 10px 4px;
  display: block;
}

/* Use <a> tags for nav items — proper links, no button styling issues */
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-sec);
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}
.nav-item:hover  { background: #e8e8e8; color: var(--text-sec); }
.nav-item.active { background: #efefef; color: var(--text); font-weight: 500; }

.nav-item.coming-soon {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.sidebar-footer {
  padding: 12px 16px 16px;
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sec);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-signout {
  font-size: 11px;
  color: var(--pink);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  padding: 0;
  font-family: var(--font);
}
.sidebar-signout:hover { text-decoration: underline; }

/* ── Main panel ──────────────────────────────────────────────── */
.main-panel {
  flex: 1;
  background: var(--surface-panel);
  margin: 10px 10px 10px 0;
  border-radius: var(--r-lg);
  overflow-y: auto;
  min-height: 0;
  min-width: 0;
}

.main-panel::-webkit-scrollbar { width: 6px; }
.main-panel::-webkit-scrollbar-track { background: transparent; }
.main-panel::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 3px; }
.main-panel::-webkit-scrollbar-thumb:hover { background: #bbb; }

.panel-inner {
  padding: 40px 40px 60px;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface-card);
  border: 0.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 24px;
}
.card + .card { margin-top: 16px; }

.card-hdr {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-label);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--border);
}

/* ── Typography ──────────────────────────────────────────────── */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.sec-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-label);
}
.page-title-row {
  margin-bottom: 24px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-pink {
  background: var(--pink);
  color: #fff;
  border-color: var(--pink);
}
.btn-pink:hover { background: var(--pink-dark); border-color: var(--pink-dark); }
.btn-outline {
  background: var(--surface-card);
  color: var(--text-sec);
  border-color: var(--border-med);
}
.btn-outline:hover { border-color: var(--pink); color: var(--pink); }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.badge-interiors { background: var(--blue-pale);   color: var(--blue); }
.badge-contracts { background: var(--amber-pale);  color: var(--amber); }
.badge-furniture { background: var(--green-pale);  color: var(--green); }
.badge-labs      { background: var(--purple-pale); color: var(--purple); }
.badge-all       { background: var(--green-pale);  color: var(--green); }
.badge-bid       { background: var(--pink-pale);   color: var(--pink); }
.badge-soon      { background: #f3f4f6;            color: #9ca3af; }

/* ── Job code badges (monospace) ─────────────────────────────── */
.job-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: nowrap;
}
.job-badge-Interiors { background: var(--blue-pale);   color: var(--blue); }
.job-badge-Contracts { background: var(--amber-pale);  color: var(--amber); }
.job-badge-Labs      { background: var(--purple-pale); color: var(--purple); }
.job-badge-Furniture { background: var(--green-pale);  color: var(--green); }

/* ── Status dots ─────────────────────────────────────────────── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-red   { background: var(--red); }
.dot-amber { background: var(--amber); }
.dot-green { background: var(--green); }

/* ── Pill (status chip) ──────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-ok    { background: var(--green-pale); color: var(--green); }
.pill-watch { background: var(--amber-pale); color: var(--amber); }
.pill-high  { background: var(--red-pale);   color: var(--red); }

/* ── Upload zone ─────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-med);
  border-radius: var(--r-md);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  background: var(--surface-panel);
}
.upload-zone:hover     { border-color: var(--pink); background: var(--pink-pale); }
.upload-zone.has-file  { border-style: solid; border-color: var(--green); background: var(--green-pale); }
.upload-zone.drag-over { border-color: var(--pink); background: var(--pink-pale); }
.upload-zone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.upload-icon  { font-size: 28px; margin-bottom: 8px; }
.upload-label { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.upload-hint  { font-size: 12px; color: var(--text-muted); }
.upload-fname { font-size: 12px; color: var(--green); font-weight: 600; margin-top: 8px; word-break: break-all; }

/* ── Inline spinner (status bars) ───────────────────────────── */
.spin-sm {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(212,0,122,0.2);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* ── Status bar ──────────────────────────────────────────────── */
.status-bar {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--pink-pale);
  border: 1px solid rgba(212,0,122,0.2);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 13px;
  color: var(--pink);
  font-weight: 500;
  margin-bottom: 14px;
}
.status-bar.visible { display: flex; }

/* ── Error bar ───────────────────────────────────────────────── */
.error-bar {
  display: none;
  background: var(--red-pale);
  border: 1px solid #f48fb1;
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 14px;
}
.error-bar.visible { display: block; }

/* ── Form fields (shared across tools) ───────────────────────── */
.field        { margin-bottom: 20px; }
.field-label  { display: block; font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.field-hint   { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; line-height: 1.5; }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border-med);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-card);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(212,0,122,0.08);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 20px;
  border-radius: var(--r-sm); font-size: 13px; z-index: 9999;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
