/* ═══════════════════════════════════════════════════════════
   becausewxcams Portal — Shared Styles
   Brand: Because Weather
   ═══════════════════════════════════════════════════════════ */

/* ── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;500;600;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Brand colours */
  --navy:        #233343;
  --dark-navy:   #1a2836;
  --blue:        #009fff;
  --gold:        #FBAE16;
  --light-gold:  #FDD890;

  /* Surface colours */
  --bg:           #0f1923;
  --surface:      #162030;
  --surface-raised:#1e2d3d;
  --border:       #253545;

  /* Text */
  --text-primary:  #e8f0f8;
  --text-secondary:#a0b4c8;
  --text-muted:    #607080;

  /* Status */
  --success: #22c55e;
  --danger:  #ef4444;
  --warning: #f59e0b;
  --info:    #38bdf8;

  /* Layout */
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --radius:        8px;
}

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

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

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  border-bottom: 1px solid var(--border);
}

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

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background: rgba(0,159,255,0.12);
  color: var(--blue);
  border-left: 2px solid var(--blue);
  margin-left: -2px;
  padding-left: 12px;
}

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

.sidebar-footer {
  margin-top: auto;
}

/* ── Main content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.topbar-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

/* ── Scrollable page area ──────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

/* ── Stat grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  line-height: 1;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

thead th {
  background: var(--surface-raised);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* Role-coloured left border on rows */
tbody tr[data-role="master"]    { border-left: 3px solid var(--gold); }
tbody tr[data-role="manager"]   { border-left: 3px solid var(--blue); }
tbody tr[data-role="developer"] { border-left: 3px solid #a78bfa; }
tbody tr[data-role="user"]      { border-left: 3px solid transparent; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: #007bd6; }

.btn-gold {
  background: var(--gold);
  color: #1a1a1a;
}
.btn-gold:hover { background: var(--light-gold); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(239,68,68,0.1); }

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 5px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-master    { background:rgba(251,174,22,0.15); color:var(--gold);    border:1px solid rgba(251,174,22,0.3); }
.badge-manager   { background:rgba(0,159,255,0.15);  color:var(--blue);    border:1px solid rgba(0,159,255,0.3); }
.badge-developer { background:rgba(139,92,246,0.15); color:#a78bfa;        border:1px solid rgba(139,92,246,0.3); }
.badge-user      { background:rgba(255,255,255,0.06);color:var(--text-muted);border:1px solid var(--border); }

.badge-active    { background:rgba(34,197,94,0.12);  color:var(--success); border:1px solid rgba(34,197,94,0.2); }
.badge-inactive  { background:rgba(239,68,68,0.1);   color:var(--danger);  border:1px solid rgba(239,68,68,0.2); }

/* ── Form elements ─────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  padding: 9px 12px;
  transition: border-color 0.15s ease;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,159,255,0.12);
}

input::placeholder { color: var(--text-muted); }

select option { background: var(--surface-raised); }

/* ── Modals ────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.active { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-box.modal-lg { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
}
.modal-close:hover { color: var(--text-primary); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Token display ─────────────────────────────────────────── */
.token-display {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
  line-height: 1.6;
}

/* ── Camera tile (activity feed style) ─────────────────────── */
.camera-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.camera-tile:last-child { border-bottom: none; }

.camera-thumb {
  width: 48px;
  height: 32px;
  background: var(--surface-raised);
  border-radius: 4px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Activity log ──────────────────────────────────────────── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  margin-top: 4px;
  flex-shrink: 0;
}

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Dual-panel camera assign ──────────────────────────────── */
.dual-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.panel {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.panel-header {
  background: var(--surface);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.panel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s ease;
  border-bottom: 1px solid var(--border);
}

.panel-item:last-child { border-bottom: none; }
.panel-item:hover { background: rgba(0,159,255,0.06); }

/* ── Scrollbar styling ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Loading skeleton ──────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-raised) 25%, var(--border) 50%, var(--surface-raised) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

/* ── Utilities ─────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-gold     { color: var(--gold); }
.text-blue     { color: var(--blue); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.mono          { font-family: 'Courier New', monospace; }
.truncate      { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Login page ────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0,159,255,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(251,174,22,0.04) 0%, transparent 50%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.login-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar becomes a slide-in drawer — width stays fixed, hidden via transform */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    height: 100%;
    width: var(--sidebar-width) !important;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    overflow-y: auto;
  }
  /* Main content fills full width on mobile */
  .main-content {
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dual-panel { grid-template-columns: 1fr; }
}