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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.6;
  padding: 20px;
  transition: background 0.3s, color 0.3s;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.app-header h1 {
  margin-bottom: 0.25rem;
}

.app-header .subtitle {
  margin-bottom: 0;
}

.header-buttons {
  display: flex;
  gap: 0.5rem;
}

h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: #666;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #444;
}

.card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: background 0.3s, box-shadow 0.3s;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input[type="text"],
input[type="number"] {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

input[type="text"] {
  flex: 1;
  min-width: 200px;
}

input[type="number"] {
  width: 80px;
}

button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #e0e0e0;
  transition: background 0.2s;
}

button:hover {
  background: #d0d0d0;
}

button.primary {
  background: #4CAF50;
  color: white;
}

button.primary:hover {
  background: #45a049;
}

button.danger {
  background: #f44336;
  color: white;
}

button.danger:hover {
  background: #da190b;
}

button.small {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.list {
  margin-top: 1rem;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #f9f9f9;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.list-item:hover {
  background: #f0f0f0;
}

.list-item .name {
  font-weight: 500;
}

.list-item .subjects {
  color: #666;
  font-size: 0.9rem;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  background: #f0f0f0;
  border-radius: 4px;
}

.checkbox-group label:hover {
  background: #e0e0e0;
}

.schedule-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.slot {
  background: #f0f4f8;
  border-radius: 8px;
  padding: 1rem;
  border-left: 4px solid #2196F3;
}

.slot-header {
  font-weight: 600;
  color: #2196F3;
  margin-bottom: 0.5rem;
}

.slot-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.subject-tag {
  background: #2196F3;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
}

/* Subject cards with teachers */
.subject-card {
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.75rem;
  cursor: grab;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  min-width: 150px;
}

.subject-card:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  border-color: #2196F3;
}

.subject-card:active {
  cursor: grabbing;
}

.subject-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.subject-name {
  font-weight: 600;
  color: #2196F3;
  margin-bottom: 0.25rem;
}

.subject-teachers {
  font-size: 0.8rem;
  color: #666;
  line-height: 1.4;
}

.subject-teachers em {
  color: #999;
}

/* Drag and drop styles */
.slot {
  transition: all 0.2s;
  min-height: 80px;
}

.slot.drag-over {
  background: #e3f2fd;
  border-color: #2196F3;
  box-shadow: inset 0 0 0 2px #2196F3;
}

.empty-slot-hint {
  color: #999;
  font-style: italic;
  font-size: 0.9rem;
}

.warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  padding: 1rem;
  border-radius: 4px;
  margin-top: 1rem;
}

.warning.hidden {
  display: none;
}

.warning h4 {
  margin-bottom: 0.5rem;
}

.warning ul {
  margin-left: 1.5rem;
}

.empty-state {
  color: #999;
  font-style: italic;
  padding: 1rem;
  text-align: center;
}

/* CSV Import styles */
.help-text {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.help-text code {
  background: #f0f0f0;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85rem;
}

textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: monospace;
  resize: vertical;
}

input[type="file"] {
  padding: 0.5rem 0;
}

.import-result {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 4px;
}

.import-result.hidden {
  display: none;
}

.import-result .success {
  color: #155724;
  background: #d4edda;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.import-result .error {
  color: #721c24;
  background: #f8d7da;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
}

.import-result .warning-text {
  color: #856404;
  background: #fff3cd;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.import-result .warning-text ul {
  margin-left: 1.5rem;
  margin-top: 0.25rem;
}

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

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin-bottom: 1rem;
  color: #333;
}

.modal-content label {
  font-weight: 500;
  color: #555;
}

.modal-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Button group for list items */
.button-group {
  display: flex;
  gap: 0.5rem;
}

/* Subject checkbox row with priority */
.subject-checkbox-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: #f8f9fa;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.subject-checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.priority-label {
  font-size: 0.85rem;
  color: #f59e0b;
}

.priority-label.hidden {
  display: none;
}

.list-item .subjects strong {
  color: #f59e0b;
}

@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  input[type="text"] {
    min-width: auto;
  }
  
  .modal-content {
    width: 95%;
    padding: 1rem;
  }
  
  .app-header {
    flex-direction: column;
  }
}

/* Login page styles */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  margin-bottom: 0.5rem;
}

.login-card .subtitle {
  margin-bottom: 1.5rem;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.login-error {
  color: #dc3545;
  background: #f8d7da;
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.login-error.hidden {
  display: none;
}

button.full-width {
  width: 100%;
}

/* ============ DARK MODE ============ */
body.dark-mode {
  background: #1a1a2e;
  color: #eee;
}

body.dark-mode .subtitle {
  color: #aaa;
}

body.dark-mode h2 {
  color: #ddd;
}

body.dark-mode .card {
  background: #16213e;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode input[type="password"],
body.dark-mode textarea {
  background: #1a1a2e;
  border-color: #444;
  color: #eee;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #888;
}

body.dark-mode button {
  background: #2d3a5a;
  color: #eee;
}

body.dark-mode button:hover {
  background: #3d4a6a;
}

body.dark-mode button.primary {
  background: #4CAF50;
}

body.dark-mode button.primary:hover {
  background: #45a049;
}

body.dark-mode button.danger {
  background: #f44336;
}

body.dark-mode .list-item {
  background: #1a1a2e;
}

body.dark-mode .list-item:hover {
  background: #252545;
}

body.dark-mode .list-item .subjects {
  color: #aaa;
}

body.dark-mode .checkbox-group label {
  background: #1a1a2e;
}

body.dark-mode .checkbox-group label:hover {
  background: #252545;
}

body.dark-mode .slot {
  background: #1a1a2e;
  border-left-color: #2196F3;
}

body.dark-mode .slot.drag-over {
  background: #1e3a5f;
}

body.dark-mode .subject-card {
  background: #16213e;
  border-color: #444;
}

body.dark-mode .subject-card:hover {
  border-color: #2196F3;
}

body.dark-mode .subject-teachers {
  color: #aaa;
}

body.dark-mode .warning {
  background: #3d3510;
  border-color: #665c00;
  color: #ffc107;
}

body.dark-mode .modal-content {
  background: #16213e;
}

body.dark-mode .modal-content h3 {
  color: #eee;
}

body.dark-mode .modal-content label {
  color: #ccc;
}

body.dark-mode .help-text {
  color: #aaa;
}

body.dark-mode .help-text code {
  background: #1a1a2e;
}

body.dark-mode .empty-state,
body.dark-mode .empty-slot-hint {
  color: #666;
}

body.dark-mode .import-result .success {
  background: #1e4620;
  color: #8bc34a;
}

body.dark-mode .import-result .error {
  background: #4a1e1e;
  color: #f44336;
}

body.dark-mode .import-result .warning-text {
  background: #3d3510;
  color: #ffc107;
}

body.dark-mode .login-card {
  background: #16213e;
}

body.dark-mode .login-error {
  background: #4a1e1e;
  color: #f44336;
}

body.dark-mode .subject-checkbox-row {
  background: #1a1a2e;
}

body.dark-mode .list-item .subjects strong {
  color: #fbbf24;
}
