/* IoT Paznic Dashboard – Bootstrap 5 theme */

:root {
  --sidebar-width: 240px;
  --topbar-height: 52px;
  --content-bg: #f1f5f9;
}

body {
  background: var(--content-bg);
  color: #1f2937;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Auth page ── */
#iot-auth-wrapper {
  min-height: 100vh;
  background: #1f2937;
}

/* ── Sidebar ── */
#iot-sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-shrink: 0;
  background: #0f172a;
  transition: transform 0.25s ease;
  z-index: 100;
}

/* Brand */
.sidebar-brand { border-bottom: 1px solid rgba(255,255,255,0.06); }

.sidebar-brand-icon {
  width: 38px;
  height: 38px;
  background: #3b82f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.sidebar-brand-name {
  color: #f1f5f9;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}

.sidebar-brand-sub {
  color: #64748b;
  font-size: 0.72rem;
  text-transform: capitalize;
  line-height: 1.2;
}

/* Nav label */
.sidebar-nav-label {
  color: #475569;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Nav links */
.sidebar-nav-link {
  color: #94a3b8;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
}

.sidebar-nav-link:hover {
  background: rgba(255,255,255,0.07);
  color: #e2e8f0;
}

.sidebar-nav-link.active {
  background: #3b82f6;
  color: #fff;
}

.sidebar-nav-link i {
  font-size: 1rem;
  width: 1.1rem;
  text-align: center;
}

/* User footer */
.sidebar-user { border-top: 1px solid rgba(255,255,255,0.06); }

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-name {
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  display: block;
}

.sidebar-user-name:hover { color: #fff; }

.sidebar-user-email {
  color: #64748b;
  font-size: 0.7rem;
  line-height: 1.3;
}

.sidebar-logout-btn {
  color: #64748b;
  font-size: 1.05rem;
  text-decoration: none;
  transition: color 0.15s;
  flex-shrink: 0;
}

.sidebar-logout-btn:hover { color: #f87171; }

/* ── Topbar ── */
#iot-topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1f2937;
}

.btn-logout { color: #6b7280; }
.btn-logout:hover { color: #dc2626; }

/* ── Layout ── */
#iot-wrapper {
  min-height: 100vh;
}

#iot-content {
  min-height: 100vh;
  background: var(--content-bg);
}

/* ── Main content text overrides (white bg context) ── */
main .text-light   { color: #1f2937 !important; }
main .text-muted   { color: #6b7280 !important; }
main .text-secondary { color: #4b5563 !important; }
main h5.text-light, main h6.text-light { color: #111827 !important; }
main .fw-semibold.text-light, main .fw-bold.text-light { color: #111827 !important; }

/* Keep code tags colored */
main code.text-light { color: #374151 !important; }
main code.text-info  { color: #0369a1 !important; }

/* ── Cards ── */
.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  color: #1f2937;
}

.card-header .text-light,
.card-header .fw-semibold {
  color: #1f2937 !important;
}

/* ── Tables ── */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: #374151;
  --bs-table-border-color: #e2e8f0;
  --bs-table-hover-bg: rgba(0,0,0,0.02);
  font-size: 0.875rem;
}

.table thead th {
  color: #6b7280;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
  background: #f8fafc;
  padding: 0.6rem 0.75rem;
}

/* ── Status badges ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-online   { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.status-offline  { background: #9ca3af; }
.status-idle     { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.status-updating { background: #3b82f6; box-shadow: 0 0 6px #3b82f688; }

.badge-online   { background: #dcfce7; color: #15803d; }
.badge-offline  { background: #f3f4f6; color: #6b7280; }
.badge-idle     { background: #dcfce7; color: #15803d; }
.badge-updating { background: #dbeafe; color: #1d4ed8; }

/* ── Form controls ── */
.form-control, .form-select {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #1f2937;
}

.form-control:focus, .form-select:focus {
  background: #ffffff;
  border-color: #3b82f6;
  color: #1f2937;
  box-shadow: 0 0 0 0.2rem rgba(59,130,246,0.15);
}

.form-control::placeholder { color: #9ca3af; }

/* ── Stats card ── */
.stat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59,130,246,0.1);
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1;
  color: #111827;
}

.stat-label {
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Progress bars ── */
.progress {
  background: #e2e8f0;
  height: 6px;
}

/* ── Modals ── */
.modal-content {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.modal-header {
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal-footer {
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal-title { color: #111827 !important; }
.modal-title.text-danger { color: #dc2626 !important; }

.modal .form-label { color: #374151 !important; }
.modal p.text-light { color: #374151 !important; }

.btn-close-white { filter: none !important; }

/* ── Alerts ── */
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #dc2626; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #b45309; }

.alert-info a    { color: #1e40af; }
.alert-success a { color: #166534; }
.alert-warning a { color: #92400e; }

/* ── Responsive sidebar ── */
@media (max-width: 991.98px) {
  #iot-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
  }
  #iot-sidebar.show {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }
  .sidebar-overlay.show { display: block; }
}

/* ── Wizard steps ── */
.wizard-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.wizard-step .text-light { color: #111827 !important; }
.wizard-step .text-muted { color: #6b7280 !important; }

.wizard-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.code-block {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  color: #a3e635;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Nav tabs on white content ── */
.nav-tabs {
  border-bottom: 2px solid #e2e8f0;
}

.nav-tabs .nav-link {
  color: #6b7280;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.nav-tabs .nav-link:hover { color: #374151; background: transparent; }
.nav-tabs .nav-link.active { color: #3b82f6; border-bottom-color: #3b82f6; background: transparent; font-weight: 600; }
.nav-tabs .nav-link.text-secondary { color: #9ca3af !important; }

/* ── Breadcrumb ── */
.breadcrumb-item a.text-secondary { color: #6b7280 !important; }
.breadcrumb-item.active { color: #374151; }

/* ── Inputs inside dark modals ── */
input[readonly].bg-dark { background: #f3f4f6 !important; color: #374151 !important; border-color: #d1d5db !important; }

/* ── Badge overrides in content ── */
main .badge.bg-secondary { background-color: #e5e7eb !important; color: #374151 !important; }
main .badge.bg-primary   { background-color: #dbeafe !important; color: #1d4ed8 !important; }

/* ── Auto-dismiss alerts (JS) ── */
.alert-auto-dismiss { transition: opacity 0.5s; }

/* ── Device info table (detail page) ── */
.device-info-table td {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  font-size: 0.875rem;
}
.device-info-table tr:last-child td { border-bottom: none; }
.device-info-table td:first-child {
  width: 140px;
  color: #6b7280;
  font-weight: 500;
  white-space: nowrap;
}
.device-info-table td:last-child { color: #1f2937; }
