@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Dark Theme (default) ── */
:root {
  --bg-color: #0f1115;
  --panel-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.05);
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #ef4444;
  --success: #10b981;
  --sidebar-bg: rgba(15, 17, 21, 0.8);
  --topbar-bg: rgba(15, 17, 21, 0.9);
  --input-bg: rgba(0, 0, 0, 0.2);
  --log-bg: #09090b;
  --log-text: #a7f3d0;
  --table-header-bg: rgba(0, 0, 0, 0.4);
  --table-row-hover: rgba(255, 255, 255, 0.02);
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg-color: #f1f5f9;
  --panel-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(0, 0, 0, 0.08);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #dc2626;
  --success: #059669;
  --sidebar-bg: rgba(255, 255, 255, 0.85);
  --topbar-bg: rgba(241, 245, 249, 0.95);
  --input-bg: rgba(0, 0, 0, 0.04);
  --log-bg: #ffffff;
  --log-text: #065f46;
  --table-header-bg: rgba(0, 0, 0, 0.03);
  --table-row-hover: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .logo {
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="light"] h1 {
  color: var(--text-main);
}
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="date"],
[data-theme="light"] input[type="datetime-local"],
[data-theme="light"] select {
  color: var(--text-main);
  background: var(--input-bg);
  border-color: var(--glass-border);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Sidebar */
#sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--glass-border);
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.sidebar-hidden #sidebar {
  transform: translateX(-100%);
  position: absolute;
  height: 100%;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: #fff;
  text-align: center;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-link {
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-link:hover {
  background: var(--panel-bg);
  color: var(--text-main);
  transform: translateX(4px);
}

.nav-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Main Content */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
  transition: margin-left 0.3s ease;
}

/* Top Bar (Hamburger + Theme Toggle) */
.topbar {
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 90;
}

#hamburger {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: none;
}
#hamburger:hover {
  background: rgba(255,255,255,0.1);
  transform: none;
}
#hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background-color: currentColor;
  transition: 0.3s;
}

/* Theme Toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  border-radius: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: none;
  transition: all 0.2s ease;
}
.theme-toggle:hover {
  background: var(--panel-bg);
  transform: none;
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
}

/* Pages */
.page {
  display: none;
  padding: 1.5rem 2.5rem;
  animation: fadeIn 0.4s ease forwards;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.page.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px);
}

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

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: #fff;
  flex-shrink: 0;
}

/* Glass Panels */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease, border-color 0.3s ease;
}
.panel.log-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

input[type="text"], input[type="password"], input[type="date"], input[type="datetime-local"], select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 0.5rem;
  color: inherit;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2394a3b8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem top 50%;
  background-size: 0.65rem auto;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.radio-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-main);
  padding: 0.5rem 1rem;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 2rem;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.radio-label:hover {
  background: rgba(255,255,255,0.05);
}

.radio-label.selected {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

input[type="radio"] {
  display: none;
}
.radio-custom {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  display: inline-block;
  position: relative;
  transition: all 0.2s ease;
}
input[type="radio"]:checked + .radio-custom {
  border-color: var(--primary);
}
input[type="radio"]:checked + .radio-custom::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

/* Time range preset buttons */
.time-presets {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.time-preset-btn {
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--input-bg);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  box-shadow: none;
  transition: all 0.2s ease;
}
.time-preset-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
  transform: none;
}
.time-preset-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Custom range section */
.custom-range-section {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  border-top: 1px solid var(--glass-border);
}

/* Log output — fills remaining space */
.log-output {
  background: var(--log-bg);
  color: var(--log-text);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  padding: 1.5rem;
  border-radius: 0.5rem;
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  white-space: pre-wrap;
  font-size: 0.875rem;
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Tables */
.table-container {
  overflow-x: auto;
  background: var(--input-bg);
  border-radius: 0.5rem;
  border: 1px solid var(--glass-border);
}
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 1rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--table-header-bg);
}

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

tr:hover td {
  background: var(--table-row-hover);
}

/* Login Overlay */
#login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#login-overlay.hidden {
  display: none;
}

.login-box {
  width: 100%;
  max-width: 420px;
}
.login-box .logo {
  font-size: 1.5rem;
}

.loader {
  border: 2px solid rgba(255,255,255,0.1);
  border-top: 2px solid #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* Notification */
.notification {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  background: var(--danger);
  color: white;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2000;
}
.notification.show {
  transform: translateY(0);
  opacity: 1;
}
.notification.success {
  background: var(--success);
}

.flex-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}
.flex-1 { flex: 1; }
