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

:root {
  /* Color Palette */
  --primary-blue: #0A192F;
  --secondary-blue: #112240;
  --light-blue: #233554;
  --accent-gold: #D4AF37;
  --accent-gold-hover: #F1C40F;
  --bg-color: #F8FAFC;
  --surface-white: #FFFFFF;
  --text-main: #1E293B;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --danger: #EF4444;
  --success: #10B981;
  
  --font-en: 'Inter', sans-serif;
  --font-ar: 'Cairo', sans-serif;
  
  /* Shadows & Transitions */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
}

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

body {
  font-family: var(--font-en);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Arabic Typography Support */
[lang="ar"], .arabic {
  font-family: var(--font-ar);
}

/* --- Layout & Containers --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-wrapper {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* --- Header & Branding --- */
.site-header {
  background-color: var(--surface-white);
  box-shadow: var(--shadow-md);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--accent-gold);
}

/* On mobile: header scrolls with page (not sticky) */
@media (max-width: 767px) {
  .site-header {
    position: static;
  }
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.brand-logo {
  height: 60px;
  width: auto;
}

@media (min-width: 768px) {
  .brand-logo {
    height: 80px;
  }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  color: var(--primary-blue);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.brand-subtitle {
  color: var(--accent-gold);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Filters Section --- */
.filter-section {
  background: var(--surface-white);
  border-radius: 1rem;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--primary-blue);
  animation: slideDown 0.5s ease-out;
}

@media (min-width: 768px) {
  .filter-section {
    padding: 3rem;
    margin: 3rem 0;
  }
}



.form-label {
  font-weight: 600;
  color: var(--secondary-blue);
  font-size: 1.1rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.form-select, .form-input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: var(--bg-color);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.2em;
}

/* Fix for date picker icon on Windows/Chrome */
input[type="date"].form-input {
  position: relative;
}
input[type="date"].form-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}
input[type="date"].form-input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.form-select:focus, .form-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(10, 25, 47, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary-blue);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background-color: var(--secondary-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(10, 25, 47, 0.2);
}

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

.btn-accent:hover {
  background-color: var(--accent-gold-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

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

.btn-outline:hover {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
  background-color: rgba(10, 25, 47, 0.05);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

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

/* --- Schedule Table --- */
.schedule-container {
  background: var(--surface-white);
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 3rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.schedule-container.visible {
  opacity: 1;
  transform: translateY(0);
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background-color: var(--primary-blue);
  color: white;
  font-weight: 600;
  padding: 1.25rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

td {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

tr {
  transition: background-color var(--transition-fast);
}

tbody tr:hover {
  background-color: rgba(212, 175, 55, 0.05);
}

.subject-name {
  font-weight: 600;
  color: var(--primary-blue);
}

.time-badge {
  background-color: rgba(10, 25, 47, 0.1);
  color: var(--primary-blue);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-block;
}

.hall-badge {
  background-color: rgba(212, 175, 55, 0.15);
  color: #927519;
  padding: 0.25rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
}

/* --- States --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  color: var(--border-color);
}

.empty-state h3 {
  color: var(--primary-blue);
  margin-bottom: 0.5rem;
}

.loader {
  display: none;
  border: 3px solid rgba(10, 25, 47, 0.1);
  border-radius: 50%;
  border-top: 3px solid var(--accent-gold);
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 4rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

/* --- Mobile Table (Stacked Cards) --- */
@media (max-width: 768px) {
  table, thead, tbody, th, td, tr {
    display: block;
  }
  
  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  tr {
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    margin: 1rem;
    padding: 0.5rem;
    background: var(--surface-white);
    box-shadow: var(--shadow-sm);
  }
  
  td {
    border: none;
    border-bottom: 1px solid var(--bg-color);
    position: relative;
    padding-left: 40%;
    text-align: right;
  }
  
  td:before {
    position: absolute;
    top: 1.25rem;
    left: 1rem;
    width: 35%;
    padding-right: 10px;
    white-space: nowrap;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    content: attr(data-label);
  }
  
  .subject-name, .time-badge, .hall-badge {
    display: inline-block;
  }
}

/* --- Admin Layout --- */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-color);
}

.admin-sidebar {
  width: 280px;
  background-color: var(--primary-blue);
  color: white;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  transition: transform var(--transition-normal);
}

.admin-sidebar .brand-title {
  color: white;
}

.admin-sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-nav {
  flex: 1;
  padding: 1.5rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border-left: 4px solid var(--accent-gold);
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-header {
  background-color: var(--surface-white);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.admin-content {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
}

.card {
  background: var(--surface-white);
  border-radius: 1rem;
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

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

.card-title {
  color: var(--primary-blue);
  font-size: 1.25rem;
}

.admin-table-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  padding-left: 2.5rem;
}

.action-btns {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.25rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background-color: var(--bg-color);
  color: var(--primary-blue);
}

.icon-btn.delete:hover {
  color: var(--danger);
  background-color: rgba(239, 68, 68, 0.1);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(10, 25, 47, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--transition-normal), visibility 0s linear 0.3s;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  visibility: visible;
  opacity: 1;
  transition: opacity var(--transition-normal), visibility 0s linear 0s;
}

.modal-content {
  background: var(--surface-white);
  border-radius: 1rem;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

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

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

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: white;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  background-color: var(--bg-color);
}

/* File Upload */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 0.5rem;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background-color: var(--bg-color);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary-blue);
  background-color: rgba(10, 25, 47, 0.02);
}

.upload-icon {
  color: var(--accent-gold);
  margin-bottom: 1rem;
}

.upload-text {
  color: var(--text-main);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.upload-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
}

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

.toast {
  background: var(--surface-white);
  border-left: 4px solid var(--success);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

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

/* Mobile Sidebar Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--primary-blue);
  cursor: pointer;
}

@media (max-width: 1024px) {
  .admin-sidebar {
    position: fixed;
    height: 100vh;
    transform: translateX(-100%);
  }
  
  .admin-sidebar.open {
    transform: translateX(0);
  }
  
  .menu-toggle {
    display: block;
  }
}
