/* Red-Cherry Training Academy — LMS
   Shared stylesheet for login + admin/instructor/student portals */

:root {
  --rc-green: #06887F;
  --rc-green-dark: #056f68;
  --rc-red: #ED3237;
  --rc-red-dark: #c92428;
  --rc-dark: #16201f;
  --bg: #f4f6f6;
  --card: #ffffff;
  --border: #e3e8e7;
  --text: #1c2624;
  --text-muted: #6b7674;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--rc-green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }
ul { padding-left: 1.2em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  font-size: .92rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--rc-green); color: #fff; }
.btn-primary:hover { background: var(--rc-green-dark); text-decoration: none; }
.btn-red { background: var(--rc-red); color: #fff; }
.btn-red:hover { background: var(--rc-red-dark); text-decoration: none; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--rc-green); color: var(--rc-green); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-danger { background: #fff; border-color: #f3c2c2; color: var(--rc-red); }
.btn-danger:hover { background: #fff5f5; text-decoration: none; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .92rem; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--rc-green); }
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
legend { font-weight: 700; padding: 0 6px; font-size: .9rem; }

/* ---------- Alerts / badges ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; }
.alert-success { background: #e7f7ef; color: #146c43; border: 1px solid #bfe8d3; }
.alert-error { background: #fdeaea; color: var(--rc-red-dark); border: 1px solid #f3c2c2; }
.alert-info { background: #eaf6f5; color: var(--rc-green-dark); border: 1px solid #bfe0dd; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge-success { background: #e7f7ef; color: #146c43; }
.badge-danger { background: #fdeaea; color: var(--rc-red-dark); }
.badge-info { background: #eaf1fb; color: #2660c4; }
.badge-muted { background: #eef0f0; color: var(--text-muted); }
.badge-warning { background: #fff5e0; color: #8a6100; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; align-items: center; gap: 14px; }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #eaf6f5; color: var(--rc-green); flex-shrink: 0; }
.stat-card .stat-icon .icon { width: 22px; height: 22px; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
tbody tr:hover { background: #fafcfc; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions a, .row-actions button { color: var(--text-muted); }
.row-actions a:hover { color: var(--rc-green); }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .icon { width: 40px; height: 40px; margin-bottom: 10px; opacity: .5; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; font-size: .85rem; }
.page-link.disabled { color: #c4cac9; }

/* ---------- Layout: sidebar + topbar (admin/instructor/student) ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: var(--rc-dark); color: #cfd6d4; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand img { height: 34px; }
.sidebar-brand .name { color: #fff; font-weight: 800; font-size: .95rem; line-height: 1.2; }
.sidebar-brand .role-tag { font-size: .7rem; color: var(--rc-green); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  color: #cfd6d4; font-size: .88rem; font-weight: 600; margin-bottom: 3px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: var(--rc-green); color: #fff; }
.sidebar-nav .icon { width: 18px; height: 18px; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot a { display: flex; align-items: center; gap: 10px; color: #cfd6d4; font-size: .85rem; font-weight: 600; }
.sidebar-foot a:hover { color: #fff; text-decoration: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.topbar-user .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--rc-green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.nav-toggle-btn { display: none; background: none; border: none; cursor: pointer; color: var(--text); }

.content { padding: 26px 28px; flex: 1; }
.content-narrow { max-width: 760px; }

/* ---------- Login page ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--rc-dark), #0c1413); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .brand-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; }
.login-card .brand-row img { height: 40px; }
.login-card h1 { text-align: center; font-size: 1.2rem; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: .85rem; margin-bottom: 26px; }
.login-demo { margin-top: 22px; padding: 14px; background: #f4f8f7; border-radius: 8px; font-size: .76rem; color: var(--text-muted); line-height: 1.6; }

/* ---------- Course / material / assessment cards ---------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.course-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.course-card .code { font-size: .72rem; font-weight: 700; color: var(--rc-green); text-transform: uppercase; letter-spacing: .05em; }
.course-card h3 { font-size: 1.05rem; }
.course-card .desc { color: var(--text-muted); font-size: .85rem; flex: 1; }
.course-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }

.material-row, .assessment-row {
  display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
}
.material-row .m-icon, .assessment-row .m-icon {
  width: 40px; height: 40px; border-radius: 8px; background: #eaf6f5; color: var(--rc-green);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.material-row .m-info, .assessment-row .m-info { flex: 1; min-width: 0; }
.material-row .m-info h4, .assessment-row .m-info h4 { margin: 0 0 2px; font-size: .95rem; }
.material-row .m-meta, .assessment-row .m-meta { font-size: .78rem; color: var(--text-muted); }

/* ---------- Exam-taking ---------- */
.exam-timer { position: sticky; top: 0; z-index: 4; background: var(--rc-red); color: #fff; padding: 12px 20px; border-radius: 10px; display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; }
.question-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.question-card .q-num { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.question-card .q-text { font-size: 1rem; font-weight: 600; margin: 6px 0 14px; }
.option-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.option-row:hover { border-color: var(--rc-green); }
.option-row input { width: auto; }
.option-row.selected { border-color: var(--rc-green); background: #eaf6f5; }

/* ---------- Certificate preview ---------- */
.cert-preview-frame { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.cert-preview-frame iframe { width: 100%; height: 560px; border: none; }

/* ---------- Toggle switches (activate exam) ---------- */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 999px; transition: .2s; }
.toggle-slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--rc-green); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }
.toggle-switch input:disabled + .toggle-slider { opacity: .5; cursor: not-allowed; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.small { font-size: .82rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; top: 0; z-index: 50; transition: left .2s; box-shadow: 0 0 0 100vw rgba(0,0,0,0); }
  .sidebar.open { left: 0; box-shadow: 20px 0 60px rgba(0,0,0,.3); }
  .nav-toggle-btn { display: block; }
  .field-row { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .topbar { padding: 12px 16px; }
}
