/* ============================================================
   KIDLIN School of AI — Member Portal Styles
   Cream/blue design language consistent with main site.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Corben:wght@400;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --navy: #081026;            /* Matches --color-corp-navy */
  --navy-light: #16223f;
  --blue: #00579f;            /* Matches --color-primary */
  --blue-light: #004480;      /* Matches --color-primary-dark */
  --blue-pale: rgba(0, 87, 159, 0.07); /* Matches --color-primary-light */
  --cream: #fffcf5;           /* Matches --color-bg */
  --cream-dark: #f5f3ee;      /* Matches --color-subtle */
  --white: #ffffff;
  --text-primary: #1a1a1a;    /* Matches --color-text */
  --text-secondary: #6b7280;  /* Matches --color-muted */
  --text-muted: #9ca3af;
  --border: #e8e3d8;          /* Matches --color-border */
  --border-light: #f5f3ee;
  --success: #15803d;
  --success-bg: #dcfce7;
  --error: #b91c1c;
  --error-bg: #fee2e2;
  --warning: #a16207;
  --warning-bg: #fef9c3;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 2px 16px rgba(0,0,0,0.06); /* Matches --shadow-card */
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10); /* Matches --shadow-hover */
  --radius: 14px;             /* Matches --radius-md */
  --radius-sm: 8px;           /* Matches --radius-sm */
  --radius-lg: 20px;          /* Matches --radius-lg */
  --transition: 0.22s ease;   /* Matches --transition-base */
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background-color: var(--cream);
  background-image: 
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 600' fill='none'%3E%3Cpath d='M-50,50 C200,100 350,-50 550,150 C700,300 650,450 850,500' stroke='%23D4B275' stroke-width='1.8' stroke-opacity='0.18'/%3E%3Cpath d='M-30,80 C220,130 370,-20 570,180 C720,330 670,480 870,530' stroke='%23D4B275' stroke-width='1.4' stroke-opacity='0.12'/%3E%3Cpath d='M-70,20 C180,70 330,-80 530,120 C680,270 630,420 830,470' stroke='%23D4B275' stroke-width='1' stroke-opacity='0.07'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 600' fill='none'%3E%3Cpath d='M850,30 C600,120 450,20 250,250 C100,400 150,550 -50,600' stroke='%23D4B275' stroke-width='1.8' stroke-opacity='0.18'/%3E%3Cpath d='M870,60 C620,150 470,50 270,280 C120,430 170,580 -30,630' stroke='%23D4B275' stroke-width='1.4' stroke-opacity='0.12'/%3E%3Cpath d='M830,0 C580,90 430,-10 230,220 C80,370 130,520 -70,570' stroke='%23D4B275' stroke-width='1' stroke-opacity='0.07'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 600' fill='none'%3E%3Cpath d='M-50,450 C250,350 400,550 650,400 C850,280 800,100 1050,50' stroke='%23D4B275' stroke-width='1.8' stroke-opacity='0.20'/%3E%3Cpath d='M-30,480 C270,380 420,580 670,430 C870,310 820,130 1070,80' stroke='%23D4B275' stroke-width='1.4' stroke-opacity='0.13'/%3E%3Cpath d='M-70,420 C230,320 380,520 630,370 C830,250 780,70 1030,20' stroke='%23D4B275' stroke-width='1' stroke-opacity='0.08'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-position: left 2vw top 5vh, right 1vw top 12vh, right -6vw bottom -4vh;
  background-size: min(78vw, 860px) auto, min(76vw, 840px) auto, min(92vw, 1080px) auto;
  background-attachment: fixed, fixed, fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .auth-title, .modal-header-title, .page-title, .user-name {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-weight: 700;
}

/* ---- Layout ---- */
.portal-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 256px;
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #4f93f5, #1d4ed8);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.logo-text strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}

.logo-text small {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}

.sidebar-user {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f93f5, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info .user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.user-info .user-email {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-section-label {
  padding: 4px 12px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.3);
  font-weight: 600;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(79,147,245,0.15);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav a .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 16px 12px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.5);
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: background var(--transition), color var(--transition);
}

.btn-logout:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
}

/* ---- Main content ---- */
.main-content {
  flex: 1;
  margin-left: 256px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-content {
  flex: 1;
  padding: 32px;
  max-width: 1100px;
  width: 100%;
}

/* ---- Cards ---- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ---- Course cards ---- */
.course-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
  text-decoration: none;
  display: block;
}

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

.course-card-header {
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  padding: 24px 24px 20px;
  position: relative;
  overflow: hidden;
}

.course-card-header::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}

.course-card-header::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(79,147,245,0.12);
}

.course-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(79,147,245,0.2);
  border: 1px solid rgba(79,147,245,0.3);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.course-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.course-dates {
  font-size: 12.5px;
  color: rgba(255,255,255,0.6);
  position: relative;
  z-index: 1;
}

.course-card-body {
  padding: 20px 24px 24px;
}

.course-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.course-meta-row svg { flex-shrink: 0; }

.course-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-active { background: var(--success-bg); color: var(--success); }
.status-upcoming { background: var(--warning-bg); color: var(--warning); }
.status-completed { background: var(--border-light); color: var(--text-muted); }

.course-cta {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-light); }

.btn-secondary {
  background: var(--white);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--cream); }

.btn-blue {
  background: var(--blue);
  color: #fff;
}
.btn-blue:hover { background: #1e40af; }

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-label .required { color: var(--error); margin-left: 2px; }
.form-label .readonly-tag {
  font-size: 10px;
  font-weight: 500;
  background: var(--border-light);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.form-input {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.08);
}

.form-input:disabled,
.form-input[readonly] {
  background: var(--cream);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---- Alerts ---- */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: var(--blue-pale); color: var(--blue); border: 1px solid #bfdbfe; }

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--cream);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 13px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--cream); }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-neutral { background: var(--border-light); color: var(--text-muted); }
.badge-blue { background: var(--blue-pale); color: var(--blue); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 360px;
  margin: 0 auto;
}

/* ---- Stats row ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

/* ---- Profile image ---- */
.profile-image-container {
  position: relative;
  width: 96px;
  height: 96px;
}

.profile-image {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  background: linear-gradient(135deg, #4f93f5, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
}

.profile-image-upload-btn {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 28px;
  height: 28px;
  background: var(--navy);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--white);
  transition: background var(--transition);
}

.profile-image-upload-btn:hover { background: var(--navy-light); }

/* ---- OTP inputs ---- */
.otp-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 28px 0;
}

.otp-input {
  width: 52px;
  height: 60px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--white);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  caret-color: var(--blue);
  font-family: 'Courier New', monospace;
}

.otp-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}

.otp-input.filled {
  border-color: var(--blue);
  background: #f0f4ff;
}

.otp-input.error {
  border-color: var(--error);
  background: var(--error-bg);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---- Login page ---- */
.auth-page {
  min-height: 100vh;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 40px 36px;
  width: 100%;
  max-width: 440px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.auth-logo .logo-mark {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.auth-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 28px;
}

.terms-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}

.terms-row input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

.terms-row label {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  cursor: pointer;
}

.terms-row label a {
  color: var(--blue);
  text-decoration: none;
}

.terms-row label a:hover { text-decoration: underline; }

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- Spinner ---- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---- Divider ---- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ---- Page header ---- */
.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-desc {
  font-size: 14px;
  color: var(--text-muted);
}

/* ---- Grid layouts ---- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .form-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-content { padding: 20px; }
  .auth-card { padding: 28px 24px; }
  .otp-container { gap: 8px; }
  .otp-input { width: 44px; height: 52px; font-size: 20px; }
  .mobile-menu-btn {
    display: flex;
  }
}

/* ---- Mobile menu button ---- */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-secondary);
}

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

.sidebar-overlay.active { display: block; }

/* ---- Toast notifications ---- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  font-weight: 500;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease;
}

.toast-success { border-left: 4px solid var(--success); color: var(--success); }
.toast-error { border-left: 4px solid var(--error); color: var(--error); }
.toast-info { border-left: 4px solid var(--blue); color: var(--blue); }

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