/* ============================================================
   Blizen Data App – Modern Corporate Color Palette
   Primary: Crimson Red #C8102E
   Secondary: Dark Red  #A00D24
   Accent:  Soft Pink   #FFF5F6
   Background:  #F0F2F5
   Card:    #FFFFFF
   Text:    #2D3748 / #4A5568 / #718096
   ============================================================ */

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

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:       #C8102E;
  --red-dark:  #A00D24;
  --red-light: #FFF5F6;
  --red-mid:   #F8D7DA;
  --bg:        #F0F2F5;
  --card:      #FFFFFF;
  --border:    #E8ECF0;
  --text:      #2D3748;
  --text-mid:  #4A5568;
  --text-mute: #718096;
  --green:     #2D8A4E;
  --green-bg:  #F0FBF4;
  --yellow:    #B7791F;
  --yellow-bg: #FEFCBF;
  --sidebar-w: 240px;
  --nav-h:     64px;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  --transition: 0.18s ease;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

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

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  box-shadow: 3px 0 16px rgba(160,13,36,0.18);
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-logo .logo-title {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  line-height: 1;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.65);
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 16px 0;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 8px 24px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  color: rgba(255,255,255,0.80);
  font-weight: 500;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,0.10);
  color: #fff;
  border-left-color: rgba(255,255,255,0.4);
}

.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-left-color: #fff;
  font-weight: 700;
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 11.5px;
  color: rgba(255,255,255,0.45);
  text-align: center;
}

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

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--nav-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-badge {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid var(--red-mid);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
}

/* ── Page content ─────────────────────────────────────────── */
.page-content {
  padding: 32px;
  flex: 1;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

.page-header p {
  color: var(--text-mute);
  margin-top: 4px;
  font-size: 13.5px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FAFBFC;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.card-body {
  padding: 24px;
}

/* ── Stat cards ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.red    { background: var(--red-light); }
.stat-icon.green  { background: var(--green-bg); }
.stat-icon.blue   { background: #EBF8FF; }
.stat-icon.yellow { background: var(--yellow-bg); }
.stat-icon.gray   { background: #F0F2F5; }

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--red);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 500;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

table.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: #F7F8FA;
  border-bottom: 2px solid var(--red);
  white-space: nowrap;
}

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

table.data-table tr:last-child td { border-bottom: none; }

table.data-table tr:hover td { background: #FAFBFC; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok      { background: var(--green-bg); color: var(--green); }
.badge-error   { background: var(--red-light); color: var(--red); }
.badge-running { background: var(--yellow-bg); color: var(--yellow); }
.badge-active  { background: var(--green-bg); color: var(--green); }
.badge-inactive{ background: #F0F2F5; color: var(--text-mute); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}
.btn-primary:hover {
  background: var(--red-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(200,16,46,0.30);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red);
}
.btn-outline:hover {
  background: var(--red-light);
  color: var(--red-dark);
}

.btn-ghost {
  background: #F0F2F5;
  color: var(--text-mid);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: #E8ECF0; }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red-mid);
}
.btn-danger:hover { background: var(--red-light); }

.btn-sm { padding: 5px 12px; font-size: 12px; gap: 5px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  background: #FAFBFC;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--red);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(200,16,46,0.10);
}
.form-hint {
  font-size: 11.5px;
  color: var(--text-mute);
  margin-top: 5px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Flash messages ───────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 80px; right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.flash-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.25s ease;
}

.flash-success { background: var(--green-bg); color: var(--green); border-left: 4px solid var(--green); }
.flash-error   { background: var(--red-light); color: var(--red); border-left: 4px solid var(--red); }
.flash-info    { background: #EBF8FF; color: #2B6CB0; border-left: 4px solid #3182CE; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Toggle switch ────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }

.toggle {
  position: relative;
  width: 42px; height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #CBD5E0;
  border-radius: 24px;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--red); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-mute);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-mid); margin-bottom: 8px; }
.empty-state p { font-size: 13.5px; }

/* ── Dividers & helpers ───────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.text-red   { color: var(--red); }
.text-green { color: var(--green); }
.text-mute  { color: var(--text-mute); }
.text-right { text-align: right; }
.font-bold  { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

/* ── Sidebar Overlay ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 95;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  margin-right: 8px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px;
  }
  
  .sidebar.active {
    transform: translateX(0);
    box-shadow: 10px 0 30px rgba(0,0,0,0.3);
  }
  
  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }
  
  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }
  
  .topbar {
    padding: 0 16px;
    height: 56px;
  }
  
  .topbar-title {
    font-size: 14px;
    font-weight: 800;
  }
  
  .topbar-right span { display: none; }
  .topbar-right a { padding: 4px 10px; font-size: 11px; }
  
  .page-content {
    padding: 16px;
  }
  
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }
  
  .stat-card {
    padding: 12px;
    flex-direction: column;
    text-align: center;
    gap: 6px;
  }
  
  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-radius: 8px;
  }
  
  .stat-value {
    font-size: 16px;
  }
  
  .stat-label {
    font-size: 9px;
  }
  
  .grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .card-header {
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .card-header h2 { font-size: 13px; }
  .card-body { padding: 16px; }

  .flash-container {
    left: 12px;
    right: 12px;
    top: 64px;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
  
  .topbar-title {
    font-size: 13px;
  }
  
  .page-header h1 {
    font-size: 18px;
  }
  
  .btn-lg {
    width: 100%;
    justify-content: center;
  }
}

/* ── Progress Overlay ─────────────────────────────────────── */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(3px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.progress-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.progress-box {
  background: #fff;
  padding: 30px 40px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(200, 16, 46, 0.15);
  text-align: center;
  width: 90%;
  max-width: 400px;
  border: 1px solid var(--border);
}

.progress-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.progress-subtitle {
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 24px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 40%;
  background: var(--red);
  border-radius: 4px;
  animation: progress-indeterminate 1.5s infinite ease-in-out;
}

@keyframes progress-indeterminate {
  0% { left: -40%; }
  50% { left: 40%; width: 60%; }
  100% { left: 100%; width: 40%; }
}
