/* ============================================
   HK P1 School Tracker - Main Stylesheet
   ============================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --gray: #6b7280;
  --gray-light: #f3f4f6;
  --gray-dark: #374151;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-light: #6b7280;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px 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);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.header {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: white;
  padding: 2rem 1rem;
  text-align: center;
}

.header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.header p {
  opacity: 0.9;
  font-size: 0.95rem;
}

.header .stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.header .stat {
  text-align: center;
}

.header .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.header .stat-label {
  font-size: 0.75rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Filter Bar */
.filter-bar {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.filter-bar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
}

.filter-bar select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
  min-width: 120px;
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.summary-card.accepting {
  border-left-color: var(--success);
}

.summary-card.closing {
  border-left-color: var(--warning);
}

.summary-card.closed {
  border-left-color: var(--danger);
}

.summary-card .card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.summary-card .card-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* School Grid */
.school-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

/* School Card */
.school-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.school-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.school-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.school-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.school-card-badges {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.school-card-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.school-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.school-card-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.status-item {
  font-size: 0.8rem;
  padding: 0.4rem 0.6rem;
  background: var(--gray-light);
  border-radius: 6px;
}

.status-item .label {
  color: var(--text-light);
  font-size: 0.7rem;
  display: block;
  margin-bottom: 0.15rem;
}

.status-item .value {
  font-weight: 600;
  display: block;
}

/* Badge Styles */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-yellow { background: #fef9c3; color: #ca8a04; }

.badge-type {
  background: #e0e7ff;
  color: #4338ca;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 10;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

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

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

.modal-body {
  padding: 1.25rem;
}

.modal-section {
  margin-bottom: 1.5rem;
}

.modal-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.modal-item {
  background: var(--gray-light);
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.modal-item .label {
  font-size: 0.75rem;
  color: var(--text-light);
  display: block;
  margin-bottom: 0.25rem;
}

.modal-item .value {
  font-weight: 600;
  font-size: 0.95rem;
}

.modal-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.modal-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
}

.modal-links a:hover {
  background: var(--primary-dark);
}

.modal-links a.secondary {
  background: var(--gray-light);
  color: var(--text);
}

.modal-links a.secondary:hover {
  background: #e5e7eb;
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-light);
  font-size: 0.8rem;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

/* Responsive */
@media (max-width: 640px) {
  .header h1 { font-size: 1.4rem; }
  .header .stats { gap: 1rem; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select { width: 100%; }
  .search-box { width: 100%; }
  .school-grid { grid-template-columns: 1fr; }
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .school-card-status { grid-template-columns: 1fr; }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
