/* CSS Reset & Variables */
:root {
  /* Color Palette */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #a855f7;
  --accent-success: #10b981;
  --accent-danger: #f43f5e;
  --accent-warning: #f59e0b;
  
  /* Text Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  /* Borders & Shadows */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.4);
  --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.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

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

/* App Container Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Styling */
.sidebar {
  width: 320px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* Mode Switch Tabs */
.mode-switch-container {
  display: flex;
  background-color: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 2rem;
  gap: 0.25rem;
}

.mode-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.mode-tab i {
  width: 14px;
  height: 14px;
}

.mode-tab:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.02);
}

.mode-tab.active {
  color: white;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  box-shadow: var(--shadow-sm);
}

.brand-logo {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.brand h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.brand p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-section {
  flex-grow: 1;
}

.sidebar-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

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

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

.select-wrapper {
  position: relative;
  width: 100%;
}

select, input[type="url"], input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  appearance: none;
  outline: none;
}

select:focus, input[type="url"]:focus, input[type="text"]:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--border-focus);
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.checkbox-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-container input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
}

.checkbox-container label {
  margin-bottom: 0;
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
}

.help-text {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  outline: none;
}

.btn-block {
  width: 100%;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-primary-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

.btn-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-success:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-success:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-danger-text {
  color: var(--accent-danger);
  border-color: rgba(244, 63, 94, 0.2);
}

.btn-danger-text:hover {
  background-color: rgba(244, 63, 94, 0.1);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-neutral {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
}

/* Main Content Styling */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Top Bar */
.top-bar {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.active-class-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.active-class-info h2 {
  font-size: 1.25rem;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
}

/* Timetable Container */
.timetable-card-container {
  flex-grow: 1;
  padding: 2rem;
  overflow-y: auto;
  position: relative;
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted);
}

.welcome-illustration {
  background-color: rgba(99, 102, 241, 0.08);
  color: var(--accent-primary);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  border: 1px dashed rgba(99, 102, 241, 0.3);
}

.welcome-screen h3 {
  color: var(--text-main);
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.welcome-screen p {
  max-width: 480px;
  font-size: 0.95rem;
}

/* Timetable Grid Table */
.timetable-grid-wrapper {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-width: 800px;
}

.timetable-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.timetable-table th, .timetable-table td {
  border: 1px solid var(--border-color);
  text-align: center;
  padding: 1.25rem 0.75rem;
  vertical-align: top;
}

.timetable-table th {
  background-color: rgba(15, 23, 42, 0.4);
  font-weight: 600;
  color: var(--text-muted);
}

.day-header {
  width: 120px;
  font-family: 'Outfit', sans-serif;
  color: var(--text-main) !important;
  font-weight: 700 !important;
  vertical-align: middle;
  background-color: rgba(15, 23, 42, 0.5) !important;
}

.period-num {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.period-time {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Timetable Grid Cell (Interactive) */
.timetable-cell {
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
  position: relative;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.timetable-cell:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.timetable-cell.assigned {
  background-color: rgba(99, 102, 241, 0.06);
  border: 1px dashed rgba(99, 102, 241, 0.3);
}

.timetable-cell.assigned:hover {
  background-color: rgba(99, 102, 241, 0.1);
  border-color: var(--accent-primary);
}

.timetable-cell.clashed {
  background-color: rgba(244, 63, 94, 0.06);
  border: 1px dashed rgba(244, 63, 94, 0.4);
}

.timetable-cell.clashed:hover {
  background-color: rgba(244, 63, 94, 0.1);
  border-color: var(--accent-danger);
}

.cell-subject-code {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.timetable-cell.clashed .cell-subject-code {
  color: var(--accent-danger);
}

.cell-subject-name {
  font-size: 0.75rem;
  color: var(--text-main);
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-faculty-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 0.25rem;
}

.cell-faculty-badge {
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.cell-empty-btn {
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.timetable-cell:hover .cell-empty-btn {
  opacity: 1;
}

.cell-clash-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  color: var(--accent-danger);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}

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

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  background-color: rgba(15, 23, 42, 0.3);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Connection Status Panel */
.connection-status-panel {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

.status-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Conflict Alert in Modal */
.clash-warning-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background-color: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fda4af;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

.clash-warning-card i {
  color: var(--accent-danger);
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.clash-warning-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.clash-warning-card p {
  font-size: 0.8rem;
  opacity: 0.95;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
}

.toast {
  background-color: var(--bg-secondary);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.25rem;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateX(120%);
  transition: transform var(--transition-normal);
}

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

.toast.success {
  border-left-color: var(--accent-success);
}

.toast.error {
  border-left-color: var(--accent-danger);
}

.toast.warning {
  border-left-color: var(--accent-warning);
}

.toast-msg {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
}

/* Utility classes */
.hide {
  display: none !important;
}

/* Print Overrides */
@media print {
  body {
    background-color: white !important;
    color: black !important;
  }
  
  .app-container {
    display: block !important;
  }
  
  .sidebar, .top-bar, .modal, .toast-container, .cell-empty-btn, .cell-clash-indicator {
    display: none !important;
  }
  
  .main-content {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
  }
  
  .timetable-card-container {
    padding: 0 !important;
    overflow: visible !important;
  }
  
  .timetable-grid-wrapper {
    box-shadow: none !important;
    border: 2px solid black !important;
    border-radius: 0 !important;
    background-color: white !important;
    width: 100% !important;
    min-width: unset !important;
  }
  
  .timetable-table {
    border: 1px solid black !important;
  }
  
  .timetable-table th, .timetable-table td {
    border: 1px solid black !important;
    color: black !important;
    background-color: white !important;
  }
  
  .day-header {
    background-color: #f1f5f9 !important;
    color: black !important;
  }
  
  .cell-subject-code {
    color: black !important;
    font-size: 0.8rem !important;
  }
  
  .cell-subject-name {
    color: #334155 !important;
    font-size: 0.7rem !important;
  }
  
  .cell-faculty-badge {
    background-color: #e2e8f0 !important;
    border: 1px solid #cbd5e1 !important;
    color: black !important;
    font-size: 0.6rem !important;
  }
  
  /* Print Header styling */
  .timetable-grid-wrapper::before {
    content: "ACADEMIC CLASS TIMETABLE";
    display: block;
    text-align: center;
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: black;
  }
}
