/* CSS Variables for Material Design Theme */
:root {
  /* Colors - Deep Blue/Purple Theme */
  --primary-color: #6200ea;
  --primary-light: #9d46ff;
  --primary-dark: #0a00b6;
  --secondary-color: #03dac6;

  /* Backgrounds */
  --bg-body: #f4f6f8;
  /* Light Grey Blue */
  --bg-sidebar: #ffffff;
  --bg-header: #ffffff;
  --bg-card: #ffffff;

  /* Text */
  --text-primary: #1c1e21;
  --text-secondary: #6b7280;
  --text-light: #ffffff;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
}

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

body {
  font-family: 'Roboto', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
}

/* Layout Grid */
.app-container {
  display: flex;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  box-shadow: var(--shadow-md);
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-links {
  padding: 24px 16px;
  list-style: none;
  flex: 1;
}

.nav-item {
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  font-weight: 500;
}

.nav-link:hover {
  background-color: rgba(98, 0, 234, 0.04);
  color: var(--primary-color);
}

.nav-link.active {
  background-color: rgba(98, 0, 234, 0.1);
  color: var(--primary-color);
}

.nav-icon {
  margin-right: 12px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content.expanded {
  margin-left: 70px;
}

/* Header */
.top-header {
  height: var(--header-height);
  background: var(--bg-header);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

/* Content Area */
.content-wrapper {
  padding: 32px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Grid System */
.grid {
  display: grid;
  gap: 24px;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, 1fr);
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Status Indicators */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-success {
  background-color: #d1fae5;
  color: #065f46;
}

.status-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.status-error {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

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

  .main-content {
    margin-left: 0;
  }

  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--primary-color);
}

input:focus+.slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
  -webkit-transform: translateX(22px);
  transform: translateX(22px);
}

/* Modal Styles */
.modal-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: 1000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: white;
  padding: 32px;
  border-radius: 16px;
  width: 500px;
  max-width: 90%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-secondary {
  background: white;
  border: 1px solid #d1d5db;
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: #f9fafb;
}

/* Entry Animation Gates */
#entry-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.gate-left,
.gate-right {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: #ffffff;
  transition: transform 1s cubic-bezier(0.77, 0, 0.175, 1);
  z-index: 10;
}

.gate-left {
  left: 0;
  border-right: 1px solid #f3f4f6;
}

.gate-right {
  right: 0;
  border-left: 1px solid #f3f4f6;
}

.gate-loader {
  position: relative;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.gate-logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

  100% {
    transform: rotate(360deg);
  }
}

/* Open State */
#entry-overlay.open .gate-left {
  transform: translateX(-100%);
}

#entry-overlay.open .gate-right {
  transform: translateX(100%);
}

#entry-overlay.open .gate-loader {
  opacity: 0;
}

/* --- Mobile Sidebar Elements --- */

/* Desktop Collapsed State */
.sidebar {
  transition: width 0.3s ease;
}

.sidebar.collapsed {
  width: 70px;
}

.sidebar.collapsed .brand span,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .nav-link span {
  display: none;
}

.sidebar.collapsed .brand {
  justify-content: center;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 12px 0;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
  font-size: 1.25rem;
}

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 15;
  /* Below Sidebar (20) but above content */
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  display: block;
  /* Overridden by media query usually, but needed for JS logic */
}

/* Mobile Adjustments */
@media (max-width: 768px) {

  /* Show Toggle Button */
  #sidebar-toggle {
    display: block !important;
  }

  /* Adjust page structure */
  .app-container {
    flex-direction: column;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  /* Fixed Header on Mobile */
  .top-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0 16px;
    /* Smaller padding */
  }

  /* Sidebar Hidden by Default */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 280px;
    /* Slightly wider for touch */
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Show overlay when sidebar open */
  .sidebar-overlay.active {
    display: block;
  }

  /* Adjust Content Padding */
  .content-wrapper {
    padding: 16px;
  }

  .card {
    padding: 16px;
  }

  .card-value {
    font-size: 1.75rem;
  }
}