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

:root {
  /* LIGHT MODE VARIABLES */
  --bg-body: #f4f7f6;
  --bg-surface: #ffffff;
  --bg-sidebar: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  
  --primary: #06b6d4; /* Aqua Turkuaz */
  --primary-hover: #0891b2;
  --secondary: #3b82f6; /* Light Blue Accent */
  
  --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);
  --radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* DARK MODE VARIABLES */
  --bg-body: #0f172a;
  --bg-surface: #1e293b;
  --bg-sidebar: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  
  --primary: #06b6d4;
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  transition: var(--transition);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 50;
}

.logo-container {
  height: 70px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
}

.logo-container img {
  height: 32px;
  object-fit: contain;
}

.nav-links {
  list-style: none;
  padding: 20px 12px;
  flex: 1;
}

.nav-links li {
  margin-bottom: 8px;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  border-radius: var(--radius);
  transition: var(--transition);
}

.nav-links a:hover, .nav-links a.active {
  background-color: rgba(249, 115, 22, 0.1);
  color: var(--primary);
}

.nav-links a i {
  font-size: 1.2rem;
}

.sidebar-footer {
  padding: 24px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
  transition: var(--transition);
}

/* MAIN LAYOUT */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Important for flex child */
}

/* TOPBAR */
.topbar {
  height: 70px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  transition: var(--transition);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
}

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

/* THEME TOGGLE */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-switch {
  display: inline-block;
  height: 28px;
  position: relative;
  width: 50px;
}
.theme-switch input {
  display: none;
}
.slider {
  background-color: #ccc;
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: .4s;
  border-radius: 34px;
}
.slider:before {
  background-color: #fff;
  bottom: 4px;
  content: "";
  height: 20px;
  left: 4px;
  position: absolute;
  transition: .4s;
  width: 20px;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(22px);
}

/* CONTENT AREA */
.content-area {
  padding: 32px;
  overflow-y: auto;
  flex: 1;
}

.section {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

.section.active {
  display: block;
}

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

/* CARDS & TABLES */
.card {
  background-color: var(--bg-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

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

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  font-size: 0.95rem;
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background-color: rgba(0,0,0,0.02);
}
[data-theme="dark"] tbody tr:hover {
  background-color: rgba(255,255,255,0.02);
}

/* STATUS BADGES */
.badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-block;
}
.badge-success { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.badge-info { background: rgba(56, 189, 248, 0.1); color: #38bdf8; }

select.inline-select {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
}

/* BUTTONS */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    height: 100vh;
  }
  .sidebar.open {
    left: 0;
  }
  .hamburger {
    display: block;
  }
  .content-area {
    padding: 16px;
  }
}

/* COLLAPSIBLE ACCORDION FOR FORMS */
.collapsible-card {
  overflow: hidden;
  transition: border-color var(--transition);
}
.collapsible-card.active {
  border-color: var(--primary);
}
.collapsible-card.active .toggle-icon {
  transform: rotate(180deg);
  color: var(--primary) !important;
}
.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.collapsible-card.active .collapsible-content {
  max-height: 1200px; /* High enough to contain all form elements */
}

/* MODAL STYLES */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(15, 23, 42, 0.6); /* Glassmorphism blur overlay */
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.3s ease;
}

.modal.open {
  display: flex;
}

.modal-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal.open .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: color-mix(in srgb, var(--primary) 5%, transparent);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-main);
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.close-modal-btn:hover {
  color: #ef4444;
}

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
