/* =============================================
   NusaLMS — Global Styles
   ============================================= */

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

:root {
  --clr-primary:    #13A89E;
  --clr-primary-dk: #244887;
  --clr-primary-lt: #e6f7f6;
  --clr-success:    #16a34a;
  --clr-success-lt: #dcfce7;
  --clr-danger:     #dc2626;
  --clr-danger-lt:  #fee2e2;
  --clr-warning:    #d97706;
  --clr-warning-lt: #fef3c7;
  --clr-bg:         #f8fafc;
  --clr-surface:    #ffffff;
  --clr-border:     #e2e8f0;
  --clr-text:       #1e293b;
  --clr-muted:      #64748b;
  --sidebar-w:      250px;
  --topbar-h:       64px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12);
  --transition:     .2s ease;
  --font:           'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
  font-size: 14px;
}

/* ══════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #13A89E 0%, #244887 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
}

.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  font-size: 1.2rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.12);
  letter-spacing: -.02em;
}

.sidebar__logo { font-size: 1.8rem; }
.sidebar__logo-img { height: 32px; width: auto; }

.sidebar__nav {
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.nav-link.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  font-weight: 600;
}

.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }

/* ══════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════ */
.layout {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.layout.full-width { margin-left: 0; }

/* ══════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow);
}

.topbar__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--clr-text);
}

.btn-toggle-sidebar {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--clr-muted);
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.btn-toggle-sidebar:hover { background: var(--clr-bg); }

/* ══════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════ */
.main-content {
  flex: 1;
  padding: 28px;
  width: 100%;
}

/* ══════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════ */
.card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--clr-border);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--clr-text);
}

/* ══════════════════════════════════════════════
   STATS GRID
   ══════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card__icon { font-size: 2rem; }
.stat-card__value { font-size: 1.8rem; font-weight: 800; color: var(--clr-primary); }
.stat-card__label { font-size: .82rem; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 500; }

/* ══════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}

thead { background: var(--clr-bg); }

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--clr-border);
}

th {
  font-weight: 600;
  color: var(--clr-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

td { color: var(--clr-text); }

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* Action buttons in table */
td:last-child {
  white-space: nowrap;
}

td .btn + .btn { margin-left: 4px; }

/* ══════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.3;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-dk); }
.btn-success   { background: var(--clr-success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: var(--clr-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--clr-surface); color: var(--clr-text); border: 1px solid var(--clr-border); }
.btn-secondary:hover { background: var(--clr-bg); }

.btn-sm { padding: 6px 12px; font-size: .78rem; border-radius: var(--radius-sm); }

/* ══════════════════════════════════════════════
   BADGE
   ══════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: .01em;
}

.badge-admin      { background: #e6f7f6; color: #0e7e76; }
.badge-pelanggan  { background: #dbeafe; color: #1d4ed8; }
.badge-instructor { background: #dbeafe; color: #1d4ed8; }
.badge-student    { background: #d1fae5; color: #065f46; }
.badge-published  { background: #dcfce7; color: #166534; }
.badge-draft      { background: #fef9c3; color: #854d0e; }
.badge-archived   { background: #f1f5f9; color: #475569; }

/* ══════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: .84rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--clr-text);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-family: var(--font);
  color: var(--clr-text);
  background: var(--clr-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

input[type="date"] {
  min-height: 42px;
  cursor: pointer;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(19,168,158,.12);
}

input[type="password"] {
  letter-spacing: .1em;
}

/* Password toggle eye */
.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrapper input {
  padding-right: 44px;
}

.btn-eye {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: .7;
  transition: opacity var(--transition);
}

.btn-eye:hover { opacity: 1; }

input::placeholder, textarea::placeholder { color: #94a3b8; }

textarea { resize: vertical; min-height: 80px; }

input[type="file"] { padding: 8px 12px; }

/* ══════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 200;
  padding: 40px 20px;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--clr-surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  animation: slideIn .25s ease;
  margin: auto 0;
}

.modal--wide {
  max-width: 780px;
}

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

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--clr-border);
}

.modal__title { font-size: 1.05rem; font-weight: 700; }

.modal__close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--clr-muted);
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.modal__close:hover { background: var(--clr-bg); color: var(--clr-danger); }

.modal__body { padding: 24px; }

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ══════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 300;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .3s ease;
  min-width: 260px;
  max-width: 380px;
}

@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.toast-success { background: var(--clr-success); }
.toast-error   { background: var(--clr-danger);  }
.toast-warning { background: var(--clr-warning); }

/* ══════════════════════════════════════════════
   LOADING & EMPTY STATE
   ══════════════════════════════════════════════ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--clr-muted);
  gap: 12px;
  font-size: .92rem;
}

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* Spinner kecil untuk tombol loading */
.spinner-sm {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--clr-muted);
}

.empty-state__icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state__text { font-size: .92rem; }

/* ══════════════════════════════════════════════
   PROGRESS BAR
   ══════════════════════════════════════════════ */
.progress-bar {
  background: var(--clr-border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  min-width: 80px;
}

.progress-bar__fill {
  height: 100%;
  background: var(--clr-primary);
  border-radius: 999px;
  transition: width .4s ease;
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 260px;
  }

  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .layout { margin-left: 0; }

  .main-content { padding: 16px; }

  .topbar { padding: 0 16px; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  .card { padding: 16px; }

  .card__header { flex-direction: column; align-items: flex-start; }

  .modal {
    max-width: 100%;
    margin: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    align-self: flex-end;
  }

  .modal-overlay { padding: 0; align-items: flex-end; }

  table { font-size: .82rem; }
  th, td { padding: 8px 10px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card__value { font-size: 1.5rem; }
}

/* ══════════════════════════════════════════════
   UTILITY
   ══════════════════════════════════════════════ */
code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  background: var(--clr-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .82em;
  color: var(--clr-primary-dk);
}

hr {
  border: none;
  border-top: 1px solid var(--clr-border);
  margin: 16px 0;
}

details summary {
  cursor: pointer;
  color: var(--clr-primary);
  font-size: .85rem;
  font-weight: 500;
}

details summary:hover { text-decoration: underline; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 10px; }
::-webkit-scrollbar-track { background: var(--clr-bg); border-radius: 5px; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Form section divider */
.form-section {
  margin: 20px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--clr-border);
  font-size: .82rem;
  font-weight: 700;
  color: var(--clr-primary);
  text-transform: uppercase;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Settings tabs */
.settings-tab {
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: .88rem;
  font-weight: 500;
  color: var(--clr-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.settings-tab:hover { color: var(--clr-text); background: var(--clr-bg); }
.settings-tab.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); font-weight: 600; }

.form-row {
  display: grid;
  gap: 12px;
  margin-bottom: 4px;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Truncated cell */
.cell-truncate {
  display: block;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

/* Timeline tracking */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--clr-primary);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
  content: '';
  position: absolute;
  left: -23px;
  top: 6px;
  width: 14px;
  height: 14px;
  background: var(--clr-primary);
  border-radius: 50%;
  border: 3px solid var(--clr-primary-lt);
}

.timeline-date {
  font-weight: 700;
  color: var(--clr-primary);
  font-size: .88rem;
  margin-bottom: 2px;
}

.timeline-desc {
  color: var(--clr-text);
  font-size: .88rem;
}

/* ══════════════════════════════════════════════
   AUTH PAGES (Login, Reset Password)
   ══════════════════════════════════════════════ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #13A89E 0%, #244887 100%);
}

.auth-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.auth-logo {
  margin-bottom: 28px;
  text-align: center;
}

.auth-logo img {
  height: 52px;
  width: auto;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 48px rgba(0,0,0,.2);
}

.auth-card__brand {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card__brand .icon { font-size: 3.2rem; }
.auth-card__brand h1 { font-size: 1.5rem; margin-top: 10px; color: var(--clr-text); font-weight: 800; }
.auth-card__brand p { color: var(--clr-muted); font-size: .88rem; margin-top: 4px; }

.auth-card .form-group { margin-bottom: 20px; }

.auth-card label {
  font-size: .85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
  display: block;
}

.auth-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  font-size: .9rem;
  font-family: var(--font);
  background: var(--clr-bg);
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.auth-card input:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(19,168,158,.12);
  background: #fff;
}

.auth-card .btn {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: .95rem;
  margin-top: 8px;
}

.auth-card__footer {
  text-align: center;
  margin-top: 22px;
  font-size: .84rem;
  color: var(--clr-muted);
}

.auth-card__footer a {
  color: var(--clr-primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-card__footer a:hover { text-decoration: underline; }

.auth-error {
  color: var(--clr-danger);
  font-size: .84rem;
  margin-top: 10px;
  text-align: center;
  display: none;
}

.auth-success {
  color: var(--clr-success);
  font-size: .84rem;
  margin-top: 10px;
  text-align: center;
  display: none;
}

.auth-demo {
  background: var(--clr-bg);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 24px;
  font-size: .8rem;
  color: #475569;
  line-height: 1.7;
  border: 1px solid var(--clr-border);
}

.auth-demo strong {
  display: block;
  margin-bottom: 6px;
  color: var(--clr-text);
  font-size: .82rem;
}

.auth-invalid {
  text-align: center;
  color: var(--clr-muted);
  padding: 20px 0;
}

.auth-invalid .icon { font-size: 3.5rem; margin-bottom: 16px; }
.auth-invalid h2 { color: var(--clr-danger); margin-bottom: 8px; }

/* ══════════════════════════════════════════════
   AGREEMENT PAGE
   ══════════════════════════════════════════════ */
.agreement-page {
  background: var(--clr-bg);
  padding: 24px;
  display: block;
  min-height: 100vh;
}

.agreement-container {
  max-width: 720px;
  margin: 0 auto;
}

.agreement-header {
  text-align: center;
  margin-bottom: 28px;
}

.agreement-header .icon { font-size: 2.8rem; }
.agreement-header h1 { font-size: 1.4rem; margin-top: 10px; font-weight: 700; }
.agreement-header p { color: var(--clr-muted); font-size: .88rem; margin-top: 4px; }

.signer-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: .9rem;
  color: #1e40af;
}

.signer-info strong { color: #1d4ed8; }

.sign-section {
  background: var(--clr-surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--clr-border);
}

.sign-section h3 { margin-bottom: 18px; font-size: 1rem; }

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 22px;
  padding: 14px 16px;
  background: var(--clr-bg);
  border-radius: 8px;
  border: 1px solid var(--clr-border);
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--clr-primary);
}

.checkbox-group label {
  font-size: .88rem;
  color: #334155;
  cursor: pointer;
  line-height: 1.5;
  font-weight: 400;
}

.canvas-wrapper {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 12px;
  background: #fff;
  transition: border-color var(--transition);
}

.canvas-wrapper:hover { border-color: var(--clr-primary); }

.canvas-wrapper canvas {
  display: block;
  width: 100%;
  height: 200px;
  cursor: crosshair;
  touch-action: none;
}

.canvas-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.canvas-controls label { margin-bottom: 0; }

.agreement-success {
  text-align: center;
  padding: 60px 20px;
}

.agreement-success .icon { font-size: 4rem; margin-bottom: 16px; }
