/* BusCity — основные стили (тема mareon: navy + gold, eGov KZ) */

:root {
  /* Цвета */
  --bg-primary: #f2f5f9;
  --bg-card: #ffffff;
  --bg-header: #16294c;
  --bg-header-2: #1d3563;
  --bg-sidebar: #0d1a33;
  --bg-input: #ffffff;
  --border: #e2e8f0;
  --border-focus: #1f5de0;

  --accent: #1f5de0;
  --accent-hover: #1848b8;
  --accent-light: #e8f0fe;
  --gold: #f5b830;
  --gold-hover: #d9a020;

  --danger: #d92d20;
  --danger-bg: #fef3f2;
  --warning: #dc6803;
  --warning-bg: #fffaeb;
  --success: #079455;
  --success-bg: #ecfdf3;
  --info: #0ea5e9;

  --text-primary: #1c2b41;
  --text-secondary: #5b6b82;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  --header-height: 56px;
  --nav-height: 48px;
  --sidebar-width: 240px;
}

/* Тёмная тема */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #0e1526;
    --bg-card: #16203a;
    --bg-input: #1a2744;
    --border: #2d3b55;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #4c85f5;
    --accent-light: #1a2744;
    --danger-bg: #2d1618;
    --warning-bg: #2d2210;
    --success-bg: #0d261a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
  }
}
:root[data-theme="dark"] {
  --bg-primary: #0e1526;
  --bg-card: #16203a;
  --bg-input: #1a2744;
  --border: #2d3b55;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #4c85f5;
  --accent-light: #1a2744;
  --danger-bg: #2d1618;
  --warning-bg: #2d2210;
  --success-bg: #0d261a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

/* Базовые стили */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
}

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

/* ─── Layout ──────────────────────────────────────── */

.utility-bar {
  background: var(--bg-sidebar);
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header {
  background: linear-gradient(135deg, var(--bg-header), var(--bg-header-2));
  border-bottom: 3px solid var(--gold);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-inverse);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-logo .logo-icon {
  font-size: 28px;
}

.header-logo .logo-sub {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.7;
  border-left: 1px solid rgba(255,255,255,0.3);
  padding-left: 10px;
  margin-left: 4px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions .btn-icon {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.2s;
}
.header-actions .btn-icon:hover {
  background: rgba(255,255,255,0.1);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-inverse);
  font-size: 13px;
}

.nav-strip {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  padding: 0 24px;
  gap: 4px;
  overflow-x: auto;
}

.nav-strip a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
}
.nav-strip a:hover {
  color: var(--accent);
  text-decoration: none;
}
.nav-strip a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.footer {
  background: var(--bg-header);
  color: rgba(255,255,255,0.6);
  padding: 32px 24px 16px;
  margin-top: 48px;
  font-size: 12px;
}
.footer-grid {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
}
.footer-bottom {
  max-width: 1400px;
  margin: 16px auto 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

/* ─── Components ──────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.kpi-card .kpi-icon {
  font-size: 28px;
  margin-bottom: 8px;
}
.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-card.danger { border-left: 4px solid var(--danger); }
.kpi-card.warning { border-left: 4px solid var(--warning); }
.kpi-card.success { border-left: 4px solid var(--success); }
.kpi-card.info { border-left: 4px solid var(--info); }
.kpi-card.gold { border-left: 4px solid var(--gold); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-gold {
  background: var(--gold);
  color: var(--bg-header);
}
.btn-gold:hover { background: var(--gold-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: var(--danger);
  color: white;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--accent-light); color: var(--accent); }

.table {
  width: 100%;
  border-collapse: collapse;
}
.table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table tbody tr:hover {
  background: var(--accent-light);
}

.input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-input);
  width: 100%;
  transition: border-color 0.2s;
}
.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(31,93,224,0.15);
}

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-primary) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Responsive ──────────────────────────────────── */

@media (max-width: 768px) {
  .utility-bar { display: none; }
  .header { padding: 0 12px; }
  .nav-strip { padding: 0 8px; }
  .nav-strip a { padding: 10px 12px; font-size: 12px; }
  .main-content { padding: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .header-user span { display: none; }
}

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

/* ─── Hero Banner ─────────────────────────────────── */

.hero {
  background: linear-gradient(135deg, var(--bg-header) 0%, var(--accent) 100%);
  border-radius: var(--radius-lg);
  padding: 32px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(245,184,48,0.15);
}
.hero h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
}
.hero p {
  opacity: 0.8;
  margin: 0;
  font-size: 14px;
}

/* ─── Hidden attribute override ─────────────────── */
[hidden] { display: none !important; }

/* ─── Login Page ──────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: linear-gradient(135deg, var(--bg-header) 0%, #0d1a33 100%);
}
.login-marketing {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  color: white;
}
.login-marketing h1 {
  font-size: 32px;
  margin: 0 0 16px;
  line-height: 1.2;
}
.login-form-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  border-top: 4px solid var(--gold);
  box-shadow: var(--shadow-lg);
}
.login-card h2 {
  margin: 0 0 24px;
  font-size: 22px;
  color: var(--text-primary);
}
.login-card .form-group {
  margin-bottom: 16px;
}
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .login-page { grid-template-columns: 1fr; }
  .login-marketing { display: none; }
}

/* ─── Map ─────────────────────────────────────────── */

.map-container {
  width: 100%;
  height: calc(100vh - var(--header-height) - var(--nav-height) - 48px);
  min-height: 500px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.bus-marker { background: none !important; border: none !important; }
.city-label { background: none !important; border: none !important; pointer-events: none; }

.map-legend {
  position: absolute; bottom: 30px; left: 10px; z-index: 1000;
  background: var(--bg-card); padding: 10px 14px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); font-size: 12px; color: var(--text-secondary);
  line-height: 1.8;
}
.map-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

/* ─── Events feed ─────────────────────────────────── */

.event-feed {
  max-height: 400px;
  overflow-y: auto;
}
.event-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.event-item:last-child { border-bottom: none; }
.event-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.event-icon.alarm { background: var(--danger-bg); }
.event-icon.apc { background: var(--success-bg); }
.event-icon.evasion { background: var(--warning-bg); }
.event-time {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

/* ─── Toast notifications ────────────────────────── */

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease-out;
  max-width: 360px;
}
.toast-info { background: var(--accent); }
.toast-warning { background: var(--warning); }
.toast-error { background: var(--danger); }
.toast-success { background: var(--success); }

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Chart container ────────────────────────────── */

#chart-hourly {
  min-height: 200px;
}

/* ─── Modal ──────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

/* ─── Detail grid ────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-item {
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}
.detail-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.detail-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Clickable row ──────────────────────────────── */

.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--accent-light); }

@media (max-width: 768px) {
  .modal-content { max-width: 100%; margin: 12px; }
  .detail-grid { grid-template-columns: 1fr; }
}
