/* ==========================================================================
   RYTAC Hunt Systems — Admin Dashboard Styles
   ========================================================================== */

:root {
  --bg-page: #f5f7f8;
  --bg-card: #ffffff;
  --border-card: #e7ecef;
  --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.04);

  --sidebar-width: 242px;
  --sidebar-bg: #032116;
  --accent-orange: #f5820d;
  --accent-orange-hover: #e27407;

  --text-primary: #111827;
  --text-secondary: #5c6672;
  --text-muted: #6b7280;

  --green-badge-bg: #e6f6eb;
  --green-badge-text: #15803d;
  --green-status: #169a3b;

  --insight-bg: #f1f9f3;
  --status-row-bg: #f9fbfa;

  --radius-card: 14px;
  --radius-sm: 8px;
}

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

html,
body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
}

/* ==========================================================================
   Layout Shell
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  position: relative;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background-color: var(--sidebar-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease, transform 0.25s ease;
  z-index: 30;
}

.sidebar.collapsed {
  width: 76px;
}

.sidebar.collapsed .brand-logo-img {
  width: 44px;
  object-fit: cover;
  object-position: left center;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-chevron {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 11px;
}

.sidebar-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.sidebar-bg-img {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 240px;
  object-fit: cover;
  object-position: center bottom;
  opacity: 0.9;
}

.sidebar-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    #021d13 0%,
    #032317 58%,
    rgba(3, 35, 23, 0.72) 78%,
    rgba(3, 35, 23, 0.12) 100%
  );
}

.sidebar-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 14px 24px;
  height: 100%;
}

.brand-logo {
  display: flex;
  align-items: center;
  padding: 4px 8px 18px;
  text-decoration: none;
}

.brand-logo-img {
  width: 182px;
  max-width: 100%;
  height: auto;
  display: block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.nav-item.active {
  background: var(--accent-orange);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(245, 130, 13, 0.35);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 19px;
  height: 19px;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-chevron {
  width: 14px;
  height: 14px;
  opacity: 0.75;
  flex-shrink: 0;
}

/* ==========================================================================
   Main Wrapper & Top Header
   ========================================================================== */

.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 26px;
  background-color: #ffffff;
  border-bottom: 1px solid #ebeff2;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #1f2937;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.menu-toggle:hover {
  background-color: #f3f4f6;
}

.menu-toggle svg {
  width: 21px;
  height: 21px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  position: relative;
  width: 320px;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #6b7280;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 38px;
  border: 1px solid #dfe5ea;
  border-radius: 10px;
  background-color: #f9fafb;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.search-box input::placeholder {
  color: #6b7280;
}

.search-box input:focus {
  border-color: var(--accent-orange);
  background-color: #ffffff;
}

.notif-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #1f2937;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.notif-btn:hover {
  background-color: #f3f4f6;
}

.notif-btn svg {
  width: 20px;
  height: 20px;
}

.notif-dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-orange);
  border: 1.5px solid #ffffff;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease;
}

.user-profile:hover {
  background-color: #f3f4f6;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: #112a20;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-avatar svg {
  width: 22px;
  height: 22px;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-role {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-org {
  font-size: 11px;
  color: var(--text-secondary);
}

.user-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Dashboard Main Grid
   ========================================================================== */

.dashboard-main {
  padding: 20px 26px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* KPI Row */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.kpi-icon-box {
  width: 54px;
  height: 54px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
}

.kpi-icon-box svg {
  width: 27px;
  height: 27px;
}

.kpi-green {
  background: linear-gradient(135deg, #42b552, #2e9a3d);
}

.kpi-blue {
  background: linear-gradient(135deg, #3b8ef3, #2471d8);
}

.kpi-orange {
  background: linear-gradient(135deg, #ff9214, #eb7400);
}

.kpi-purple {
  background: linear-gradient(135deg, #8b6ff8, #6c4be8);
}

.kpi-body {
  flex: 1;
  min-width: 0;
}

.kpi-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kpi-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background-color: var(--green-badge-bg);
  color: var(--green-badge-text);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* Generic Card */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-title-muted {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.card-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select-wrap {
  position: relative;
}

.pill-select {
  appearance: none;
  height: 32px;
  padding: 0 30px 0 12px;
  border: 1px solid #d5dde3;
  border-radius: 8px;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
}

.pill-select:focus {
  border-color: var(--accent-orange);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #374151;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.icon-btn:hover {
  background-color: #f3f4f6;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

/* ==========================================================================
   Middle Row: Map + Trend Chart
   ========================================================================== */

.mid-grid {
  display: grid;
  grid-template-columns: 1.48fr 1fr;
  gap: 16px;
}

.map-viewport {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background-color: #092616;
  height: 266px;
}

.map-base-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;
  display: block;
  transition: filter 0.25s ease;
}

.map-viewport.dim-heatmap .map-base-img {
  filter: saturate(0.7) contrast(0.95);
}

.stand-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stand-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f5820d;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.map-legend-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  bottom: 10px;
  width: 205px;
  padding: 14px 14px 12px;
  border-radius: 10px;
  background: rgba(6, 30, 18, 0.9);
  backdrop-filter: blur(8px);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.94);
  cursor: pointer;
  user-select: none;
}

.legend-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.check-box {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.legend-check input:checked + .check-box {
  background-color: var(--accent-orange);
  border-color: var(--accent-orange);
}

.legend-check input:checked + .check-box::after {
  content: '';
  width: 9px;
  height: 5px;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.activity-scale {
  margin-top: auto;
  padding-top: 6px;
}

.scale-title {
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.95);
}

.scale-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a 0%, #eab308 50%, #ef4444 100%);
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 4px;
}

/* Trend Chart Card */
.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

.swatch-green {
  background-color: #269128;
}

.swatch-orange {
  background-color: #f5820d;
}

.chart-container {
  position: relative;
  flex: 1;
  min-height: 215px;
}

.trend-chart-svg {
  width: 100%;
  height: 222px;
  display: block;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: #111827;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 11.5px;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  white-space: nowrap;
  z-index: 10;
}

/* ==========================================================================
   Bottom Row: Cameras, AI Insights, System Status
   ========================================================================== */

.bottom-grid {
  display: grid;
  grid-template-columns: 1.38fr 1.15fr 0.85fr;
  gap: 16px;
}

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: #169038;
  text-decoration: none;
}

.view-all-link:hover {
  text-decoration: underline;
}

.view-all-link svg {
  width: 14px;
  height: 14px;
}

.camera-thumbs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.camera-item {
  display: flex;
  flex-direction: column;
}

.camera-thumb-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background-color: #111827;
}

.camera-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.camera-thumb-wrap:hover .camera-thumb-img {
  transform: scale(1.03);
}

.thumb-expand-btn {
  position: absolute;
  left: 7px;
  bottom: 7px;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.thumb-expand-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.thumb-expand-btn svg {
  width: 13px;
  height: 13px;
}

.camera-meta {
  margin-top: 8px;
}

.camera-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22a343;
  flex-shrink: 0;
}

.camera-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.camera-time {
  display: block;
  margin-top: 2px;
  padding-left: 14px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* AI Insights */
.title-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sparkle-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-orange);
  flex-shrink: 0;
}

.gear-icon {
  width: 20px;
  height: 20px;
  color: #209e40;
  flex-shrink: 0;
}

.insights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: 9px;
  background-color: var(--insight-bg);
}

.insight-icon {
  width: 20px;
  height: 20px;
  color: #169038;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.insight-icon svg {
  width: 19px;
  height: 19px;
}

.insight-text {
  font-size: 12.5px;
  line-height: 1.4;
  color: #1f2937;
  font-weight: 500;
}

/* System Status */
.status-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background-color: var(--status-row-bg);
}

.status-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background-color: #189b3c;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-check svg {
  width: 12px;
  height: 12px;
}

.status-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 500;
  color: #1f2937;
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--green-status);
}

/* ==========================================================================
   Modal Lightbox
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  background: #ffffff;
  border-radius: 14px;
  max-width: 780px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: #4b5563;
  cursor: pointer;
}

.modal-body {
  padding: 14px;
  background: #0b1410;
  display: flex;
  justify-content: center;
}

.modal-body img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  object-fit: contain;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1240px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mid-grid {
    grid-template-columns: 1fr;
  }

  .bottom-grid {
    grid-template-columns: 1fr 1fr;
  }

  .status-card {
    grid-column: span 2;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .top-header {
    padding: 12px 16px;
  }

  .search-box {
    display: none;
  }

  .dashboard-main {
    padding: 16px;
  }

  .kpi-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .status-card {
    grid-column: span 1;
  }
}
