/* ═══════════════════════════════════════════
   Sarta · custom.css
   Tokens generated from staticfiles/design_system.json
   (Sarta Design System v1.0.0)
   ═══════════════════════════════════════════ */

:root {
  --sidebar-width: 240px;
  --topbar-height: 56px;

  /* ── Spacing (8pt base) ── */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 40px;
  --space-3xl: 48px;

  /* ── Brand / primary (navy) ── */
  --color-primary:        #0F172A;
  --color-primary-hover:  #1E293B;
  --color-primary-subtle: #E2E8F0;

  /* ── Accent (violet — interactive states & single-color gradient stand-in) ── */
  --color-accent:         #7C3AED;
  --color-accent-hover:   #6D28D9;
  --color-accent-subtle:  #EDE9FE;

  /* ── Brand gradient (controlled accent: violet → teal) ── */
  --gradient-primary:     linear-gradient(135deg, #7C3AED, #2DD4BF);
  --gradient-from:        #7C3AED;
  --gradient-to:          #2DD4BF;

  /* Map Bootstrap's primary utilities (.bg-primary/.text-primary/.border-primary) to the navy brand */
  --bs-primary:           #0F172A;
  --bs-primary-rgb:       15, 23, 42;

  /* ── Status ── */
  --color-success: #16A34A;
  --color-warning: #F59E0B;
  --color-danger:  #DC2626;
  --color-info:    #0EA5E9;

  /* ── Neutral ── */
  --color-bg:             #F9FAFB;
  --color-surface:        #FFFFFF;
  --color-border:         #E5E7EB;
  --color-border-subtle:  #F3F4F6;
  --color-text:           #111827;
  --color-text-secondary: #6B7280;
  --color-text-muted:     #9CA3AF;

  /* ── Sidebar (dark brand surface) ── */
  --color-sidebar-bg:     #0F172A;
  --color-sidebar-text:   #9CA3AF;
  --color-sidebar-border: rgba(255,255,255,0.065);

  /* ── Radius ── */
  --radius-sm:   6px;
  --radius:      8px;   /* md */
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  /* ── Shadow ── */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 24px rgba(0,0,0,0.08);

  /* ── Typography scale ── */
  --text-h1:      32px;
  --text-h2:      24px;
  --text-h3:      20px;
  --text-body:    16px;
  --text-small:   14px;
  --text-caption: 12px;

  /* ── Motion ── */
  --motion-fast:   150ms;
  --motion-normal: 200ms;
  --motion-slow:   300ms;
  --ease:          ease-in-out;

  /* ── z-index ── */
  --z-dropdown: 1000;
  --z-sticky:   1100;
  --z-modal:    1200;
  --z-toast:    1300;
}

/* ── Base ──────────────────────────────────────── */

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

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

h1, .h1 { font-size: var(--text-h1); line-height: 1.2; font-weight: 700; }
h2, .h2 { font-size: var(--text-h2); line-height: 1.2; font-weight: 700; }
h3, .h3 { font-size: var(--text-h3); line-height: 1.2; font-weight: 600; }

/* Gradient utilities (design-system token) */
.bg-gradient-primary { background: var(--gradient-primary); }
.text-gradient-primary {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── Sidebar ───────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 1.125rem 1.25rem 1rem;
  border-bottom: 1px solid var(--color-sidebar-border);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .brand-mark {
  flex: 0 0 auto;
  display: block;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sidebar-brand .brand-name {
  font-size: 1.05rem;
  font-weight: 750;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.sidebar-brand .brand-tagline {
  font-size: 0.66rem;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.sidebar-nav {
  padding: 0.75rem 0.625rem;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.475rem 0.75rem;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.845rem;
  font-weight: 500;
  border-radius: var(--radius);
  margin-bottom: 1px;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

.sidebar-nav a i {
  font-size: 0.875rem;
  width: 1rem;
  flex-shrink: 0;
  opacity: 0.75;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.05);
  color: #E5E7EB;
}

.sidebar-nav a:hover i { opacity: 1; }

.sidebar-nav a.active {
  background: rgba(124,58,237,0.20);
  color: #C4B5FD;
  font-weight: 600;
}

.sidebar-nav a.active i { opacity: 1; color: #C4B5FD; }

.sidebar-nav .nav-section {
  padding: 1rem 0.75rem 0.35rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #374151;
  font-weight: 600;
}

.sidebar-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--color-sidebar-border);
  font-size: 0.775rem;
  color: #6B7280;
}

/* ── Main layout ───────────────────────────────── */

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

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 0.875rem;
  box-shadow: var(--shadow-xs);
}

.topbar-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-content {
  padding: 1.75rem 1.5rem;
  flex: 1;
}

/* ── Bootstrap component overrides ─────────────── */

/* Buttons */
.btn {
  font-family: inherit;
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: var(--radius);
  padding: 10px 16px;
  transition: all var(--motion-fast) var(--ease);
  font-size: 0.855rem;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 1px 2px rgba(15,23,42,0.20);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: 0 2px 6px rgba(15,23,42,0.26);
}

.btn-outline-secondary {
  border-color: var(--color-border);
  color: var(--color-text-secondary);
}
.btn-outline-secondary:hover {
  background: var(--color-bg);
  border-color: #D1D5DB;
  color: var(--color-text);
}

.btn-outline-primary {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.btn-outline-primary:hover {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-outline-dark { border-color: #374151; color: #374151; }
.btn-outline-dark:hover { background: #374151; color: #fff; }

.btn-dark { background: #1F2937; border-color: #1F2937; }
.btn-dark:hover { background: #111827; border-color: #111827; }

/* Form inputs */
.form-control, .form-select {
  font-family: inherit;
  font-size: 0.875rem;
  border-color: #D1D5DB;
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--color-text);
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
  box-shadow: var(--shadow-xs);
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
  outline: none;
}

.form-control-sm, .form-select-sm { font-size: 0.825rem; padding: 0.35rem 0.6rem; }

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.3rem;
}

textarea.form-control { resize: vertical; }

.input-group-text {
  background: var(--color-bg);
  border-color: #D1D5DB;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

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

.card-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-size: 0.875rem;
}

.card-footer {
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Tables */
.table {
  font-size: 0.855rem;
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  padding: 0.875rem 1rem;
  vertical-align: middle;
}

.table thead tr { background: var(--color-border-subtle); }

.table th {
  font-size: 0.695rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border) !important;
  white-space: nowrap;
}

.table td { border-color: var(--color-border-subtle); }

.table-hover > tbody > tr:hover > * { background: #F9FAFB; }

.table-light {
  --bs-table-bg: var(--color-border-subtle);
  --bs-table-border-color: var(--color-border);
}

/* Nav tabs */
.nav-tabs {
  border-bottom: 1px solid var(--color-border);
  gap: 2px;
}

.nav-tabs .nav-link {
  border: none;
  border-radius: 0;
  color: var(--color-text-muted);
  font-size: 0.855rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  transition: color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
  background: transparent;
}

.nav-tabs .nav-link:hover {
  color: var(--color-text);
  border-bottom-color: #D1D5DB;
  background: transparent;
}

.nav-tabs .nav-link.active {
  color: var(--color-accent);
  font-weight: 600;
  border-bottom: 2px solid var(--color-accent);
  background: transparent;
}

/* List groups */
.list-group-item {
  border-color: var(--color-border-subtle);
  font-size: 0.875rem;
  padding: 0.7rem 1.25rem;
  color: var(--color-text);
}

.list-group-item-action { transition: background var(--motion-fast) var(--ease); }

.list-group-item-action:hover,
.list-group-item-action:focus {
  background: var(--color-bg);
  color: var(--color-text);
}

/* Badges */
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

/* Alerts */
.alert {
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.alert-danger  { background: #FEE2E2; border-color: #FECACA; color: #991B1B; }
.alert-success { background: #DCFCE7; border-color: #BBF7D0; color: #166534; }
.alert-info    { background: #E0F2FE; border-color: #BAE6FD; color: #075985; }
.alert-warning { background: #FEF3C7; border-color: #FDE68A; color: #92400E; }

/* Pagination */
.pagination { gap: 2px; }

.page-link {
  border-radius: var(--radius-sm);
  border-color: var(--color-border);
  color: var(--color-text-secondary);
  font-size: 0.82rem;
  padding: 0.3rem 0.65rem;
  transition: all var(--motion-fast) var(--ease);
}

.page-link:hover {
  background: var(--color-bg);
  border-color: #D1D5DB;
  color: var(--color-text);
}

.page-item.active .page-link {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.page-item.disabled .page-link {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

/* ── App-specific ───────────────────────────────── */

/* Status badges */
.badge-status-new           { background: #cffafe; color: #0e7490; }
.badge-status-triaged       { background: #DBEAFE; color: #1D4ED8; }
.badge-status-in_progress   { background: #FEF3C7; color: #92400E; }
.badge-status-waiting_vendor{ background: #F3F4F6; color: #6B7280; }
.badge-status-resolved      { background: #DCFCE7; color: #166534; }
.badge-status-closed        { background: #F3F4F6; color: #374151; }

/* Priority badges */
.badge-priority-low    { background: #F3F4F6; color: #6B7280; }
.badge-priority-medium { background: #DBEAFE; color: #1D4ED8; }
.badge-priority-high   { background: #FEF3C7; color: #92400E; }
.badge-priority-urgent { background: #FEE2E2; color: #991B1B; }

.status-badge, .priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.695rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  white-space: nowrap;
  line-height: 1.4;
}

/* Stat cards */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.125rem 1.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-border);
}

.stat-card.urgent::before  { background: var(--color-danger); }
.stat-card.waiting::before { background: var(--color-warning); }
.stat-card.resolved::before{ background: var(--color-success); }

.stat-card .stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
  font-size: 0.775rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.stat-card.urgent .stat-value  { color: var(--color-danger); }
.stat-card.waiting .stat-value { color: var(--color-warning); }
.stat-card.resolved .stat-value{ color: var(--color-success); }

/* Ticket row */
.ticket-row { transition: background var(--motion-fast) var(--ease); }
.ticket-row:hover { background: var(--color-bg); }

/* Detail page panels */
.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.375rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-xs);
}

.form-section-title {
  font-size: 0.695rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-text-muted);
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

/* Photo grid */
.photo-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.photo-thumb {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: opacity var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}

.photo-thumb:hover { opacity: 0.82; transform: scale(1.04); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--color-text-secondary);
}

.empty-state h4 {
  font-size: 0.975rem;
  font-weight: 600;
  color: #374151;
  margin-top: 0.875rem;
  margin-bottom: 0.375rem;
}

.empty-state p {
  font-size: 0.855rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

/* Internal note bubbles */
.note-bubble {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

/* Override Bootstrap bg-light inside forms */
.form-section .bg-light.rounded {
  background: var(--color-bg) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius) !important;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 1.375rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.4rem; top: 0.45rem; bottom: 0;
  width: 1.5px;
  background: var(--color-border);
}

.timeline-item {
  position: relative;
  padding-bottom: 1.125rem;
  font-size: 0.855rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -0.975rem;
  top: 0.35rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #9CA3AF;
  border: 2px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
}

.timeline-time {
  font-size: 0.695rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}

/* Public form */
.public-form-wrapper {
  max-width: 660px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.public-brand { text-align: center; margin-bottom: 1.75rem; }

.public-brand h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.025em;
}

/* Monospace ticket numbers */
.font-monospace { font-size: 0.8rem !important; letter-spacing: -0.01em; }

/* Scrollbar (WebKit) */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ── Responsive ─────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--motion-slow) cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 1.25rem 1rem; }
  .topbar { padding: 0 1rem; }
}
