/* ==========================================================================
   GREAT KEZINO SCHOOLS — ENTERPRISE PORTAL & CBT STYLES
   Production-ready styling for 7 Roles, CBT Engine, KEZINO AI & SMS Dashboard
   ========================================================================== */

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

:root {
  --portal-bg: #070d18;
  --portal-card-bg: #0d1a2d;
  --portal-card-alt: #11223b;
  --portal-card-border: rgba(255, 255, 255, 0.08);
  --portal-header-bg: #0a1526;
  --portal-sidebar-bg: #070e1b;
  
  --primary-navy: #0f2147;
  --accent-gold: #d99216;
  --accent-gold-light: #f5ab2b;
  --accent-gold-bg: rgba(217, 146, 22, 0.12);
  
  --success-green: #10b981;
  --success-green-bg: rgba(16, 185, 129, 0.12);
  --danger-red: #ef4444;
  --danger-red-bg: rgba(239, 68, 68, 0.12);
  --info-blue: #3b82f6;
  --info-blue-bg: rgba(59, 130, 246, 0.12);
  --purple-accent: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.12);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-portal: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-serif: 'Cinzel', serif;
}

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

body.portal-body {
  font-family: var(--font-portal);
  background-color: var(--portal-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   1. Portal Top Navigation Bar & Global Header
   -------------------------------------------------------------------------- */
.p-header {
  background: var(--portal-header-bg);
  border-bottom: 1px solid var(--portal-card-border);
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.p-header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.p-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
}

.p-logo-badge {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-navy), #060d1a);
  border: 1.5px solid var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold);
  font-size: 1.25rem;
}

.p-brand-text {
  display: flex;
  flex-direction: column;
}

.p-brand-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  color: #fff;
  line-height: 1.1;
}

.p-brand-tag {
  font-size: 0.6875rem;
  color: var(--accent-gold);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.p-header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Role Selector Pill */
.role-badge-selector {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--portal-card-border);
  padding: 0.4rem 0.875rem;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.role-badge-selector:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-gold);
}

.role-icon-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.current-role-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-main);
}

.role-dropdown-menu {
  position: absolute;
  top: 75px;
  right: 1.75rem;
  width: 320px;
  background: var(--portal-card-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  padding: 0.75rem;
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 200;
  animation: pFadeIn 0.2s ease;
}

.role-dropdown-menu.open {
  display: flex;
}

.role-menu-header {
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.5rem 0.75rem;
  letter-spacing: 0.08em;
}

.role-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  font-family: inherit;
}

.role-menu-item:hover, .role-menu-item.active {
  background: rgba(217, 146, 22, 0.15);
  color: #fff;
}

.role-menu-item.active .role-title {
  color: var(--accent-gold-light);
  font-weight: 700;
}

.role-avatar-chip {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-navy);
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.role-info-wrap {
  display: flex;
  flex-direction: column;
  margin-left: 0.625rem;
  flex: 1;
}

.role-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.role-holder {
  font-size: 0.6875rem;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   2. Main Dashboard Layout (Sidebar + Content Viewport)
   -------------------------------------------------------------------------- */
.p-main-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  min-height: calc(100vh - 70px);
}

/* Sidebar Navigation */
.p-sidebar {
  background: var(--portal-sidebar-bg);
  border-right: 1px solid var(--portal-card-border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.p-sidebar-profile {
  background: var(--portal-card-bg);
  border: 1px solid var(--portal-card-border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.p-profile-pic {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-gold), #b8770b);
  color: #060d1a;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.p-profile-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.p-profile-name {
  font-weight: 700;
  font-size: 0.875rem;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.p-profile-role {
  font-size: 0.6875rem;
  color: var(--accent-gold-light);
  font-weight: 600;
}

.p-profile-id {
  font-size: 0.6875rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.p-nav-group-title {
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  padding: 0.5rem 0.75rem 0.25rem 0.75rem;
}

.p-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  position: relative;
}

.p-nav-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  transition: color 0.15s;
}

.p-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.p-nav-item:hover svg {
  color: var(--accent-gold);
}

.p-nav-item.active {
  background: rgba(217, 146, 22, 0.14);
  color: var(--accent-gold-light);
  border: 1px solid rgba(217, 146, 22, 0.3);
  font-weight: 700;
}

.p-nav-item.active svg {
  color: var(--accent-gold);
}

.p-nav-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
}

.badge-ai {
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: #fff;
}

.badge-cbt {
  background: var(--danger-red);
  color: #fff;
}

/* --------------------------------------------------------------------------
   3. Content Viewport & Screens
   -------------------------------------------------------------------------- */
.p-content-viewport {
  padding: 2rem;
  background: radial-gradient(circle at top right, rgba(15, 33, 71, 0.4) 0%, transparent 60%);
  overflow-y: auto;
}

.p-view-screen {
  display: none;
  animation: pFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.p-view-screen.active {
  display: block;
}

.p-screen-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.p-screen-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.p-screen-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.p-screen-actions {
  display: flex;
  gap: 0.75rem;
}

/* Metric Cards Grid */
.p-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.p-metric-card {
  background: var(--portal-card-bg);
  border: 1px solid var(--portal-card-border);
  border-radius: 14px;
  padding: 1.35rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

.p-metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(217, 146, 22, 0.4);
}

.p-metric-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.metric-gold { background: var(--accent-gold-bg); color: var(--accent-gold); }
.metric-green { background: var(--success-green-bg); color: var(--success-green); }
.metric-blue { background: var(--info-blue-bg); color: var(--info-blue); }
.metric-purple { background: var(--purple-bg); color: var(--purple-accent); }

.p-metric-val {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.p-metric-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.p-metric-sub {
  font-size: 0.6875rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Standard Card Panels */
.p-card {
  background: var(--portal-card-bg);
  border: 1px solid var(--portal-card-border);
  border-radius: 16px;
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.p-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--portal-card-border);
  padding-bottom: 1rem;
}

.p-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

/* --------------------------------------------------------------------------
   4. KEZINO AI TUTOR CHAT MODULE
   -------------------------------------------------------------------------- */
.kezino-ai-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 180px);
  min-height: 600px;
  background: var(--portal-card-bg);
  border: 1px solid var(--portal-card-border);
  border-radius: 16px;
  overflow: hidden;
}

.ai-sidebar {
  background: var(--portal-card-alt);
  border-right: 1px solid var(--portal-card-border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-badge-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
}

.ai-spark-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.ai-prompts-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ai-preset-chip {
  padding: 0.625rem 0.875rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--portal-card-border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.ai-preset-chip:hover {
  background: rgba(217, 146, 22, 0.15);
  color: #fff;
  border-color: rgba(217, 146, 22, 0.4);
}

.ai-chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ai-messages-box {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ai-msg {
  display: flex;
  gap: 1rem;
  max-width: 85%;
}

.ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.ai-msg.bot .ai-msg-avatar {
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: #fff;
}

.ai-msg.user .ai-msg-avatar {
  background: var(--accent-gold);
  color: #060d1a;
}

.ai-msg-bubble {
  padding: 1rem 1.25rem;
  border-radius: 14px;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.ai-msg.bot .ai-msg-bubble {
  background: var(--portal-card-alt);
  border: 1px solid var(--portal-card-border);
  color: var(--text-main);
}

.ai-msg.user .ai-msg-bubble {
  background: var(--primary-navy);
  color: #fff;
  border: 1px solid rgba(217, 146, 22, 0.3);
}

.ai-input-area {
  padding: 1.25rem;
  border-top: 1px solid var(--portal-card-border);
  background: var(--portal-card-alt);
  display: flex;
  gap: 0.75rem;
}

.ai-text-input {
  flex: 1;
  background: var(--portal-bg);
  border: 1.5px solid var(--portal-card-border);
  border-radius: 10px;
  padding: 0.875rem 1.25rem;
  color: #fff;
  font-size: 0.9375rem;
}

.ai-text-input:focus {
  border-color: var(--accent-gold);
  outline: none;
}

/* --------------------------------------------------------------------------
   5. CBT EXAMINATION ENGINE SCREEN
   -------------------------------------------------------------------------- */
.cbt-screen-wrapper {
  background: var(--portal-card-bg);
  border: 1px solid var(--portal-card-border);
  border-radius: 16px;
  overflow: hidden;
}

.cbt-header-bar {
  background: var(--portal-card-alt);
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--portal-card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cbt-exam-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.cbt-timer-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--danger-red-bg);
  border: 1.5px solid var(--danger-red);
  color: #f87171;
  padding: 0.5rem 1.25rem;
  border-radius: 30px;
  font-weight: 800;
  font-family: var(--font-mono);
  font-size: 1.15rem;
}

.cbt-exam-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 520px;
}

.cbt-question-area {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cbt-q-number {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.cbt-q-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.cbt-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 2rem;
}

.cbt-option-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid var(--portal-card-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cbt-option-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(217, 146, 22, 0.4);
}

.cbt-option-item.selected {
  background: rgba(217, 146, 22, 0.15);
  border-color: var(--accent-gold);
  color: #fff;
}

.cbt-option-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.875rem;
}

.cbt-option-item.selected .cbt-option-letter {
  background: var(--accent-gold);
  color: #060d1a;
}

.cbt-nav-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--portal-card-border);
  padding-top: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Question Palette Sidebar */
.cbt-palette-sidebar {
  background: var(--portal-card-alt);
  border-left: 1px solid var(--portal-card-border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.cbt-palette-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.cbt-palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.cbt-palette-num {
  aspect-ratio: 1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--portal-card-border);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.cbt-palette-num:hover {
  border-color: var(--accent-gold);
}

.cbt-palette-num.answered {
  background: var(--success-green-bg);
  border-color: var(--success-green);
  color: #34d399;
}

.cbt-palette-num.flagged {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #fbbf24;
}

.cbt-palette-num.current {
  background: var(--accent-gold);
  color: #060d1a;
  font-weight: 800;
}

/* --------------------------------------------------------------------------
   6. Data Tables & Gradebook Spreadsheet Styles
   -------------------------------------------------------------------------- */
.p-table-responsive {
  width: 100%;
  overflow-x: auto;
}

.p-data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.p-data-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--portal-card-border);
}

.p-data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.p-data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.score-input {
  width: 60px;
  background: var(--portal-bg);
  border: 1px solid var(--portal-card-border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  color: #fff;
  font-weight: 700;
  text-align: center;
  font-family: var(--font-mono);
}

.score-input:focus {
  border-color: var(--accent-gold);
  outline: none;
}

/* Status Badges */
.badge-status {
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-status.paid {
  background: var(--success-green-bg);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status.pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Animations */
@keyframes pFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .p-main-layout {
    grid-template-columns: 1fr;
  }
  .p-sidebar {
    display: none;
  }
  .p-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .cbt-exam-grid {
    grid-template-columns: 1fr;
  }
  .kezino-ai-container {
    grid-template-columns: 1fr;
  }
  .ai-sidebar {
    display: none;
  }
}

@media (max-width: 640px) {
  .p-metrics-grid {
    grid-template-columns: 1fr;
  }
  .p-content-viewport {
    padding: 1rem;
  }
}
