/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary:      #4f46e5;
  --primary-hover:#4338ca;
  --primary-light:#eef2ff;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --bg:           #f8fafc;
  --white:        #ffffff;
  --success:      #16a34a;
  --success-bg:   #f0fdf4;
  --danger:       #dc2626;
  --radius:       8px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:    0 10px 30px rgba(0,0,0,.10);
}

body { font-family: 'Inter', 'Segoe UI', sans-serif; color: var(--text); background: var(--bg); line-height: 1.6; font-size: 15px; }
a { text-decoration: none; color: inherit; }
img { display: block; }
button { font-family: inherit; cursor: pointer; }

/* ===== NAVBAR ===== */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  max-width: 1160px; margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex; align-items: center; gap: 1.5rem;
}
.nav-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.2rem; color: var(--text);
  white-space: nowrap;
}
.nav-logo img { height: 34px; width: 34px; border-radius: 6px; object-fit: cover; }
.nav-logo span { color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 1.5rem; margin-left: auto; }
.nav-links a { color: var(--text-muted); font-size: .9rem; font-weight: 500; transition: color .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.btn-nav {
  background: var(--primary); color: var(--white) !important;
  padding: .45rem 1.1rem; border-radius: var(--radius);
  font-size: .88rem; font-weight: 600;
  transition: background .15s;
}
.btn-nav:hover { background: var(--primary-hover) !important; }

/* ===== HERO ===== */
.hero {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 4rem 1.5rem;
  text-align: center;
}
.hero-inner { max-width: 640px; margin: 0 auto; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; line-height: 1.25; color: var(--text); margin-bottom: .75rem; }
.hero h1 span { color: var(--primary); }
.hero p { color: var(--text-muted); font-size: 1rem; margin-bottom: 2rem; }
.hero-cta { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.3rem; border-radius: var(--radius);
  font-size: .92rem; font-weight: 600; border: none;
  transition: all .15s;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #15803d; }
.btn-gray { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-gray:hover { border-color: var(--primary); color: var(--primary); }
.btn-lg { padding: .8rem 1.8rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ===== SECTION ===== */
.section { padding: 3.5rem 1.5rem; }
.section-inner { max-width: 1160px; margin: 0 auto; }
.section-header { margin-bottom: 2rem; }
.section-header h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: .3rem; }
.section-header p { color: var(--text-muted); font-size: .95rem; }

/* ===== CARD ===== */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

/* ===== COURSE CARD ===== */
.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }

.course-card { cursor: pointer; }
.course-thumb {
  position: relative; padding-top: 56.25%;
  background: #e2e8f0; overflow: hidden;
}
.course-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.course-play-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.course-card:hover .course-play-overlay { opacity: 1; }
.play-circle {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--white); display: flex; align-items: center; justify-content: center;
  color: var(--primary); font-size: 1.1rem;
}
.badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--primary); color: var(--white);
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; padding: .2rem .55rem; border-radius: 4px;
}
.course-body { padding: 1.1rem; }
.course-title { font-weight: 700; font-size: .98rem; margin-bottom: .35rem; line-height: 1.4; }
.course-meta-row { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); font-size: .82rem; }
.course-meta-row i { font-size: .8rem; }
.course-free {
  display: inline-block; margin-top: .75rem;
  background: var(--success-bg); color: var(--success);
  font-size: .8rem; font-weight: 700; padding: .25rem .6rem; border-radius: 4px;
}

/* ===== FEATURES ===== */
.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.5rem; }
.feature-item { padding: 1.5rem; background: var(--white); border: 1px solid var(--border); border-radius: 10px; }
.feature-icon {
  width: 42px; height: 42px; border-radius: 8px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: .9rem;
}
.feature-item h3 { font-size: .95rem; font-weight: 700; margin-bottom: .3rem; }
.feature-item p { font-size: .85rem; color: var(--text-muted); }

/* ===== COURSE PAGE ===== */
.course-layout {
  max-width: 1160px; margin: 0 auto; padding: 2rem 1.5rem;
  display: grid; grid-template-columns: 1fr 320px; gap: 2rem; align-items: start;
}
.course-page-header {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 1.5rem;
}
.course-page-header-inner { max-width: 1160px; margin: 0 auto; }
.breadcrumb { display: flex; align-items: center; gap: .35rem; font-size: .83rem; color: var(--text-muted); margin-bottom: .5rem; }
.breadcrumb a { color: var(--primary); }
.breadcrumb i { font-size: .7rem; }
.course-page-header h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: .4rem; }
.course-page-header p { color: var(--text-muted); font-size: .92rem; }

/* ===== VIDEO ===== */
.video-wrap {
  position: relative; padding-top: 56.25%;
  background: #0f172a; border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow);
}
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }

/* ===== PROGRESS ===== */
.progress-card { padding: 1.2rem; margin-top: 1.25rem; }
.progress-label { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; margin-bottom: .5rem; }
.progress-track { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 1rem; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s ease; }

.cert-locked-notice {
  display: flex; align-items: flex-start; gap: .75rem;
  background: #fff7ed; border: 1px solid #fed7aa;
  border-radius: var(--radius); padding: .9rem 1rem;
  font-size: .88rem; color: #9a3412;
}
.cert-locked-notice i { margin-top: 2px; font-size: 1rem; flex-shrink: 0; }

/* ===== CURRICULUM ===== */
.curriculum-card { margin-top: 1.25rem; }
.curriculum-header { padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: .5rem; color: var(--text); }
.curriculum-item {
  display: flex; align-items: center; gap: .9rem;
  padding: .85rem 1.2rem; border-bottom: 1px solid var(--border);
  transition: background .15s; cursor: default;
}
.curriculum-item:last-child { border-bottom: none; }
.curriculum-item.clickable { cursor: pointer; }
.curriculum-item.clickable:hover { background: var(--bg); }
.ci-icon {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; color: var(--text-muted); flex-shrink: 0;
}
.ci-icon.done { background: var(--success); border-color: var(--success); color: var(--white); }
.ci-icon.active { background: var(--primary); border-color: var(--primary); color: var(--white); }
.ci-text { flex: 1; }
.ci-name { font-size: .88rem; font-weight: 500; }
.ci-sub { font-size: .78rem; color: var(--text-muted); margin-top: 1px; }
.ci-badge { font-size: .75rem; font-weight: 600; color: var(--primary); }

/* ===== SIDEBAR ===== */
.sidebar { position: sticky; top: 76px; }
.sidebar-thumb { position: relative; padding-top: 56.25%; background: #e2e8f0; overflow: hidden; }
.sidebar-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sidebar-body { padding: 1.2rem; }
.sidebar-free { font-size: 1.6rem; font-weight: 800; color: var(--success); margin-bottom: 1rem; }
.sidebar-includes { margin-top: 1rem; }
.sidebar-includes h4 { font-size: .88rem; font-weight: 700; margin-bottom: .6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.include-item { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--text-muted); padding: .3rem 0; }
.include-item i { width: 16px; text-align: center; color: var(--primary); }

/* ===== CERTIFICATE PAGE ===== */
.cert-page { min-height: calc(100vh - 60px); padding: 3rem 1.5rem; }
.cert-inner { max-width: 780px; margin: 0 auto; }
.cert-page-title { text-align: center; margin-bottom: 2rem; }
.cert-page-title h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: .4rem; }
.cert-page-title p { color: var(--text-muted); }

.cert-locked-card { text-align: center; padding: 3rem 2rem; }
.locked-icon { width: 72px; height: 72px; border-radius: 50%; background: #fef3c7; color: #d97706; font-size: 1.8rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 1.2rem; }
.cert-locked-card h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: .5rem; }
.cert-locked-card p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .95rem; }

.cert-form-card { padding: 2rem; }
.cert-form-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.2rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.form-group input {
  width: 100%; padding: .65rem .9rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .92rem; outline: none; transition: border .15s;
  font-family: inherit;
}
.form-group input:focus { border-color: var(--primary); }
.form-msg { padding: .7rem .9rem; border-radius: var(--radius); font-size: .88rem; font-weight: 600; margin-bottom: .8rem; display: none; }
.form-msg.success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.form-msg.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* ===== CERTIFICATE CANVAS ===== */
.cert-preview-section { display: none; margin-top: 2rem; }
.cert-preview-section.visible { display: block; }
.cert-action-bar { display: flex; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cert-canvas-wrap { border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-lg); }
canvas#certificate-canvas { display: block; width: 100%; height: auto; }

/* ===== FOOTER ===== */
.footer { background: var(--white); border-top: 1px solid var(--border); padding: 2rem 1.5rem; }
.footer-inner { max-width: 1160px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-brand { font-weight: 700; font-size: .95rem; }
.footer-brand span { color: var(--primary); }
.footer-copy { font-size: .83rem; color: var(--text-muted); }
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a { font-size: .83rem; color: var(--text-muted); transition: color .15s; }
.footer-links a:hover { color: var(--primary); }

/* ===== ADMIN ===== */
.admin-wrap { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.admin-header h1 { font-size: 1.4rem; font-weight: 800; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-box { background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem; }
.stat-box .num { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.stat-box .lbl { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }
.table-wrap { background: var(--white); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table-head { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.table-head h2 { font-size: 1rem; font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg); padding: .7rem 1rem; text-align: left; font-size: .8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .88rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
.cert-pill { font-family: monospace; font-size: .78rem; background: var(--primary-light); color: var(--primary); padding: .2rem .5rem; border-radius: 4px; font-weight: 700; }

/* ===== QUIZ OVERLAY ===== */
.quiz-overlay {
  display: none;
  position: absolute; inset: 0; z-index: 50;
  background: rgba(15,23,42,.88);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  border-radius: 10px;
}
.quiz-overlay.active { display: flex; }
.quiz-box {
  background: var(--white); border-radius: 12px;
  padding: 2rem 1.75rem; width: calc(100% - 2rem); max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  animation: quizIn .25s ease;
}
@keyframes quizIn { from { transform: scale(.92); opacity:0; } to { transform: scale(1); opacity:1; } }
.quiz-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--primary-light); color: var(--primary);
  font-size: .75rem; font-weight: 700; padding: .3rem .7rem;
  border-radius: 99px; margin-bottom: .9rem; letter-spacing: .3px;
  text-transform: uppercase;
}
.quiz-question { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 1.2rem; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: .55rem; margin-bottom: 1rem; }
.quiz-opt {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-radius: 8px;
  border: 2px solid var(--border); background: var(--bg);
  cursor: pointer; transition: all .15s; font-size: .92rem; font-weight: 500;
}
.quiz-opt:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.quiz-opt.correct { border-color: var(--success); background: var(--success-bg); color: var(--success); pointer-events: none; }
.quiz-opt.wrong { border-color: var(--danger); background: #fef2f2; color: var(--danger); pointer-events: none; }
.quiz-opt.disabled { pointer-events: none; opacity: .5; }
.quiz-opt-letter {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--border); display: flex; align-items: center;
  justify-content: center; font-size: .75rem; font-weight: 800;
}
.quiz-feedback {
  padding: .65rem .9rem; border-radius: 8px; font-size: .88rem; font-weight: 600;
  margin-bottom: .8rem; display: none;
}
.quiz-feedback.correct { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.quiz-feedback.wrong   { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* No-seek message */
.seek-block-msg {
  display: none; position: absolute; bottom: 56px; left: 50%; transform: translateX(-50%);
  background: rgba(220,38,38,.9); color: #fff; padding: .45rem 1rem;
  border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; z-index: 40;
}
.seek-block-msg.show { display: block; animation: fadeOut 2s forwards; }
@keyframes fadeOut { 0%,70%{opacity:1} 100%{opacity:0} }

/* ===== LOGIN / SIGNUP ===== */
.login-wrap { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-box { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-icon { width: 52px; height: 52px; border-radius: 10px; background: var(--primary-light); color: var(--primary); font-size: 1.3rem; display: flex; align-items: center; justify-content: center; margin-bottom: 1.2rem; }
.login-box h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: .3rem; }
.login-box p { color: var(--text-muted); font-size: .88rem; margin-bottom: 1.5rem; }
.login-err { color: var(--danger); font-size: .83rem; margin-top: .5rem; display: none; }

/* Password eye toggle */
.input-eye-wrap { position: relative; }
.input-eye-wrap input { padding-right: 2.5rem !important; }
.eye-btn {
  position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); font-size: .9rem;
  padding: 0; line-height: 1; cursor: pointer;
}
.eye-btn:hover { color: var(--primary); }

/* Nav user (logged-in state) */
.nav-user {
  display: flex; align-items: center; gap: .5rem;
  font-size: .88rem; font-weight: 600; color: var(--text);
}
.nav-user i.fa-circle-user { font-size: 1.1rem; color: var(--primary); }
.nav-username { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-nav-logout {
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--bg); border: 1.5px solid var(--border);
  color: var(--text-muted); font-size: .82rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s;
}
.btn-nav-logout:hover { background: #fef2f2; border-color: var(--danger); color: var(--danger); }

/* ===== LANGUAGE SWITCHER ===== */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  margin-left: .5rem;
}
.lang-btn {
  background: transparent;
  border: none;
  padding: .28rem .65rem;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  letter-spacing: .3px;
}
.lang-btn:hover { color: var(--primary); }
.lang-btn.lang-active {
  background: var(--primary);
  color: var(--white);
}

/* RTL adjustments */
[dir="rtl"] .nav-inner { flex-direction: row-reverse; }
[dir="rtl"] .nav-links { flex-direction: row-reverse; }
[dir="rtl"] .breadcrumb { flex-direction: row-reverse; }
[dir="rtl"] .course-meta-row { flex-direction: row-reverse; }
[dir="rtl"] .include-item { flex-direction: row-reverse; }
[dir="rtl"] .feature-icon { margin-right: 0; }
[dir="rtl"] .ci-icon { margin-right: 0; margin-left: 0; }
[dir="rtl"] .footer-inner { flex-direction: row-reverse; }
[dir="rtl"] .cert-action-bar { flex-direction: row-reverse; }
[dir="rtl"] .progress-label { flex-direction: row-reverse; }
[dir="rtl"] .form-group input { text-align: right; }
[dir="rtl"] .admin-header { flex-direction: row-reverse; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] .login-box { text-align: right; }
[dir="rtl"] .stat-box { text-align: right; }

/* ===== RESPONSIVE ===== */
@media (max-width: 860px) {
  .course-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}
@media (max-width: 560px) {
  .nav-links .hide-mobile { display: none; }
  .footer-inner { flex-direction: column; text-align: center; }
}
