/* ============================================================================
 * DocuTrack — Main Stylesheet
 * Redbit Theme (matching rk2ju)
 * ========================================================================== */

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

:root {
  --red:        #EA3446;
  --red-hover:  #D52938;
  --red-50:     #FEEBEE;
  --slate:      #3D5367;
  --dark:       #0F172A;
  --ink:        #1F2937;
  --muted:      #6B7280;
  --light:      #9CA3AF;
  --border:     #E5E7EB;
  --border-soft:#F1F2F4;
  --bg:         #FFFFFF;
  --bg-soft:    #FAFAFA;
  --bg-hover:   #F9FAFB;

  --green:      #10B981;
  --green-50:   #D1FAE5;
  --green-700:  #047857;
  --amber:      #F59E0B;
  --amber-50:   #FEF3C7;
  --amber-700:  #B45309;
  --blue:       #3B82F6;
  --blue-50:    #DBEAFE;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============================================================================
 * APP LAYOUT
 * ========================================================================== */
.app { display: flex; min-height: 100vh; }

/* ============================================================================
 * SIDEBAR (matching rk2ju)
 * ========================================================================== */
.sidebar {
  width: 240px;
  background: white;
  border-right: 1px solid var(--border);
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand-box {
  padding: 0 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 40px; height: 40px;
  background: var(--red);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; color: var(--dark); }
.brand-tag  { font-size: 12px; color: var(--muted); }

.nav-section { margin-top: 8px; padding: 0 12px; }
.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 12px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 1px;
}
.nav-link:hover { background: var(--bg-hover); }
.nav-link.active { background: var(--bg-soft); font-weight: 500; }
.nav-link.danger { color: var(--red); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.nav-link.active .nav-icon { color: var(--ink); }
.nav-link.danger .nav-icon { color: var(--red); }
.nav-link .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* ============================================================================
 * MAIN AREA
 * ========================================================================== */
.main { flex: 1; background: white; min-width: 0; }

.breadcrumb-bar { padding: 24px 32px 0; }
.breadcrumb { font-size: 14px; color: var(--muted); }
.breadcrumb a, .breadcrumb span { color: var(--muted); }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { margin: 0 8px; color: var(--light); }
.breadcrumb .current { color: var(--ink); }

.page-content { padding: 24px 32px 40px; }

.page-title-block { margin-bottom: 28px; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.page-title { font-size: 28px; font-weight: 600; color: var(--dark); letter-spacing: -0.02em; margin-bottom: 4px; }
.page-subtitle { color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 8px; }

/* ============================================================================
 * STATS CARDS
 * ========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 20px 24px; }
.stat-card.featured { border-color: var(--red); background: linear-gradient(135deg, white 0%, #FFF8F8 100%); }
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.stat-value { font-size: 32px; font-weight: 600; color: var(--dark); letter-spacing: -0.02em; line-height: 1; }
.stat-meta { margin-top: 10px; font-size: 12px; color: var(--muted); }
.stat-meta.danger { color: var(--red); }
.stat-meta.success { color: var(--green-700); }

/* ============================================================================
 * PANELS / CARDS
 * ========================================================================== */
.panel { background: white; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
.panel-header { padding: 20px 24px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.panel-header h3 { font-size: 16px; font-weight: 600; color: var(--dark); }
.panel-header .panel-meta { font-size: 13px; color: var(--muted); }
.panel-body { padding: 24px; }
.panel-body.no-pad { padding: 0; }
.panel-footer { padding: 16px 24px; border-top: 1px solid var(--border-soft); background: var(--bg-soft); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }

/* ============================================================================
 * BUTTONS
 * ========================================================================== */
.btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.btn-primary { background: var(--red); color: white; border-color: var(--red); }
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn-secondary { background: white; color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-soft); border-color: var(--light); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn-success { background: var(--green); color: white; border-color: var(--green); }
.btn-success:hover { background: var(--green-700); border-color: var(--green-700); }
.btn-danger { background: var(--red); color: white; border-color: var(--red); }
.btn-large { padding: 12px 22px; font-size: 14px; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-icon { width: 16px; height: 16px; stroke-width: 2; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================================
 * FORMS
 * ========================================================================== */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: block; }
.field label { display: block; font-size: 13px; color: var(--ink); margin-bottom: 6px; font-weight: 500; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: white;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* ----- Custom select styling (Safari, Chrome, Firefox consistent) ----- */
.field select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
  cursor: pointer;
}
.field select:hover {
  border-color: var(--ink-soft, #94A3B8);
}
.field select:disabled {
  background-color: #F8FAFC;
  color: var(--muted);
  cursor: not-allowed;
}
.field select::-ms-expand { display: none; }

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-50);
}
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .error { font-size: 12px; color: var(--red); margin-top: 4px; }
.field textarea { resize: vertical; min-height: 80px; }

/* ============================================================================
 * DROPZONE
 * ========================================================================== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 56px 32px;
  text-align: center;
  background: var(--bg-soft);
  transition: all 0.15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--red); background: #FFFBFB; }
.dz-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--red);
}
.dz-title { font-size: 16px; font-weight: 600; color: var(--dark); margin-bottom: 4px; }
.dz-sub { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.dz-spec { font-size: 12px; color: var(--light); padding-top: 12px; border-top: 1px solid var(--border); display: inline-block; padding: 12px 14px 0; }
.dz-input { display: none; }

/* ============================================================================
 * TABLES
 * ========================================================================== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}
table.data tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.data tbody tr:hover td { background: var(--bg-hover); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num { font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
table.data .doc-no { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--ink); font-weight: 500; }
table.data .secondary { color: var(--muted); font-size: 12px; }

table.data tr.row-warning { background: var(--amber-50); }
table.data tr.row-warning:hover td { background: #FCE7B0; }
table.data tr.row-danger { background: var(--red-50); }
table.data tr.row-danger:hover td { background: #FBD5D5; }

/* ============================================================================
 * PILLS / TAGS
 * ========================================================================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill-success { background: var(--green-50); color: var(--green-700); }
.pill-success .dot { background: var(--green); }
.pill-amber   { background: var(--amber-50); color: var(--amber-700); }
.pill-amber .dot { background: var(--amber); }
.pill-danger  { background: var(--red-50); color: var(--red); }
.pill-danger .dot { background: var(--red); }
.pill-info    { background: var(--blue-50); color: #1E40AF; }
.pill-info .dot { background: var(--blue); }
.pill-neutral { background: var(--bg-soft); color: var(--muted); }
.pill-neutral .dot { background: var(--light); }

/* ============================================================================
 * CONFIDENCE METER
 * ========================================================================== */
.conf { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.conf-track { flex: 1; height: 5px; background: var(--border-soft); border-radius: 3px; overflow: hidden; }
.conf-track > div { height: 100%; border-radius: 3px; }
.conf-num { font-family: 'SF Mono', monospace; font-size: 12px; font-weight: 600; min-width: 36px; text-align: right; }
.conf.high .conf-track > div { background: var(--green); }
.conf.high .conf-num { color: var(--green-700); }
.conf.mid .conf-track > div { background: var(--amber); }
.conf.mid .conf-num { color: var(--amber-700); }
.conf.low .conf-track > div { background: var(--red); }
.conf.low .conf-num { color: var(--red); }

/* ============================================================================
 * BANNERS
 * ========================================================================== */
.banner {
  padding: 14px 18px;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid;
}
.banner-icon { flex-shrink: 0; margin-top: 1px; width: 18px; height: 18px; }
.banner-info { background: var(--blue-50); color: #1E3A8A; border-color: #BFDBFE; }
.banner-warn { background: var(--amber-50); color: var(--amber-700); border-color: #FDE68A; }
.banner-success { background: var(--green-50); color: var(--green-700); border-color: #A7F3D0; }
.banner-danger { background: var(--red-50); color: var(--red); border-color: #FCA5A5; }
.banner strong { font-weight: 600; }

/* ============================================================================
 * STEPPER
 * ========================================================================== */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.step { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  background: white; border: 1px solid var(--border); color: var(--muted);
}
.step.done .step-num { background: var(--green); border-color: var(--green); color: white; }
.step.active .step-num { background: var(--red); border-color: var(--red); color: white; }
.step .step-label { color: var(--muted); }
.step.active .step-label { color: var(--ink); font-weight: 500; }
.step.done .step-label { color: var(--ink); }
.stepper .conn { flex: 1; height: 1px; background: var(--border); max-width: 80px; }
.stepper .conn.done { background: var(--green); }

/* ============================================================================
 * HERO ACTION
 * ========================================================================== */
.hero-action {
  background: linear-gradient(135deg, var(--dark) 0%, #1E293B 100%);
  color: white;
  border-radius: 12px;
  padding: 32px;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}
.hero-action::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 360px; height: 360px;
  background: radial-gradient(circle, rgba(234,52,70,0.15) 0%, transparent 65%);
  pointer-events: none;
}
.hero-eyebrow { color: var(--red); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 12px; position: relative; }
.hero-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 8px; max-width: 560px; position: relative; }
.hero-sub { color: rgba(255,255,255,0.65); font-size: 14px; max-width: 540px; margin-bottom: 24px; position: relative; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; position: relative; }
.btn-on-dark { background: rgba(255,255,255,0.08); color: white; border: 1px solid rgba(255,255,255,0.15); }
.btn-on-dark:hover { background: rgba(255,255,255,0.14); }

/* ============================================================================
 * FILE CARD
 * ========================================================================== */
.file-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: white; border: 1px solid var(--border); border-radius: 8px; }
.file-thumb {
  width: 40px; height: 48px;
  background: var(--green);
  color: white;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0; position: relative;
}
.file-thumb::after { content: ''; position: absolute; top: 0; right: 0; width: 12px; height: 12px; background: white; clip-path: polygon(0 100%, 100% 0, 100% 100%); }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-family: 'SF Mono', monospace; font-size: 13px; color: var(--ink); font-weight: 500; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info { font-size: 12px; color: var(--muted); }

/* ============================================================================
 * RESULT GRID
 * ========================================================================== */
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.result-card { padding: 20px; border-radius: 8px; border: 1px solid; }
.result-card.success { background: var(--green-50); border-color: #6EE7B7; }
.result-card.warning { background: var(--amber-50); border-color: #FCD34D; }
.result-card.danger  { background: var(--red-50); border-color: #FCA5A5; }
.result-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.result-card.success .result-label { color: var(--green-700); }
.result-card.warning .result-label { color: var(--amber-700); }
.result-card.danger  .result-label  { color: var(--red); }
.result-value { font-size: 32px; font-weight: 700; color: var(--dark); letter-spacing: -0.02em; line-height: 1; }
.result-desc { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ============================================================================
 * LOGIN PAGE
 * ========================================================================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand .logo {
  width: 56px; height: 56px;
  background: var(--red);
  border-radius: 12px;
  display: inline-flex;
  align-items: center; justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 20px;
  margin-bottom: 16px;
}
.login-brand h1 { font-size: 22px; font-weight: 600; color: var(--dark); margin-bottom: 4px; }
.login-brand .tag { color: var(--muted); font-size: 14px; }
.login-form .field { margin-bottom: 16px; }
.login-form .btn { width: 100%; justify-content: center; }
.login-foot { margin-top: 24px; text-align: center; font-size: 12px; color: var(--muted); }

/* ============================================================================
 * FILTERS
 * ========================================================================== */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.search-input { flex: 1; min-width: 200px; position: relative; }
.search-input input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: white; }
.search-input .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.filter-tag { padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: white; color: var(--muted); }
.filter-tag.active { background: var(--dark); color: white; border-color: var(--dark); }
.filter-tag .count { margin-left: 6px; background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 8px; font-size: 11px; }
.filter-tag.active .count { background: rgba(255,255,255,0.18); }

/* ============================================================================
 * EMPTY STATE
 * ========================================================================== */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state .ic {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  background: var(--bg-soft);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--light);
}
.empty-state h3 { font-size: 16px; color: var(--dark); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* ============================================================================
 * UTIL
 * ========================================================================== */
.text-muted { color: var(--muted); }
.text-danger { color: var(--red); }
.text-success { color: var(--green-700); }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .result-grid { grid-template-columns: 1fr; }
  .sidebar { width: 200px; }
}
