/* Base Styles */
:root {
  /* Light Theme */
  --primary: #3B82F6;
  --primary-light: #60A5FA;
  --primary-dark: #2563EB;
  --secondary: #14B8A6;
  --accent: #F97316;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  
  --background: #F9FAFB;
  --surface: #FFFFFF;
  --text-primary: #1F2937;
  --text-secondary: #4B5563;
  --text-tertiary: #9CA3AF;
  --border: #E5E7EB;
  --divider: #F3F4F6;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --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);
  
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 80px;
  --header-height: 64px;
  
  --transition-speed: 0.3s;
}

/* Dark Theme */
[data-theme="dark"] {
  --primary: #60A5FA;
  --primary-light: #93C5FD;
  --primary-dark: #3B82F6;
  --secondary: #2DD4BF;
  --accent: #FB923C;
  --success: #4ADE80;
  --warning: #FBBF24;
  --danger: #F87171;
  
  --background: #111827;
  --surface: #1F2937;
  --text-primary: #F9FAFB;
  --text-secondary: #E5E7EB;
  --text-tertiary: #9CA3AF;
  --border: #374151;
  --divider: #1F2937;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.26);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.26);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
}

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

html {
  font-size: 16px;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  transition: background-color var(--transition-speed) ease;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('https://images.pexels.com/photos/370799/pexels-photo-370799.jpeg?auto=compress&cs=tinysrgb&w=1600');
  background-size: cover;
  background-position: center;
  opacity: 0.03;
  z-index: -1;
  transition: opacity var(--transition-speed) ease;
}

[data-theme="dark"] body::before {
  opacity: 0.05;
  background-image: url('https://images.pexels.com/photos/956999/milky-way-starry-sky-night-sky-star-956999.jpeg?auto=compress&cs=tinysrgb&w=1600');
}

/* Container */
.container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--surface);
  box-shadow: var(--shadow);
  height: 100vh;
  position: fixed;
  z-index: 100;
  transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--divider);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  color: var(--primary);
  font-size: 1.25rem;
}

.logo i {
  font-size: 1.5rem;
}

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.2s ease;
  padding: 8px;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.sidebar-toggle:hover {
  color: var(--primary);
  background-color: var(--divider);
  transform: scale(1.1);
}

.sidebar-toggle:active {
  transform: scale(0.95);
}

.sidebar-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background-color: rgba(59, 130, 246, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.sidebar-toggle:active::after {
  width: 100px;
  height: 100px;
}

.user-info {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
}

.user-avatar {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
}

.user-details {
  overflow: hidden;
}

.user-details h3 {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details span {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav li {
  margin-bottom: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  border-radius: 8px;
  margin: 0 8px;
  position: relative;
  overflow: hidden;
}

.sidebar-nav a:hover {
  background-color: var(--divider);
  color: var(--text-primary);
  transform: translateX(4px);
}

.sidebar-nav a:active {
  transform: translateX(2px) scale(0.98);
}

.sidebar-nav li.active a {
  background-color: var(--primary-dark);
  color: white;
}

.sidebar-nav a::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.sidebar-nav a:active::after {
  width: 200px;
  height: 200px;
}

.sidebar-nav i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
  transition: margin-left var(--transition-speed) ease;
}

body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
}

.main-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-welcome {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.btn i {
  font-size: 1rem;
}

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

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.btn:active::after {
  width: 200px;
  height: 200px;
}

.btn span, .btn i {
  position: relative;
  z-index: 1;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background-color: var(--divider);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background-color: var(--border);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background-color: #DC2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background-color: var(--divider);
  color: var(--text-primary);
  border-color: var(--primary);
}

/* Theme Toggle */
.theme-toggle {
  position: relative;
  width: 100%;
}

.theme-switch {
  opacity: 0;
  position: absolute;
}

.theme-switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px;
  border-radius: 50px;
  position: relative;
  background-color: var(--divider);
  height: 26px;
  width: 50px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-switch-label:hover {
  transform: scale(1.05);
}

.theme-switch-label:active {
  transform: scale(0.95);
}

.theme-switch-label .ball {
  background-color: var(--surface);
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  height: 22px;
  width: 22px;
  transform: translateX(0);
  transition: transform 0.2s ease;
}

.theme-switch:checked + .theme-switch-label .ball {
  transform: translateX(24px);
}

.theme-switch-label i {
  font-size: 0.75rem;
}

.theme-switch-label .fa-sun {
  color: var(--warning);
}

.theme-switch-label .fa-moon {
  color: var(--primary);
}

/* Responsive */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(0);
  }
  
  .sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }
  
  .main-content {
    margin-left: 0;
  }
  
  body.sidebar-collapsed .main-content {
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  .main-content {
    padding: 16px;
  }
  
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalOpen 0.3s ease-out forwards;
}

.modal-content.modal-lg {
  max-width: 800px;
}

@keyframes modalOpen {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--divider);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.close-modal {
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 0.2s ease;
  padding: 4px;
  border-radius: 4px;
}

.close-modal:hover {
  color: var(--text-primary);
  background-color: var(--divider);
  transform: scale(1.1);
}

.close-modal:active {
  transform: scale(0.9);
}

.modal-body {
  padding: 16px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--background);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  transform: scale(1.02);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary);
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Expert-only elements */
.expert-only {
  display: none;
}

body[data-role="expert"] .expert-only {
  display: flex;
}

/* Input Group */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group i {
  position: absolute;
  left: 12px;
  color: var(--text-tertiary);
}

.input-group input {
  padding-left: 36px;
}

/* Search Container */
.search-container {
  position: relative;
  max-width: 300px;
  width: 100%;
}

.search-container input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--background);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.search-container input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  transform: scale(1.02);
}

.search-container i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}

/* Hide sidebar content when collapsed */
.sidebar.collapsed .logo span,
.sidebar.collapsed .user-details,
.sidebar.collapsed .sidebar-nav span,
.sidebar.collapsed #logout-btn span {
  display: none;
}

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

.sidebar.collapsed .user-info {
  justify-content: center;
}

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

.sidebar.collapsed .sidebar-nav i {
  margin: 0;
}

.sidebar.collapsed .theme-toggle {
  display: flex;
  justify-content: center;
}

/* Fixed Search */
.fixed-search {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--surface);
  padding: 16px 0;
  margin-bottom: 16px;
}

/* Notification System */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 2000;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
}

.notification.show {
  transform: translateX(0);
}

.notification.success {
  background-color: var(--success);
}

.notification.error {
  background-color: var(--danger);
}

.notification.warning {
  background-color: var(--warning);
}

.notification.info {
  background-color: var(--primary);
}

.notification i {
  font-size: 1.2rem;
}

.notification-close {
  margin-left: auto;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.notification-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Button Loading State */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: spin 1s infinite linear;
}

.btn.loading span,
.btn.loading i {
  opacity: 0;
}

/* Login Modal Styles */
.login-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.login-footer p {
  margin-bottom: 4px;
}

/* Expert Login Button */
#expert-login-btn {
  display: flex;
  align-items: center;
  gap: 8px;
}