:root {
  --bg-color: #0f172a;
  --surface-color: rgba(30, 41, 59, 0.7);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --border-color: rgba(255, 255, 255, 0.1);
  --glass-blur: 12px;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --gradient-1: rgba(59, 130, 246, 0.15);
  --gradient-2: rgba(139, 92, 246, 0.15);
}

[data-theme="light"] {
  --bg-color: #f1f5f9;
  --surface-color: rgba(255, 255, 255, 0.85);
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border-color: rgba(0, 0, 0, 0.1);
  --gradient-1: rgba(37, 99, 235, 0.1);
  --gradient-2: rgba(124, 58, 237, 0.1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 15% 50%, var(--gradient-1), transparent 25%),
    radial-gradient(circle at 85% 30%, var(--gradient-2), transparent 25%);
  background-attachment: fixed;
  transition: background-color 0.3s, color 0.3s;
}

.glass-panel {
  background: var(--surface-color);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
  transition: background 0.3s, border-color 0.3s;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.header {
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-color);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(to right, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="light"] .header-title {
  background: linear-gradient(to right, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.card {
  padding: 2rem;
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(148, 163, 184, 0.3);
  transform: translateY(-4px);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* Theme Toggle Button */
#theme-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
#theme-toggle:hover {
  background: var(--surface-color);
}

/* Layout Utilities */
.app-layout {
  display: block;
}
.sidebar {
  width: 250px;
  padding: 1.5rem;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  background: #111827;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed {
  width: 80px;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-text {
  display: none;
}
.sidebar-logo-icon {
  display: none;
}
.sidebar.collapsed .sidebar-logo-full {
  display: none;
}
.sidebar.collapsed .sidebar-logo-icon {
  display: block;
}
.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  gap: 1rem;
  padding-right: 0 !important;
}
.sidebar.collapsed .sidebar-link-content {
  justify-content: center;
}
.sidebar.collapsed .sidebar-link {
  padding: 0.75rem;
}
.sidebar-toggle-btn {
  transition: transform 0.3s;
}
.sidebar.collapsed .sidebar-toggle-btn {
  transform: rotate(180deg);
}
[data-theme="light"] .sidebar {
  background: #1e293b; /* Dark sidebar even in light mode, as requested typically, or change if needed */
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}
.sidebar .sidebar-link {
  color: #cbd5e1;
}
.sidebar .sidebar-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.sidebar .sidebar-link.active {
  background: var(--primary) !important;
  color: #fff;
}

.main-area {
  flex-grow: 1;
  padding: 2rem;
  width: 100%;
}

/* Bottom Nav (Mobile Only) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--surface-color);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--border-color);
  z-index: 1000;
  justify-content: space-around;
  padding: 0.5rem 0;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
}
.bottom-nav-item {
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  padding: 0.5rem;
  border-radius: 8px;
  transition: var(--transition);
  cursor: pointer;
}
.bottom-nav-item.active {
  color: var(--primary);
}
.bottom-nav-item i {
  width: 1.2rem;
  height: 1.2rem;
}

/* More Menu Modal */
.more-menu-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s;
}
.more-menu-overlay.show {
  display: flex;
  opacity: 1;
  justify-content: center;
  align-items: flex-end;
}
.more-menu-content {
  background: var(--bg-color);
  width: 100%;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 2rem;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-top: 1px solid var(--border-color);
  max-height: 80vh;
  overflow-y: auto;
}
.more-menu-overlay.show .more-menu-content {
  transform: translateY(0);
}

/* Responsive Table */
.responsive-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.responsive-table th, .responsive-table td {
  padding: 1rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}
.responsive-table th {
  color: var(--text-muted);
  font-weight: 600;
}

/* Media Queries */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
    padding-bottom: 5rem; /* Space for bottom nav */
  }
  .header {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    display: none; /* Hide sidebar */
  }
  .bottom-nav {
    display: flex; /* Show bottom nav */
  }
  
  /* Cards Table */
  .responsive-table thead {
    display: none;
  }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tr {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface-color);
    padding: 1rem;
  }
  .responsive-table td {
    border-bottom: none;
    padding: 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  }
  .responsive-table td:last-child {
    border-bottom: none;
    margin-top: 0.5rem;
    justify-content: flex-end;
  }
  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 1rem;
  }
}

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

.animate-in {
  animation: fadeIn 0.6s ease-out forwards;
}

/* HTMX Transitions */
.htmx-indicator {
  opacity: 0;
  transition: opacity 0.3s ease-in;
}
.htmx-request .htmx-indicator {
  opacity: 1;
}
.htmx-request.htmx-indicator {
  opacity: 1;
}
