/* =====================================================================
   FALCOM SERVICE CENTER - STYLE
   Tema: Merah / Hitam / Putih, mobile-first responsive
   ===================================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  /* Brand colors */
  --brand-red:        #e30613;
  --brand-red-dark:   #b30410;
  --brand-red-deep:   #7a020a;
  --brand-red-light:  #ff4858;
  --brand-black:      #0e0e0e;
  --brand-charcoal:   #1a1a1a;
  --brand-graphite:   #232323;
  --brand-white:      #ffffff;

  /* Status palette */
  --st-received:       #6b7280;
  --st-confirm:        #f59e0b;
  --st-assigned:       #3b82f6;
  --st-in-progress:    #06b6d4;
  --st-awaiting:       #a855f7;
  --st-qc:             #14b8a6;
  --st-resolved:       #10b981;
  --st-shipping:       #8b5cf6;
  --st-completed:      #22c55e;
  --st-rejected:       #ef4444;
  --st-on-hold:        #94a3b8;

  /* UI */
  --bg-app:        #f4f5f7;
  --bg-card:       #ffffff;
  --bg-muted:      #f8f9fb;
  --border:        #e5e7eb;
  --border-strong: #d1d5db;
  --text-primary:  #111827;
  --text-secondary:#4b5563;
  --text-muted:    #9ca3af;

  --shadow-sm: 0 1px 2px rgba(15,17,21,.06);
  --shadow:    0 4px 12px rgba(15,17,21,.08);
  --shadow-lg: 0 12px 32px rgba(15,17,21,.12);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --sidebar-w: 240px;
  --header-h:  64px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-red); text-decoration: none; }
a:hover { color: var(--brand-red-dark); }

img { max-width: 100%; height: auto; }

/* ---------- Login Page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, var(--brand-red) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, var(--brand-red-dark) 0%, transparent 50%),
    linear-gradient(135deg, var(--brand-black) 0%, var(--brand-red-deep) 70%, var(--brand-black) 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,.4) 100%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: rgba(20,20,20,.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  color: var(--brand-white);
}

.login-logo {
  width: 88px; height: 88px;
  margin: 0 auto 24px;
  background: var(--brand-red);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 40px rgba(227,6,19,.6);
}

.login-logo svg { width: 44px; height: 44px; }

.login-card h1 {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: .5px;
}

.login-card .subtitle {
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,.7);
  margin-bottom: 28px;
}

.login-card .input-group { margin-bottom: 16px; }

.login-card input {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  padding: 14px 20px;
  color: var(--brand-white);
  font-size: 14px;
  transition: all .2s;
}

.login-card input::placeholder { color: rgba(255,255,255,.55); }
.login-card input:focus {
  outline: none;
  background: rgba(255,255,255,.12);
  border-color: var(--brand-red-light);
  box-shadow: 0 0 0 3px rgba(227,6,19,.2);
}

.login-card .btn-login {
  width: 100%;
  background: var(--brand-white);
  color: var(--brand-black);
  border: 0;
  border-radius: 999px;
  padding: 14px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  margin-top: 12px;
  transition: transform .15s;
}
.login-card .btn-login:hover { transform: translateY(-1px); }
.login-card .btn-login:active { transform: translateY(0); }

.login-error {
  background: rgba(239,68,68,.18);
  border: 1px solid rgba(239,68,68,.4);
  color: #fecaca;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.login-hint {
  margin-top: 24px;
  font-size: 11.5px;
  color: rgba(255,255,255,.5);
  text-align: center;
  line-height: 1.7;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--brand-black) 0%, var(--brand-charcoal) 100%);
  color: var(--brand-white);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

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

.sidebar-brand .logo-dot {
  width: 36px; height: 36px;
  background: var(--brand-red);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .5px;
}
.sidebar-brand .brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  display: block;
  font-weight: 400;
  margin-top: 2px;
}

.sidebar-nav { padding: 12px 8px; flex: 1; }

.nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.4);
  padding: 14px 14px 6px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,.78);
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: all .15s;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--brand-white);
}

.nav-item.active {
  background: linear-gradient(90deg, var(--brand-red) 0%, var(--brand-red-dark) 100%);
  color: var(--brand-white);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(227,6,19,.3);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-red);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: var(--brand-white);
  font-size: 14px;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,.55); text-transform: capitalize; }

.user-logout {
  background: rgba(255,255,255,.06);
  border: 0;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  color: rgba(255,255,255,.7);
  display: flex; align-items: center;
}
.user-logout:hover { background: var(--brand-red); color: white; }

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

.topbar {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-menu-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
  color: var(--text-primary);
}

.page-title { font-size: 18px; font-weight: 700; margin: 0; flex: 1; }

.topbar-search {
  position: relative;
  width: 260px;
}
.topbar-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px 9px 38px;
  font-size: 13px;
  background: var(--bg-muted);
}
.topbar-search svg {
  position: absolute;
  left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
}

.content { padding: 24px; flex: 1; }

/* ---------- Welcome Banner ---------- */
.welcome-banner {
  background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-dark) 100%);
  color: white;
  padding: 22px 26px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.welcome-banner::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,.15) 0%, transparent 70%);
  border-radius: 50%;
}
.welcome-banner h2 { margin: 0 0 4px; font-size: 13px; font-weight: 500; opacity: .9; }
.welcome-banner .name { font-size: 22px; font-weight: 800; }

/* ---------- Quick Banners (Top Stock / Most Item) ---------- */
.quick-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.quick-card {
  background: linear-gradient(135deg, var(--brand-black) 0%, var(--brand-charcoal) 100%);
  color: white;
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.quick-card.red-glow::before {
  content: '';
  position: absolute;
  bottom: -30px; right: -30px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, var(--brand-red) 0%, transparent 65%);
  opacity: .6;
}

.quick-card .quick-label {
  font-size: 11.5px;
  letter-spacing: .8px;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  margin-bottom: 6px;
  position: relative;
}
.quick-card .quick-value {
  font-size: 16px; font-weight: 700; position: relative;
}

/* ---------- KPI Status Grid ---------- */
.section-title {
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0 0 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--brand-red);
}

.kpi-card .kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--brand-black);
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-card .kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-card.accent-red { border-color: rgba(227,6,19,.2); background: linear-gradient(180deg,#fff 0%, #fff5f5 100%); }
.kpi-card.accent-red .kpi-value { color: var(--brand-red); }

/* ---------- Quick Actions ---------- */
.quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand-red);
  color: white;
  border-color: var(--brand-red);
}
.btn-primary:hover {
  background: var(--brand-red-dark);
  color: white;
  box-shadow: 0 4px 12px rgba(227,6,19,.3);
}

.btn-dark {
  background: var(--brand-black);
  color: white;
}
.btn-dark:hover { background: var(--brand-charcoal); color: white; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-muted);
  border-color: var(--brand-red);
  color: var(--brand-red);
}

.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 14px; }

.btn-block { display: flex; width: 100%; justify-content: center; }

.btn-icon {
  padding: 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex; align-items: center;
}
.btn-icon:hover { background: var(--bg-muted); color: var(--brand-red); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.card-body { padding: 20px; }

/* ---------- Table ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  text-align: left;
  padding: 12px 16px;
  color: var(--text-secondary);
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--bg-muted); }

.data-table .actions { white-space: nowrap; text-align: right; }

/* ---------- Status Badges ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: white;
  white-space: nowrap;
}
.status-received,      .status-diagnosing    { background: var(--st-received); }
.status-cust-confirm                         { background: var(--st-confirm); color: #1f1f1f; }
.status-spv-review                           { background: #d97706; color: #fff; }
.status-assigned                             { background: var(--st-assigned); }
.status-in-progress                          { background: var(--st-in-progress); }
.status-awaiting-parts                       { background: var(--st-awaiting); }
.status-qc                                   { background: var(--st-qc); }
.status-qc-failed                            { background: var(--st-rejected); }
.status-resolved                             { background: var(--st-resolved); }
.status-shipping                             { background: var(--st-shipping); }
.status-completed                            { background: var(--st-completed); }
.status-rejected                             { background: var(--st-rejected); }
.status-on-hold                              { background: var(--st-on-hold); }
.status-default                              { background: #6b7280; }

/* ---------- Service Order Card (mobile list) ---------- */
.so-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all .15s;
  cursor: pointer;
}
.so-card:hover {
  border-color: var(--brand-red);
  box-shadow: var(--shadow-sm);
}

.so-card-body { flex: 1; min-width: 0; }
.so-card-date { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.so-card-customer { font-size: 14px; font-weight: 700; }
.so-card-product { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; }
.so-card-actions { display: flex; gap: 6px; }

/* ---------- Forms ---------- */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.form-section-title {
  background: var(--brand-black);
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  margin: -20px -20px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.form-grid .full { grid-column: 1 / -1; }

.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--bg-card);
  transition: all .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(227,6,19,.12);
}

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { background-color: var(--bg-card); cursor: pointer; }

.form-help {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

/* ---------- Flash messages ---------- */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid;
}
.flash-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.flash-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty svg { width: 64px; height: 64px; opacity: .3; margin-bottom: 12px; }
.empty h4 { margin: 0 0 6px; color: var(--text-secondary); font-size: 16px; }
.empty p { margin: 0; font-size: 13px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; gap: 4px; justify-content: center; padding: 16px;
}
.pagination a, .pagination span {
  padding: 7px 12px; border-radius: 6px; font-size: 13px;
  border: 1px solid var(--border); color: var(--text-secondary);
}
.pagination a:hover { background: var(--bg-muted); }
.pagination .active { background: var(--brand-red); color: white; border-color: var(--brand-red); }

/* ---------- Mobile Bottom Nav ---------- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  z-index: 100;
  justify-content: space-around;
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.mobile-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 10px;
  text-decoration: none;
}
.mobile-nav a.active {
  color: var(--brand-red);
}
.mobile-nav a svg { width: 22px; height: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 200;
    transition: left .3s ease;
  }
  .sidebar.open { left: 0; }
  .topbar-menu-toggle { display: inline-flex; }
  .topbar-search { display: none; }
  .content { padding: 16px; padding-bottom: 80px; }
  .mobile-nav { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .quick-strip { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .welcome-banner { padding: 18px 20px; }
  .welcome-banner .name { font-size: 18px; }
  .kpi-card .kpi-value { font-size: 28px; }
  .quick-actions .btn { flex: 1; justify-content: center; }
  .topbar { padding: 0 14px; }
  .page-title { font-size: 16px; }
}

/* ---------- Helpers ---------- */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: 16px; }
.flex-row { display: flex; gap: 12px; align-items: center; }
.flex-grow { flex: 1; }

/* Sidebar mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
}
.sidebar-overlay.show { display: block; }
