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

:root {
  /* High-end Dark Theme */
  --bg-color: #0F0D0B;
  --surface-color: #1A1714;
  --surface-hover: #221F1B;
  --border-color: #2E2A26;
  --text-primary: #F0ECE8;
  --text-secondary: #9A918A;
  --text-tertiary: #786F67;
  
  --accent: #C49A7C;
  --accent-hover: #D9B092;
  --accent-subtle: rgba(196, 154, 124, 0.08);

  /* Card Colors (Dark Mode) */
  --card-1: #322820;
  --card-2: #283028;
  --card-3: #262C34;
  --card-4: #34262C;
  --card-5: #302C1E;
  
  --card-border-1: #8B6B50;
  --card-border-2: #5A7A5E;
  --card-border-3: #506882;
  --card-border-4: #8A5068;
  --card-border-5: #8A7A48;

  /* Time settings */
  --day-start: 8; 
  --hour-height: 85px;
  --grid-gap: 10px;
  --header-height: 64px;
}

[data-theme="light"] {
  --bg-color: #FAF7F2;
  --surface-color: #FFFFFF;
  --surface-hover: #F2EEEA;
  --border-color: #DDD6CD;
  --text-primary: #1C1917;
  --text-secondary: #5C554E;
  --text-tertiary: #847C75;
  
  --accent: #A07050;
  --accent-hover: #8A5E40;
  --accent-subtle: rgba(160, 112, 80, 0.06);

  --card-1: #F0E6DC;
  --card-2: #DDE8DE;
  --card-3: #DCE3EE;
  --card-4: #EEDDE4;
  --card-5: #F0ECDA;

  --card-border-1: #C49A7C;
  --card-border-2: #7CA080;
  --card-border-3: #7090B0;
  --card-border-4: #B07090;
  --card-border-5: #B0A060;
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: var(--accent);
  color: var(--bg-color);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* === Global Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* === Header === */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-height);
  padding: 0 48px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  background: color-mix(in srgb, var(--bg-color) 85%, transparent);
  border-bottom: 1px solid var(--border-color);
}

.app-header-left {
  display: flex;
  align-items: center;
}

.app-header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.app-header h1 .dot {
  color: var(--accent);
}

.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Live Clock */
.now-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  border-right: 1px solid var(--border-color);
  margin-right: 4px;
}

.now-dot {
  width: 6px;
  height: 6px;
  background: #5CB85C;
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.now-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

/* Icon Button (Theme Toggle) */
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

/* Configure Button */
.batch-selector {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.batch-selector:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

/* === Status Bar (Subject Pills) === */
.status-bar {
  padding: 0 48px;
  border-bottom: 1px solid var(--border-color);
  background: var(--accent-subtle);
}

.status-bar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  overflow-x: auto;
}

.status-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.subject-pills {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-primary);
}

.pill .pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--card-border);
  flex-shrink: 0;
}

/* === Empty State === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 48px;
}

.empty-state-icon {
  color: var(--text-tertiary);
  margin-bottom: 24px;
}

.empty-state h2 {
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 360px;
  line-height: 1.6;
}

.empty-state p strong {
  color: var(--accent);
  font-weight: 500;
}

/* === Timetable Grid === */
.timetable-container {
  padding: 24px 48px 80px 48px;
  max-width: 1800px;
  margin: 0 auto;
}

.week-grid {
  display: grid;
  grid-template-columns: 50px repeat(5, 1fr);
  gap: var(--grid-gap);
  position: relative;
}

/* Time Markers */
.time-column {
  display: flex;
  flex-direction: column;
  margin-top: 44px;
}

.time-marker {
  height: var(--hour-height);
  display: flex;
  justify-content: flex-end;
  padding-right: 14px;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  position: relative;
  transform: translateY(-7px);
}

.time-marker::after {
  content: '';
  position: absolute;
  top: 7px;
  left: calc(100% + 4px);
  width: calc(100vw - 130px);
  max-width: 1700px;
  height: 1px;
  background: var(--border-color);
  opacity: 0.5;
  z-index: 0;
}

/* Day Columns */
.day-column {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 800px; 
  border-left: 1px solid var(--border-color);
}

.day-column:last-child {
  border-right: 1px solid var(--border-color);
}

.day-header {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--accent-subtle);
  border-bottom: 1px solid var(--border-color);
}

/* Subject Cards */
.subject-card {
  position: absolute;
  width: calc(100% - 12px);
  left: 6px;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--card-bg);
  border-left: 3px solid var(--card-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  color: var(--text-primary);
  box-sizing: border-box;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  
  top: calc(((var(--start) - var(--day-start)) * var(--hour-height)) + 44px);
  height: calc(var(--duration) * var(--hour-height) - 6px);
}

.subject-card:hover {
  transform: translateY(-1px) scale(1.005);
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.06);
}

.subject-card h3 {
  margin: 0 0 4px 0;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.subject-card .card-time {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
}

.subject-card .card-location {
  margin: 4px 0 0 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 400;
}

.subject-card svg {
  opacity: 0.5;
  flex-shrink: 0;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

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

.modal-content {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 64px rgba(0,0,0,0.3);
}

.modal-header {
  padding: 28px 32px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-header h2 { 
  font-size: 1.15rem; 
  font-weight: 600; 
  letter-spacing: -0.02em; 
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.close-btn { 
  background: none; 
  border: 1px solid transparent; 
  color: var(--text-tertiary); 
  cursor: pointer; 
  transition: all 0.2s;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.close-btn:hover { 
  color: var(--text-primary); 
  background: var(--surface-hover);
  border-color: var(--border-color);
}

.modal-body {
  padding: 24px 32px 32px;
  overflow-y: auto;
}

/* Form Controls */
.form-row { display: flex; gap: 16px; margin-bottom: 28px; }
.form-group { flex: 1; display: flex; flex-direction: column; }
.form-group > label { 
  margin-bottom: 8px; 
  font-size: 0.7rem; 
  color: var(--text-secondary); 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.subject-count {
  color: var(--accent);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.form-group input[type="text"], .form-group select {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 11px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus, .form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

/* Search input with icon */
.subject-search { 
  position: relative; 
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.subject-search input[type="text"] { 
  width: 100%; 
  box-sizing: border-box; 
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 11px 14px 11px 42px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.subject-search input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  outline: none;
}

/* Subject List */
.subject-list {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  height: 260px;
  overflow-y: auto;
  padding: 6px;
  margin-top: 10px;
}

.subject-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s;
  user-select: none;
}
.subject-item:hover { background: var(--surface-hover); }
.subject-item span { font-size: 0.82rem; font-weight: 400; }

.subject-item.checked {
  background: var(--accent-subtle);
}

/* Custom Checkbox */
.subject-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.subject-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.subject-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 4px;
  height: 7px;
  border: solid var(--bg-color);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* Generate Button */
.form-actions { margin-top: 28px; }

.submit-btn {
  width: 100%;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  padding: 13px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.submit-btn:hover { background: var(--accent-hover); }
.submit-btn:active { transform: scale(0.98); }

/* === Footer === */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  background: color-mix(in srgb, var(--bg-color) 90%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.footer-divider { opacity: 0.3; }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 20px;
}

/* === Responsive === */
@media (max-width: 1000px) {
  .app-header { padding: 0 20px; }
  .timetable-container { padding: 20px 20px 80px; }
  .status-bar { padding: 0 20px; }
  .time-column { display: none; }
  .week-grid { grid-template-columns: 1fr; gap: 28px; }
  .day-column { min-height: auto; border: none; }
  .day-header { justify-content: flex-start; padding-left: 4px; border-bottom: 2px solid var(--border-color); background: transparent; margin-bottom: 12px; font-size: 0.8rem; }
  .subject-card { position: relative; top: auto !important; height: auto !important; margin-bottom: 10px; width: 100%; left: 0; padding: 14px 16px; border-left-width: 4px; }
  .now-indicator { display: none; }
  .app-footer { display: none; }
}
