/* ================================
   جداول الاختبارات - الكلية التقنية بالوجه
   تصميم الموقع: المهندس عبدالعزيز العنزي
   ================================ */

/* ===== المتغيرات (الألوان والظلال) ===== */
:root {
  --primary: #0f4c5c;
  --primary-dark: #093744;
  --primary-light: #1a6b80;
  --accent: #e36414;
  --accent-soft: #fff4eb;
  --gold: #c9a961;
  --bg: #f7f4ed;
  --paper: #ffffff;
  --ink: #1a1f2c;
  --ink-soft: #4a5568;
  --muted: #8b95a3;
  --line: #e5e0d3;
  --line-strong: #d4cab5;
  --shadow: rgba(15, 76, 92, 0.08);
  --shadow-strong: rgba(15, 76, 92, 0.15);
}

/* ===== إعدادات عامة ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Tajawal', 'Cairo', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 10% 0%, rgba(15, 76, 92, 0.06), transparent 40%),
    radial-gradient(circle at 90% 100%, rgba(227, 100, 20, 0.05), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ===== الترويسة (الهيدر) ===== */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 24px;
  padding: 28px 24px;
  color: white;
  box-shadow: 0 12px 32px var(--shadow-strong);
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.header::before,
.header::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.header::before {
  top: -40px;
  left: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(201, 169, 97, 0.15), transparent 70%);
}

.header::after {
  bottom: -50px;
  right: -50px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(227, 100, 20, 0.12), transparent 70%);
}

.header-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-circle {
  width: 180px;
  height: 120px;
  border-radius: 18px;
  background: rgb(255, 255, 255);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 6px;
}

.logo-circle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header h1 {
  font-family: 'Cairo', sans-serif;
  font-size: clamp(20px, 4.5vw, 26px);
  font-weight: 900;
  line-height: 1.3;
  text-align: center;
}

/* توسيط كامل المحتوى التقني داخل الهيدر */
.header .header-inner {
  justify-content: center;
}

.header > div:not(.header-inner),
.header > div {
  text-align: center;
}

.header .subtitle {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  margin-top: 4px;
  font-weight: 500;
}

.header .term-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px;
  background: var(--gold);
  color: var(--primary-dark);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
}

/* ===== التبويبات (نظري / عملي) ===== */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px var(--shadow);
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: 11px;
  padding: 14px 12px;
  font-family: 'Cairo', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-btn .tab-icon {
  font-size: 20px;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 6px 16px var(--shadow-strong);
}

.tab-btn:not(.active):hover {
  background: var(--bg);
  color: var(--primary);
}

/* ===== بطاقة الاختيار (القسم/المستوى) ===== */
.selector-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 6px 20px var(--shadow);
}

.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 14px;
  font-family: 'Cairo', sans-serif;
}

.step-text {
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
}

/* ===== أزرار الأقسام ===== */
.dept-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .dept-grid {
    grid-template-columns: 1fr;
  }
}

.dept-btn {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 16px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: center;
  color: var(--ink);
}

.dept-btn:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px var(--shadow);
}

.dept-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 8px 20px var(--shadow-strong);
}

.dept-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 6px;
}

.dept-name {
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 14px;
  line-height: 1.4;
}

/* ===== أزرار المستويات ===== */
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 500px) {
  .level-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.level-btn {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 14px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  color: var(--ink);
  font-size: 14px;
}

.level-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.level-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.level-num {
  font-size: 22px;
  font-weight: 900;
  display: block;
}

.level-label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 2px;
}

/* ===== قسم الجدول ===== */
.schedule-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 6px 20px var(--shadow);
  animation: slideUp 0.35s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 2px dashed var(--line);
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}

.schedule-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.schedule-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}

.schedule-icon.theory {
  background: var(--accent-soft);
  color: var(--accent);
}

.schedule-icon.practical {
  background: rgba(15, 76, 92, 0.1);
  color: var(--primary);
}

.schedule-title {
  font-family: 'Cairo', sans-serif;
  font-weight: 900;
  font-size: 18px;
  color: var(--ink);
}

.schedule-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.week-badge {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ===== بطاقات الاختبارات ===== */
.exam-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exam-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  transition: all 0.2s ease;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}

.exam-card:hover {
  background: var(--paper);
  border-color: var(--primary-light);
  box-shadow: 0 4px 12px var(--shadow);
}

.exam-card.empty {
  background: var(--paper);
  border-style: dashed;
  opacity: 0.7;
}

.exam-date {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  min-width: 64px;
}

.exam-card.empty .exam-date {
  background: transparent;
}

.exam-day {
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 12px;
  color: var(--primary);
  margin-bottom: 2px;
}

.exam-hijri {
  font-size: 11px;
  color: var(--ink-soft);
  direction: ltr;
  font-family: 'Tajawal', sans-serif;
  font-weight: 600;
}

.exam-greg {
  font-size: 10px;
  color: var(--muted);
  direction: ltr;
  margin-top: 2px;
}

.exam-info {
  min-width: 0;
}

.exam-subject {
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.4;
  margin-bottom: 8px;
}

.exam-card.empty .exam-subject {
  color: var(--muted);
  font-style: italic;
}

.exam-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ===== شارات المعلومات (الفترة، الوقت، المكان) ===== */
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}

.meta-chip.time {
  background: rgba(15, 76, 92, 0.06);
  color: var(--primary);
  border-color: rgba(15, 76, 92, 0.15);
}

.meta-chip.location {
  background: rgba(227, 100, 20, 0.08);
  color: var(--accent);
  border-color: rgba(227, 100, 20, 0.2);
}

.meta-chip.period {
  background: rgba(201, 169, 97, 0.15);
  color: #8a7340;
  border-color: rgba(201, 169, 97, 0.3);
}

/* ===== كتل الفترات داخل البطاقة ===== */
.periods-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.period-block {
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.period-block:first-child {
  padding-top: 0;
  border-top: none;
}

/* ===== شاشة "اختر القسم والمستوى" ===== */
.placeholder {
  background: var(--paper);
  border: 2px dashed var(--line-strong);
  border-radius: 22px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

.placeholder-icon {
  font-size: 48px;
  margin-bottom: 10px;
  opacity: 0.5;
}

.placeholder-text {
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.placeholder-sub {
  font-size: 13px;
  color: var(--muted);
}

/* ===== أزرار الإجراءات (طباعة، تغيير الاختيار) ===== */
.action-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.action-btn {
  flex: 1;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== التذييل ===== */
.footer-note {
  text-align: center;
  margin-top: 24px;
  padding: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.footer-note strong {
  color: var(--ink-soft);
}

.footer-note .designer {
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
}

.footer-note .designer b {
  color: var(--primary);
  font-weight: 800;
}

/* ===== إعدادات الطباعة ===== */
@media print {
  body::before {
    display: none;
  }
  .selector-card,
  .header::before,
  .header::after,
  .action-bar,
  .tabs {
    display: none !important;
  }
  .schedule-section {
    box-shadow: none;
    border: 1px solid #999;
    page-break-inside: avoid;
  }
  body {
    background: white;
  }
}
