/* =====================================================
   منصة تحفيظ القرآن الكريم — CSS الرئيسي
   ألوان: أخضر زمردي + ذهبي + كريمي
   ===================================================== */

:root {
  --green-dark:   #1a3a2a;
  --green-mid:    #2d6a4f;
  --green-light:  #40916c;
  --green-pale:   #d8f3dc;
  --gold:         #c9a84c;
  --gold-light:   #f0d080;
  --cream:        #fdf8f0;
  --cream-dark:   #f5ece0;
  --text-dark:    #1a2520;
  --text-mid:     #3d5a4a;
  --text-light:   #6b8c78;
  --white:        #ffffff;
  --shadow-sm:    0 2px 8px rgba(26,58,42,.10);
  --shadow-md:    0 4px 20px rgba(26,58,42,.15);
  --shadow-lg:    0 8px 40px rgba(26,58,42,.20);
  --radius:       12px;
  --radius-lg:    20px;
  --font-body:    'Tajawal', sans-serif;
  --font-display: 'Amiri', serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  direction: rtl;
}

/* --- Navbar --- */
.navbar {
  background: var(--green-dark);
  padding: .9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 350;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
}
.navbar-logo {
  font-size: 1.6rem;
  color: var(--gold);
}
.navbar-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--white);
  letter-spacing: .5px;
}
.navbar-links {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.navbar-links a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .95rem;
  transition: color .2s;
}
.navbar-links a:hover { color: var(--gold-light); }
.btn-logout {
  background: rgba(255,255,255,.12);
  padding: .35rem .9rem;
  border-radius: 6px;
}
.btn-register {
  background: var(--gold) !important;
  color: var(--green-dark) !important;
  font-weight: 700;
  padding: .35rem .9rem;
  border-radius: 6px;
}

/* --- Main --- */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* --- Alert --- */
.alert {
  padding: .85rem 1.2rem;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  font-size: .95rem;
  font-weight: 500;
}
.alert-success { background: var(--green-pale); color: var(--green-dark); border-right: 4px solid var(--green-mid); }
.alert-error   { background: #fdecea; color: #c0392b; border-right: 4px solid #e74c3c; }
.alert-info    { background: #e8f4fd; color: #1a5276; border-right: 4px solid #3498db; }

/* --- Auth Pages --- */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
  min-height: calc(100vh - 140px);
}
.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  border-top: 4px solid var(--gold);
}
.auth-card-wide { max-width: 620px; }

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-icon {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--green-mid);
  background: var(--green-pale);
  display: inline-block;
  padding: .4rem 1rem;
  border-radius: 20px;
  margin-bottom: 1rem;
}
.auth-header h1 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--green-dark);
  margin-bottom: .3rem;
}
.auth-header p {
  color: var(--text-light);
  font-size: .95rem;
}

/* --- Forms --- */
.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-mid);
}
.form-group input {
  border: 1.5px solid #dde8e2;
  border-radius: 8px;
  padding: .7rem 1rem;
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--text-dark);
  background: var(--cream);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--green-light);
  box-shadow: 0 0 0 3px rgba(64,145,108,.15);
  background: var(--white);
}
.form-group small {
  font-size: .82rem;
  color: var(--text-light);
}
.form-group-code input {
  letter-spacing: 2px;
  font-weight: 700;
  text-align: center;
}
.required { color: #e74c3c; }
.optional  { color: var(--text-light); font-weight: 400; font-size: .85rem; }

/* --- Buttons --- */
.btn-primary {
  background: var(--green-mid);
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: .85rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn-primary:hover    { background: var(--green-dark); }
.btn-primary:active   { transform: scale(.98); }
.btn-full             { width: 100%; }

.btn-gold {
  background: var(--gold);
  color: var(--green-dark);
  border: none;
  border-radius: 8px;
  padding: .7rem 1.5rem;
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
  text-decoration: none;
  display: inline-block;
}
.btn-gold:hover { background: var(--gold-light); }

.btn-outline {
  background: transparent;
  color: var(--green-mid);
  border: 2px solid var(--green-mid);
  border-radius: 8px;
  padding: .65rem 1.4rem;
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  display: inline-block;
}
.btn-outline:hover { background: var(--green-mid); color: var(--white); }

/* --- Auth Footer --- */
.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-light);
  font-size: .9rem;
}
.auth-footer a {
  color: var(--green-mid);
  font-weight: 700;
  text-decoration: none;
}
.auth-footer a:hover { text-decoration: underline; }

/* --- Session Cards --- */
.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.2rem;
  margin-top: 1.5rem;
}
.session-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem;
  border-right: 4px solid var(--green-light);
  transition: box-shadow .2s, transform .2s;
}
.session-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.session-card.live  { border-right-color: var(--gold); }

.session-badge {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 700;
  margin-bottom: .7rem;
}
.badge-live     { background: #fff3cd; color: #856404; animation: pulse 2s infinite; }
.badge-upcoming { background: var(--green-pale); color: var(--green-dark); }
.badge-recorded { background: #e8eaf6; color: #3949ab; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}

.session-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--green-dark);
  margin-bottom: .5rem;
}
.session-time {
  font-size: .88rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* --- Live Player Page --- */
.live-container {
  max-width: 900px;
  margin: 0 auto;
}
.live-header {
  margin-bottom: 1rem;
}
.live-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--green-dark);
}
.player-wrapper {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
media-player {
  width: 100%;
  aspect-ratio: 16/9;
}

/* --- Admin --- */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 60px);
  gap: 0;
}
.admin-sidebar {
  background: var(--green-dark);
  padding: 1.5rem 0;
}
.admin-sidebar a {
  display: block;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  padding: .75rem 1.5rem;
  font-size: .95rem;
  transition: all .2s;
}
.admin-sidebar a:hover,
.admin-sidebar a.active { background: rgba(255,255,255,.1); color: var(--gold-light); }
.admin-main { padding: 2rem; }

.admin-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.admin-card h2 {
  font-size: 1.1rem;
  color: var(--green-dark);
  margin-bottom: 1rem;
  padding-bottom: .7rem;
  border-bottom: 2px solid var(--green-pale);
}

/* --- Table --- */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .75rem 1rem; text-align: right; }
th { background: var(--green-pale); color: var(--green-dark); font-weight: 700; }
tr:nth-child(even) { background: var(--cream); }
tr:hover { background: #edf7f1; }

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--green-dark);
}

/* --- Footer --- */
.footer {
  background: var(--green-dark);
  color: rgba(255,255,255,.6);
  text-align: center;
  padding: 1rem;
  font-size: .85rem;
  margin-top: auto;
}

/* --- Sidebar Toggle (Admin) --- */
.sidebar-toggle-checkbox { display: none; }
.hamburger-btn {
  display: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: .2rem .4rem;
}
.sidebar-overlay { display: none; }

/* --- Mobile Nav Toggle (Student) --- */
.nav-toggle-checkbox { display: none; }
.nav-hamburger-btn {
  display: none;
  color: var(--white);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  /* --- Admin sidebar يتحول لدرج جانبي (drawer) --- */
  .admin-layout { grid-template-columns: 1fr; }
  .hamburger-btn { display: block; }
  .admin-sidebar {
    position: fixed;
    top: 0;
    right: -270px;
    height: 100vh;
    width: 250px;
    z-index: 300;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transition: right .25s ease;
    padding-top: 4.5rem;
  }
  #sidebarToggle:checked ~ .admin-layout .admin-sidebar { right: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 250;
    cursor: pointer;
  }
  #sidebarToggle:checked ~ .admin-layout .sidebar-overlay { display: block; }
  .admin-main { padding: 1rem; }

  /* --- ناف بار الطالب يتحول لقائمة همبرجر --- */
  .nav-hamburger-btn { display: block; }
  .navbar-links {
    position: fixed;
    top: 0;
    right: -80%;
    width: 78%;
    max-width: 300px;
    height: 100vh;
    background: var(--green-dark);
    flex-direction: column;
    align-items: flex-start;
    padding: 4.5rem 1.5rem 1.5rem;
    gap: .3rem;
    z-index: 300;
    box-shadow: var(--shadow-lg);
    transition: right .25s ease;
    overflow-y: auto;
  }
  #navToggle:checked ~ .navbar .navbar-links { right: 0; }
  .navbar-links a {
    width: 100%;
    padding: .8rem .5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    font-size: 1rem;
  }
  .nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 250;
  }
  #navToggle:checked ~ .nav-overlay { display: block; }
}

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .main-content { padding: 1rem; }
  .auth-card { padding: 1.5rem; }
  .navbar { padding: .8rem 1rem; }
  .navbar-title { font-size: 1rem; }
  .admin-layout { grid-template-columns: 1fr; }

  /* --- خطوط وعناوين أصغر شوية عشان تتناسب مع الشاشة --- */
  .page-header { flex-wrap: wrap; gap: .6rem; }
  .page-header h1 { font-size: 1.25rem; }
  .admin-card { padding: 1rem; }
  .admin-card h2 { font-size: 1rem; }

  /* --- الأزرار تاخد مساحة لمس كافية على الموبايل --- */
  .btn-primary, .btn-gold, .btn-outline, .btn-danger, .btn-live, .btn-end, .btn-success {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* --- الجداول: خط أصغر شوية + سكرول أفقي واضح --- */
  table { font-size: .82rem; }
  th, td { padding: .55rem .6rem; }

  /* --- فورم الراديو بتاعة نوع الحصة وغيرها متلخبطش --- */
  .form-group > div[style*="flex"] { flex-wrap: wrap; }
}