/* IoT Paznic Dashboard – Bootstrap 5 theme */

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

:root {
  --sidebar-width: 248px;
  --content-bg: #f8fafc;
  --btn-radius: 4px;
}

body {
  background: var(--content-bg);
  color: #0f172a;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
}

a { text-decoration: none; }
a:hover { text-decoration: none; }

/* ── Auth page ── */
body.login-page {
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 0, transparent 38%),
    radial-gradient(circle at bottom right, rgba(34, 211, 238, 0.12), transparent 0, transparent 34%),
    linear-gradient(135deg, #0f172a 0%, #132238 48%, #0b1220 100%);
  color: #e2e8f0;
}

#iot-auth-wrapper {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background: transparent;
}

body.login-page #iot-auth-wrapper::before,
body.login-page #iot-auth-wrapper::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(12px);
  opacity: 0.4;
  pointer-events: none;
}

body.login-page #iot-auth-wrapper::before {
  width: 220px;
  height: 220px;
  top: -70px;
  right: 10%;
  background: rgba(59, 130, 246, 0.2);
}

body.login-page #iot-auth-wrapper::after {
  width: 180px;
  height: 180px;
  bottom: -40px;
  left: 8%;
  background: rgba(14, 165, 233, 0.14);
}

.auth-page {
  position: relative;
  z-index: 1;
}

.auth-card {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 22px;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.26);
  backdrop-filter: blur(10px);
}

.auth-card-compact {
  max-width: 460px;
  margin: 0 auto;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-brand-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #2563eb 0%, #38bdf8 100%);
  color: #fff;
  font-size: 1.45rem;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.24);
}

.auth-form-wrap {
  height: 100%;
}

.auth-form-label {
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
}

.auth-input {
  border-radius: 14px;
  border: 1px solid #dbe3ef;
  background: #f8fbff;
  color: #0f172a;
  padding: 0.8rem 1rem;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

.auth-input:focus {
  background: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.15);
}

.auth-remember .form-check-input {
  margin-top: 0.15rem;
}

.auth-remember .form-check-label {
  color: #64748b;
}

.auth-submit-btn {
  border-radius: var(--btn-radius);
  padding: 0.8rem 1rem;
  font-weight: 600;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.26);
}

.auth-footer-note {
  color: rgba(226, 232, 240, 0.84);
  font-size: 0.88rem;
}

@media (max-width: 991.98px) {
  .auth-card {
    border-radius: 20px;
  }
}

/* ── Sidebar ── */
#iot-sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-shrink: 0;
  background: #0f172a;
  border-right: 1px solid rgba(255,255,255,0.07);
  transition: transform 0.25s ease;
  z-index: 100;
}

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

.sidebar-brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(180deg, #60c2ff 0%, #3b82f6 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.08rem;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

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

.sidebar-brand-sub {
  color: #8ea5bc;
  font-size: 0.71rem;
  text-transform: capitalize;
  line-height: 1.2;
}

/* Nav label */
.sidebar-nav-label {
  color: #88a0b9;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Nav links */
.sidebar-nav-link {
  color: #ebf2f9;
  padding: 0.58rem 0.75rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
}

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

.sidebar-nav-link.active {
  background: rgba(116, 193, 255, 0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 #7dd3fc;
}

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

.sidebar-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-tree-link {
  display: block;
  color: #a9c0d7;
  font-size: 0.77rem;
  line-height: 1.35;
  padding: 0.34rem 0.55rem;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

.sidebar-tree-link:hover {
  background: rgba(255,255,255,0.06);
  color: #ffffff;
}

.sidebar-tree-link.current {
  background: rgba(116, 193, 255, 0.18);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #7dd3fc;
}

.sidebar-subnav-link {
  color: #f8fafc;
  padding: 0.48rem 0.65rem 0.48rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 2px;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

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

.sidebar-subnav-link.active {
  background: rgba(116, 193, 255, 0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 #7dd3fc;
}

.sidebar-subnav-link i {
  font-size: 0.95rem;
  width: 1.1rem;
  text-align: center;
  color: #b9d7f2;
}

.sidebar-separator {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 0.8rem 1rem;
}

/* User footer */
.sidebar-user {
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(6, 15, 25, 0.16);
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(59,130,246,0.22);
  color: #8ec5ff;
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

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

.sidebar-user-email {
  color: #89a0b7;
  font-size: 0.68rem;
  line-height: 1.3;
}

.sidebar-logout-btn {
  color: #8ea5bc;
  font-size: 1rem;
  text-decoration: none;
  transition: color 0.15s;
  flex-shrink: 0;
}

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

@media (min-width: 992px) {
  body.context-nav-page .page-context-tabs {
    display: none !important;
  }
}

/* ── Mobile tab scroll with arrows ── */
.tab-scroll-wrapper {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #dee2e6;
}
.tab-scroll-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 4px 6px;
  color: #64748b;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.tab-scroll-btn:hover { color: #0f172a; }
.tab-scroll-list {
  flex: 1;
  display: flex !important;
  flex-wrap: nowrap !important;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  border-bottom: none !important;
  margin-bottom: 0 !important;
}
.tab-scroll-list::-webkit-scrollbar { display: none; }
.tab-scroll-list .nav-item { flex-shrink: 0; }
.tab-scroll-list .nav-link { white-space: nowrap; padding: 8px 12px; font-size: 13px; }


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

.topbar-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
}

.btn-logout { color: #94a3b8; }
.btn-logout:hover { color: #ef4444; }

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

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

/* ── Main content text overrides (light bg context) ── */
main .text-light   { color: #1e293b !important; }
main .text-muted   { color: #475569 !important; }
main .text-secondary { color: #475569 !important; }
main h5.text-light, main h6.text-light { color: #0f172a !important; }
main .fw-semibold.text-light, main .fw-bold.text-light { color: #0f172a !important; }

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

/* ── Page headings ── */
main h5, main h4 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
}

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

.card-header {
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  border-radius: 12px 12px 0 0 !important;
}

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

/* ── Tables ── */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: #334155;
  --bs-table-border-color: #f1f5f9;
  --bs-table-hover-bg: rgba(248,250,252,0.8);
  font-size: 0.875rem;
}

.table thead th {
  color: #64748b;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 0.6rem 0.75rem;
}

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

.status-online   { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.status-offline  { background: #94a3b8; }
.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: #f1f5f9; color: #64748b; }
.badge-idle     { background: #dcfce7; color: #15803d; }
.badge-updating { background: #dbeafe; color: #1d4ed8; }

/* ── Form controls ── */
.form-control, .form-select {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  border-radius: 8px;
}

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

.form-control::placeholder { color: #94a3b8; }

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

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: #0f172a;
}

.stat-label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

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

.progress-bar { border-radius: 999px; }

/* ── Modals ── */
.modal-content {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}

.modal-header {
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
}

.modal-footer {
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
  border-radius: 0 0 16px 16px;
}

.modal-title { color: #0f172a !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 { border-radius: 10px; }
.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: #92400e; }

.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.4);
    z-index: 99;
  }
  .sidebar-overlay.show { display: block; }
}

/* ── Bootstrap overrides for buttons ── */
.btn {
  border-radius: var(--btn-radius) !important;
  font-weight: 500;
}

.btn-group > .btn,
.btn-group-sm > .btn {
  border-radius: var(--btn-radius) !important;
}

.btn-primary {
  background: #3b82f6;
  border-color: #3b82f6;
}
.btn-primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.btn-info {
  background: #06b6d4;
  border-color: #06b6d4;
  color: #fff;
}
.btn-info:hover {
  background: #0891b2;
  border-color: #0891b2;
  color: #fff;
}

/* ── Nav tabs ── */
.nav-tabs {
  border-bottom: 1px solid #e2e8f0;
}

.nav-tabs .nav-link {
  color: #64748b;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.nav-tabs .nav-link:hover { color: #1e293b; 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: #94a3b8 !important; }

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

.wizard-step .text-light { color: #0f172a !important; }
.wizard-step .text-muted { color: #64748b !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;
}

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

/* ── 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; }
