/* ═══════════════════════════════════════════
   Sarta · custom.css
   Design direction: "Blueprint" — technical/precise,
   ink-blue on paper, flat brand-blue accent, no gradient.
   ═══════════════════════════════════════════ */

:root {
  --sidebar-width: 224px;
  --topbar-height: 52px;

  /* ── 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 (ink navy) ── */
  --color-primary:        #10263D;
  --color-primary-hover:  #16324E;
  --color-primary-subtle: #DCE7F2;

  /* ── Accent — flat brand blue (matches mark-flat-* logo assets). No gradient. ── */
  --color-accent:         #2563EB;
  --color-accent-hover:   #1D4FC4;
  --color-accent-subtle:  #DCE7F2;

  /* Map Bootstrap's primary utilities (.bg-primary/.text-primary/.border-primary) to the ink brand */
  --bs-primary:           #10263D;
  --bs-primary-rgb:       16, 38, 61;

  /* ── Status ── */
  --color-success: #1F7A5C;
  --color-warning: #B7791F;
  --color-danger:  #B23A2E;
  --color-info:    #2563EB;

  /* ── Neutral (cool paper, not warm cream) ── */
  --color-bg:             #EFF2F4;
  --color-surface:        #FFFFFF;
  --color-border:         #C7D3DC;
  --color-border-subtle:  #E3E8EC;
  --color-text:           #10263D;
  --color-text-secondary: #5B7186;
  --color-text-muted:     #8598A8;

  /* ── Sidebar (light paper column, not a dark block) ── */
  --color-sidebar-bg:     #F7F8F9;
  --color-sidebar-text:   #3C5164;
  --color-sidebar-border: #C7D3DC;

  /* ── Radius — sharp, technical/drafting feel ── */
  --radius-sm:   2px;
  --radius:      3px;   /* md */
  --radius-lg:   4px;
  --radius-xl:   6px;
  --radius-full: 9999px;

  /* ── Shadow — hairline rules do the work, not soft shadows ── */
  --shadow-xs: 0 1px 2px rgba(16,38,61,0.04);
  --shadow-sm: 0 1px 2px rgba(16,38,61,0.05);
  --shadow-md: none;
  --shadow-lg: 0 8px 20px rgba(16,38,61,0.09);

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

  /* ── Type roles ── */
  --font-display: 'Archivo', 'Century Gothic', 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;
  --font-body:    'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

  /* ── 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: var(--font-body);
  color: var(--color-text);
  font-size: var(--text-body);
  line-height: 1.5;
}

h1, .h1 { font-family: var(--font-display); font-size: var(--text-h1); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h2, .h2 { font-family: var(--font-display); font-size: var(--text-h2); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h3, .h3 { font-family: var(--font-display); font-size: var(--text-h3); line-height: 1.2; font-weight: 600; }

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

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-sidebar-border);
  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-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.sidebar-brand .brand-tagline {
  font-size: 0.63rem;
  color: var(--color-text-muted);
  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 0.475rem calc(0.75rem - 2px);
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.845rem;
  font-weight: 500;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 2px solid transparent;
  margin-bottom: 1px;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}

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

.sidebar-nav a:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

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

.sidebar-nav a.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  font-weight: 600;
}

.sidebar-nav a.active i { opacity: 1; color: var(--color-accent); }

.sidebar-nav .nav-section {
  padding: 1rem 0.75rem 0.35rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  font-weight: 700;
}

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

.sidebar-footer .ws-name {
  color: var(--color-text);
  font-weight: 600;
  margin-bottom: 0.15rem;
  font-size: 0.8rem;
}

/* ── 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-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  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: none;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: none;
}

.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(37,99,235,0.14);
  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 — outlined, monospace, bracket-tag rather than a pastel pill */
.badge-status-new           { color: #2563EB; }
.badge-status-triaged       { color: #5B6B8C; }
.badge-status-in_progress   { color: #B7791F; }
.badge-status-waiting_vendor{ color: #7C6A46; }
.badge-status-resolved      { color: #1F7A5C; }
.badge-status-closed        { color: #5B7186; }

/* Priority badges */
.badge-priority-low    { color: #8598A8; }
.badge-priority-medium { color: #2563EB; }
.badge-priority-high   { color: #B7791F; }
.badge-priority-urgent { color: #B23A2E; }

.status-badge, .priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  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;
}

/* Corner registration ticks — a drafting/blueprint convention, not decoration */
.stat-card::before, .stat-card::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  opacity: 0.6;
}
.stat-card::before {
  top: -1px; left: -1px;
  border-top: 1.5px solid var(--color-border);
  border-left: 1.5px solid var(--color-border);
}
.stat-card::after {
  bottom: -1px; right: -1px;
  border-bottom: 1.5px solid var(--color-border);
  border-right: 1.5px solid var(--color-border);
}

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

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  letter-spacing: -0.02em;
  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-family: var(--font-display);
  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-family: var(--font-display);
  font-size: 0.975rem;
  font-weight: 600;
  color: var(--color-text);
  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-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.015em;
}

/* Monospace ticket numbers */
.font-monospace { font-family: var(--font-mono) !important; 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: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ── 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; }
}
