/* ══════════════════════════════════════════════
   Dashboard Admin — Diagnosa Mio M3
   Premium Dark Theme
   ══════════════════════════════════════════════ */

:root {
  --blue-50: #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-400: #60A5FA;
  --blue-500: #3B82F6;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;
  --blue-900: #1E3A8A;

  --bg-base: #0A0F1E;
  --bg-surface: #111827;
  --bg-card: #1A2236;
  --bg-card-hover: #1E2A42;
  --bg-input: #0D1525;
  --sidebar-bg: #070D1A;

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #475569;

  --border: #1E2D4A;
  --border-light: #243354;

  --success: #10B981;
  --success-bg: #064E3B20;
  --warning: #F59E0B;
  --warning-bg: #78350F20;
  --danger: #EF4444;
  --danger-bg: #7F1D1D20;
  --purple: #8B5CF6;
  --purple-bg: #4C1D9520;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 24px rgba(59,130,246,0.2);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition: 0.2s ease;
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ───── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-600); }

/* ═══════════════════════════════════════════════════ LOGIN */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: radial-gradient(ellipse at 30% 30%, #1e3a8a30 0%, transparent 60%),
              radial-gradient(ellipse at 70% 70%, #7c3aed20 0%, transparent 60%),
              var(--bg-base);
}

.login-bg-shapes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  animation: floatShape 8s ease-in-out infinite alternate;
}
.shape-1 { width: 400px; height: 400px; background: var(--blue-700); top: -100px; left: -100px; }
.shape-2 { width: 300px; height: 300px; background: #6d28d9; bottom: -80px; right: -80px; animation-delay: 3s; }
.shape-3 { width: 200px; height: 200px; background: var(--blue-500); top: 50%; left: 50%; animation-delay: 5s; }

@keyframes floatShape {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(-30px) scale(1.05); }
}

.login-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 400px;
  padding: 40px;
  border-radius: var(--radius-xl);
  animation: fadeInUp 0.5s ease forwards;
}

.glass {
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 130, 246, 0.15);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.login-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.login-header p { font-size: 0.875rem; color: var(--text-secondary); margin-top: 4px; }
.login-hint { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-top: 16px; }
.login-hint code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; color: var(--blue-400); }

/* ─── Forms ──────────────────────────────────────── */
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); letter-spacing: 0.05em; text-transform: uppercase; }
.input-wrapper { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 12px; font-size: 0.9rem; pointer-events: none; }
.input-wrapper input { width: 100%; padding: 12px 12px 12px 38px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.9rem; font-family: 'Inter', sans-serif; outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.input-wrapper input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.input-wrapper input::placeholder { color: var(--text-muted); }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm); font-size: 0.875rem;
  font-weight: 600; font-family: 'Inter', sans-serif; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--blue-600), var(--blue-700)); color: #fff; box-shadow: 0 4px 16px rgba(37,99,235,0.35); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--blue-500), var(--blue-600)); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.5); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff; }
.btn-danger:hover:not(:disabled) { background: linear-gradient(135deg, #ef4444, #dc2626); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.btn-full { width: 100%; padding: 14px; font-size: 0.95rem; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-icon { padding: 8px; border-radius: 8px; background: transparent; border: none; cursor: pointer; font-size: 1rem; transition: background var(--transition); }
.btn-icon:hover { background: var(--bg-card-hover); }

.btn-loader { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ─── Alerts ─────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 16px; border-left: 4px solid; }
.alert-error { background: var(--danger-bg); border-color: var(--danger); color: #fca5a5; }
.alert-success { background: var(--success-bg); border-color: var(--success); color: #6ee7b7; }

/* ═══════════════════════════════════════════════════ DASHBOARD LAYOUT */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 16px 16px; border-bottom: 1px solid var(--border); }
.brand-name { font-weight: 700; font-size: 0.9rem; color: var(--text-primary); }
.brand-sub { font-size: 0.7rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 16px 8px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500;
  transition: all var(--transition); position: relative;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: linear-gradient(90deg, #1e3a8a40, #1e3a8a10); color: var(--blue-400); border-left: 3px solid var(--blue-500); padding-left: 9px; }
.nav-icon { font-size: 1.05rem; width: 22px; text-align: center; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--blue-600), var(--blue-900)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0; }
.user-name { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }
.btn-logout { background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; cursor: pointer; color: var(--danger); font-size: 1rem; transition: all var(--transition); }
.btn-logout:hover { background: var(--danger-bg); border-color: var(--danger); }

/* ─── Main Content ───────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: rgba(10, 15, 30, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.sidebar-toggle { display: none; background: none; border: none; color: var(--text-secondary); font-size: 1.2rem; cursor: pointer; padding: 4px; }
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--text-primary); flex: 1; }
.api-status { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-secondary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); animation: none; }
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); animation: pulse 2s ease-in-out infinite; }
.status-dot.offline { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Toast ──────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: var(--radius-md);
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem; font-weight: 500;
  animation: slideInRight 0.3s ease;
}

/* ─── Pages ──────────────────────────────────────── */
.page { padding: 24px; display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 1.3rem; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 0.875rem; margin-top: 2px; }

/* ─── Stats Grid ─────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; display: flex; align-items: center; gap: 16px;
  transition: all var(--transition); cursor: default;
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-blue { background: #1e3a8a25; border: 1px solid #1e3a8a60; }
.stat-orange { background: #78350f25; border: 1px solid #78350f60; }
.stat-purple { background: #4c1d9525; border: 1px solid #4c1d9560; }
.stat-green { background: #064e3b25; border: 1px solid #064e3b60; }
.stat-val { font-size: 1.8rem; font-weight: 800; color: var(--text-primary); }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; }

/* ─── Section Grid ───────────────────────────────── */
.section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .section-grid { grid-template-columns: 1fr; } }

/* ─── Cards ──────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
.card-header h3 { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

/* ─── Tables ─────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table thead tr { background: rgba(0,0,0,0.3); }
.data-table th { padding: 12px 16px; text-align: left; font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.empty-row { text-align: center; color: var(--text-muted); padding: 32px !important; }

/* ─── Search & Count ─────────────────────────────── */
.search-input {
  padding: 8px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-family: 'Inter', sans-serif;
  font-size: 0.85rem; outline: none; transition: border-color var(--transition); width: 250px;
}
.search-input:focus { border-color: var(--blue-500); }
.count-badge { font-size: 0.78rem; color: var(--text-muted); background: var(--bg-input); padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border); }

/* ─── CF Badge ───────────────────────────────────── */
.cf-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 700;
}
.cf-high { background: #064e3b30; color: #34d399; border: 1px solid #064e3b60; }
.cf-mid  { background: #1e3a8a30; color: #60a5fa; border: 1px solid #1e3a8a60; }
.cf-low  { background: #78350f30; color: #fbbf24; border: 1px solid #78350f60; }

.kode-badge { background: var(--blue-900); color: var(--blue-400); padding: 3px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; font-family: monospace; }

/* ─── Jasa Badge (kategori jasa servis) ──────────── */
.jasa-badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700;
  text-transform: capitalize;
}
.jasa-ringan { background: var(--success-bg); color: #34d399; border: 1px solid #064e3b60; }
.jasa-sedang { background: var(--warning-bg); color: #fbbf24; border: 1px solid #78350f60; }
.jasa-berat  { background: var(--danger-bg); color: #f87171; border: 1px solid #7f1d1d60; }

/* ─── Chart ──────────────────────────────────────── */
#chart-container { padding: 16px; max-height: 260px; display: flex; align-items: center; justify-content: center; }
#kerusakan-chart { max-height: 230px; }
.chart-empty { color: var(--text-muted); font-size: 0.85rem; text-align: center; padding: 32px; }

/* ─── Modals ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 520px; max-height: 90vh;
  border-radius: var(--radius-xl); overflow: hidden;
  display: flex; flex-direction: column;
  animation: fadeInUp 0.25s ease;
}
.modal-sm { max-width: 380px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 4px; border-radius: 6px; transition: all var(--transition); }
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--border); }

.modal-form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.875rem; font-family: 'Inter', sans-serif; outline: none;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ─── Landing Page ───────────────────────────────── */
.landing-card { max-width: 440px; }
.landing-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.landing-btn { justify-content: flex-start; text-align: left; padding: 16px 18px; height: auto; gap: 14px; }
.landing-btn-icon { font-size: 1.6rem; flex-shrink: 0; line-height: 1; }
.landing-btn-content { display: flex; flex-direction: column; gap: 2px; }
.landing-btn-title { font-size: 0.95rem; font-weight: 700; }
.landing-btn-sub { font-size: 0.75rem; font-weight: 400; opacity: 0.75; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 0.8rem;
  font-family: 'Inter', sans-serif; padding: 0; margin-bottom: 16px;
  transition: color var(--transition);
}
.back-link:hover { color: var(--text-primary); }

/* ─── Utilities ──────────────────────────────────── */
.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .search-input { width: 160px; }
  .page { padding: 16px; }
}
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }
