/* Admin & Analytics Styles */
:root {
  --bg-dark: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-alt: #111827;
  --accent: #ef4444;
  --accent-light: #f87171;
  --text-light: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --success: #22c55e;
  --warn: #fbbf24;
  --radius: 0.5rem;
  --transition: 0.2s ease;
}

/* Dark mode is default - explicitly set */
html,
body,
body.dark-mode {
  --bg-dark: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-alt: #111827;
  --text-light: #e2e8f0;
  --text-muted: #94a3b8;
}

/* Light mode override */
body.light-mode {
  --bg-dark: #f5f5f5;
  --bg-panel: #ffffff;
  --bg-panel-alt: #eeeeee;
  --text-light: #1a1a1a;
  --text-muted: #666;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-light);
  overflow: hidden;
}

.layout { display: flex; height: 100vh; }

/* sidebar */
.sidebar {
  width: 240px;
  background-color: var(--bg-dark);
  display: flex;
  flex-direction: column;
  padding-top: 1.5rem;
  transition: width var(--transition);
  border-right: 1px solid #1e293b;
  z-index: 10;
  overflow-y: auto;
}
.sidebar.collapsed { width: 80px; }
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: clamp(1.1rem, 2.5vw, 1.25rem);
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 2rem;
  padding: 0 1rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  text-decoration: none;
  color: var(--text-muted);
  border-left: 4px solid transparent;
  transition: all var(--transition);
  font-weight: 500;
  font-size: clamp(0.9rem, 2vw, 0.95rem);
}
.nav-link:hover,
.nav-link.active {
  background-color: var(--bg-panel);
  color: white;
  border-left-color: var(--accent);
}
.logout {
  margin-top: auto;
  margin-bottom: 1.5rem;
  color: var(--accent-light);
  cursor: pointer;
}
.sidebar.collapsed .text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s;
}
.icon {
  font-size: 1.25rem;
  min-width: 1.5rem;
  text-align: center;
}

/* main content */
.main-content {
  flex: 1;
  padding: clamp(1rem, 3vw, 1.5rem);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel-alt);
  overflow-y: auto;
}

.top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

#menuToggle {
  background: var(--bg-panel);
  color: white;
  border: none;
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#menuToggle:hover { background: #334155; }

.page-title {
  font-size: clamp(1.25rem, 4vw, 1.5rem);
  font-weight: 600;
  flex: 1;
}

.theme-btn {
  background: var(--bg-panel);
  color: white;
  border: none;
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: var(--radius);
  min-width: 44px;
  min-height: 44px;
}
.theme-btn:hover { background: #334155; }

/* tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--bg-panel);
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-btn:hover {
  color: var(--text-light);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-light);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-panel);
  color: var(--text-light);
  border: 1px solid #334155;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}

.form-group textarea {
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* buttons */
.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-panel);
  color: var(--text-light);
  border: 1px solid #334155;
}

.btn-secondary:hover {
  background: #334155;
}

/* modals */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-panel);
  padding: 2rem;
  border-radius: 0.75rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.close {
  float: right;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-muted);
  cursor: pointer;
}

.close:hover {
  color: var(--text-light);
}

/* lists */
.list-container {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.list-item {
  background: var(--bg-panel);
  padding: 1.25rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-item h4 {
  margin: 0;
  color: var(--text-light);
}

.list-item p {
  margin: 0.25rem 0 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.list-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  background: var(--bg-panel-alt);
  color: var(--text-light);
  border: 1px solid #334155;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-small:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-danger:hover {
  background: #dc2626;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-panel);
  padding: 1.5rem;
  border-radius: var(--radius);
  border-left: 5px solid var(--primary);
  text-align: center;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.kpi-unit {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-container {
  background: var(--bg-panel);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid #334155;
}

.chart-container h3 {
  margin-top: 0;
  color: var(--text-light);
}

/* tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-panel);
  border-radius: var(--radius);
  overflow: hidden;
}

thead {
  background: var(--bg-panel-alt);
}

th {
  padding: 1rem;
  text-align: left;
  color: var(--text-light);
  font-weight: 600;
  border-bottom: 2px solid #334155;
}

td {
  padding: 1rem;
  border-bottom: 1px solid #334155;
  color: var(--text-muted);
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.1);
}

/* settings */
.settings-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-panel);
  margin-bottom: 1rem;
  border-radius: var(--radius);
}

.settings-group label {
  margin: 0;
  cursor: pointer;
  font-weight: 500;
}

.settings-group input[type="checkbox"] {
  width: 1.5rem;
  height: 1.5rem;
  cursor: pointer;
}

/* responsive */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0.75rem;
    border-bottom: 1px solid #1e293b;
    border-right: none;
    overflow-x: auto;
  }
  .sidebar.collapsed { height: 60px; width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
}
