/* ══════════════════════════════════════════════════════════════════════════════
   CCTV Desa Bantarsari — Stylesheet
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg-primary:   #0a1628;
  --bg-secondary: #111f36;
  --bg-card:      #152236;
  --bg-header:    #0d1b2e;
  --bg-input:     #1a2b44;
  --bg-modal:     rgba(6, 12, 24, 0.85);
  --accent:       #3a7bd5;
  --accent-glow:  rgba(58, 123, 213, 0.3);
  --accent-hover: #4a8be5;
  --success:      #2ecc71;
  --danger:       #e74c3c;
  --warning:      #f39c12;
  --text:         #e8ecf1;
  --text-muted:   #8899b3;
  --border:       #1e3250;
  --border-light: #2a3c5f;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --transition:   0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font:         'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text);
  padding: 0;
  min-height: 100vh;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ══════════════════════════════════════════════════════════════════════════════
   HEADER KOP SURAT
   ══════════════════════════════════════════════════════════════════════════════ */
.kop-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--bg-header) 0%, #0f2240 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
}

.kop-header img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.kop-text { text-align: center; }
.kop-text h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1.5px;
  background: linear-gradient(135deg, #fff 0%, #a8c8f8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kop-text p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ══════════════════════════════════════════════════════════════════════════════ */
.main-content {
  padding: 110px 20px 60px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════════════════════════
   TAB NAVIGATION
   ══════════════════════════════════════════════════════════════════════════════ */
.tab-container {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tab-btn {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 22px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  transition: all var(--transition);
  overflow: hidden;
}

.tab-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent) 0%, #5b4ae3 100%);
  opacity: 0;
  transition: opacity var(--transition);
}

.tab-btn span { position: relative; z-index: 1; }

.tab-btn:hover {
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.tab-btn.active {
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.tab-btn.active::before { opacity: 1; }

.tab-btn .lock-icon {
  margin-right: 4px;
  font-size: 12px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   CCTV GRID
   ══════════════════════════════════════════════════════════════════════════════ */
.cctv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.cam-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.cam-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 32px var(--accent-glow);
}

.cam-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  overflow: hidden;
}

.cam-thumb.checking { color: var(--warning); }
.cam-thumb.online   { color: var(--success); }
.cam-thumb.offline  { background: linear-gradient(135deg, #1a0505 0%, #2a0000 100%); color: var(--danger); }

/* Status badge */
.status-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.4);
}
.status-badge.online  { background: var(--success); box-shadow: 0 0 8px var(--success); animation: pulse 2s infinite; }
.status-badge.offline { background: var(--danger); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(46,204,113,0.3); }
  50%      { box-shadow: 0 0 12px 4px rgba(46,204,113,0.3); }
}

.cam-label {
  padding: 10px 14px;
  background: var(--bg-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════════════════════════════
   VIDEO MODAL
   ══════════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-modal);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.2s ease;
}
.modal-overlay.show { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: #0a0f1a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 95%;
  max-width: 1000px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 64px rgba(0,0,0,0.6);
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  cursor: move;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  transition: all var(--transition);
}
.modal-close:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.modal-body video {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  display: block;
}

.modal-body .error-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: contain;
  background: #111;
  display: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   LOGIN MODAL (overlay pada tab)
   ══════════════════════════════════════════════════════════════════════════════ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-modal);
  backdrop-filter: blur(16px);
}
.login-overlay.show { display: flex; }

.login-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-box h3 {
  text-align: center;
  margin: 0 0 6px;
  font-size: 22px;
  background: linear-gradient(135deg, #fff 0%, #a8c8f8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-box .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #5b4ae3 100%);
  color: #fff;
  width: 100%;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #c0392b;
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #27ae60;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.login-error {
  color: var(--danger);
  text-align: center;
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

.login-cancel {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
}
.login-cancel:hover { color: var(--text); }

/* ══════════════════════════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════════════════════════ */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  text-align: center;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--bg-header) 0%, #0f2240 100%);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.site-footer strong { color: var(--text); }

/* ══════════════════════════════════════════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════════════════════════════════════════ */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.admin-sidebar .logo-area {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.admin-sidebar .logo-area h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}
.admin-sidebar .logo-area p {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.admin-nav { flex: 1; padding: 0; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.admin-nav a:hover {
  background: var(--bg-card);
  color: var(--text);
}
.admin-nav a.active {
  background: var(--bg-card);
  color: var(--accent);
  border-left-color: var(--accent);
}

.admin-sidebar .sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.admin-main {
  margin-left: 240px;
  flex: 1;
  padding: 24px 32px;
  min-height: 100vh;
}

.admin-main h1 {
  font-size: 24px;
  margin: 0 0 8px;
}

.admin-main .page-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ── Admin Cards / Stats ──────────────────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.stat-icon.blue   { background: rgba(58,123,213,0.15); }
.stat-icon.green  { background: rgba(46,204,113,0.15); }
.stat-icon.orange { background: rgba(243,156,18,0.15); }
.stat-icon.red    { background: rgba(231,76,60,0.15); }

.stat-info h4 { margin: 0; font-size: 26px; }
.stat-info p  { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }

/* ── Admin Tables ──────────────────────────────────────────────────────────── */
.admin-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.admin-table-header h3 { margin: 0; font-size: 16px; }

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

.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table tr:hover td {
  background: rgba(58,123,213,0.05);
}

.admin-table .actions {
  display: flex;
  gap: 6px;
}

/* ── Status Pill ──────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 600;
}
.pill.running  { background: rgba(46,204,113,0.15); color: var(--success); }
.pill.stopped  { background: rgba(231,76,60,0.15); color: var(--danger); }
.pill.umum     { background: rgba(58,123,213,0.15); color: var(--accent); }
.pill.kantor   { background: rgba(243,156,18,0.15); color: var(--warning); }
.pill.bumdes   { background: rgba(155,89,182,0.15); color: #9b59b6; }

/* ── Admin Modal (forms) ──────────────────────────────────────────────────── */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-modal);
  backdrop-filter: blur(12px);
}
.admin-modal-overlay.show { display: flex; }

.admin-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

.admin-modal h3 {
  margin: 0 0 20px;
  font-size: 18px;
}

.admin-modal .btn-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ══════════════════════════════════════════════════════════════════════════════
   LOADING / EMPTY
   ══════════════════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.loading-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--accent); }

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

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .kop-header {
    flex-direction: column;
    padding: 12px 16px;
    gap: 8px;
  }
  .kop-header img { width: 56px; height: 56px; }
  .kop-text h2 { font-size: 18px; }
  .kop-text p  { font-size: 12px; }

  .main-content { padding: 160px 12px 56px; }

  .cctv-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .tab-btn { padding: 8px 14px; font-size: 12px; }

  .cam-card { border-radius: 8px; }
  .cam-card:hover { transform: none; }

  /* Admin mobile */
  .admin-sidebar {
    width: 100%;
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 200;
  }
  .admin-sidebar .logo-area { display: none; }
  .admin-sidebar .sidebar-footer { display: none; }
  .admin-nav {
    display: flex;
    justify-content: space-around;
    width: 100%;
  }
  .admin-nav a {
    flex-direction: column;
    padding: 10px;
    font-size: 10px;
    border-left: none;
    border-top: 3px solid transparent;
    gap: 4px;
  }
  .admin-nav a.active { border-top-color: var(--accent); border-left-color: transparent; }

  .admin-main {
    margin-left: 0;
    padding: 16px 12px 80px;
  }
}

@media (max-width: 480px) {
  .cctv-grid { grid-template-columns: 1fr; }
}

/* Sembunyikan tombol fullscreen bawaan browser pada video player (diganti custom) */
video::-webkit-media-controls-fullscreen-button {
  display: none !important;
}
