/* ============================================================
   PATHFINDER PORTAL — Shared Styles
   Matches website: charcoal nav, orange #E8491E, Inter font
   ============================================================ */

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

:root {
  --orange:        #E8491E;
  --orange-light:  #FF6B45;
  --orange-dark:   #C23A14;
  --charcoal:      #1C1C1E;
  --charcoal-mid:  #2C2C2E;
  --charcoal-light:#3A3A3C;
  --white:         #FFFFFF;
  --off-white:     #F7F7F7;
  --light-grey:    #EBEBEB;
  --mid-grey:      #999999;
  --dark-grey:     #555555;
  --border:        rgba(0,0,0,0.09);
  --border-dark:   rgba(255,255,255,0.10);
  --shadow:        0 2px 12px rgba(0,0,0,0.07);
  --shadow-h:      0 4px 24px rgba(0,0,0,0.13);
  --r:             8px;
  --r-sm:          5px;

  /* Status colours */
  --present:       #16a34a;
  --present-bg:    #dcfce7;
  --absent-nc:     #dc2626;
  --absent-nc-bg:  #fee2e2;
  --absent-notice: #d97706;
  --absent-notice-bg: #fef3c7;
  --cancelled:     #6b7280;
  --cancelled-bg:  #f3f4f6;
  --scheduled:     #2563eb;
  --scheduled-bg:  #dbeafe;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--off-white);
  color: var(--charcoal);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ---- PORTAL SHELL ---- */
.portal-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 64px 1fr;
  min-height: 100vh;
}

/* ---- TOP NAV ---- */
.topnav {
  grid-column: 1 / -1;
  background: var(--charcoal);
  border-bottom: 3px solid var(--orange);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topnav-logo img {
  height: 30px;
  width: auto;
  display: block;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topnav-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.7);
}

.topnav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--orange);
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topnav-role-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.18rem 0.6rem;
  border-radius: 20px;
  background: rgba(232,73,30,0.25);
  color: var(--orange);
  border: 1px solid rgba(232,73,30,0.35);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btn-logout {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--r-sm);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-logout:hover {
  color: var(--white);
  border-color: rgba(255,255,255,0.35);
}

/* ---- SIDEBAR ---- */
.sidebar {
  background: var(--charcoal-mid);
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
}

.sidebar-section {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  padding: 0.85rem 0.75rem 0.4rem;
  margin-top: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-sm);
  font-size: 0.845rem;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 1px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: var(--white);
}

.nav-item.active {
  background: rgba(232,73,30,0.18);
  color: var(--orange);
  font-weight: 500;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active svg { opacity: 1; }

/* ---- MAIN CONTENT ---- */
.main {
  padding: 1.75rem;
  overflow-y: auto;
}

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

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--charcoal);
}

.page-sub {
  font-size: 0.85rem;
  color: var(--mid-grey);
  margin-top: 0.2rem;
}

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--charcoal);
}

.card-body {
  padding: 1.25rem;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.845rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  text-decoration: none;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: var(--orange);
  color: var(--white);
}
.btn-primary:hover { background: var(--orange-light); transform: translateY(-1px); }

.btn-secondary {
  background: var(--off-white);
  color: var(--charcoal);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--light-grey); }

.btn-ghost {
  background: transparent;
  color: var(--dark-grey);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--off-white); }

.btn-sm {
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.btn-danger:hover { background: #fecaca; }

/* ---- WEEK NAVIGATOR ---- */
.week-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.week-nav-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--charcoal);
  min-width: 180px;
  text-align: center;
}

.week-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dark-grey);
  font-size: 1rem;
  transition: all 0.15s;
}
.week-nav-btn:hover { background: var(--off-white); border-color: var(--charcoal); }

/* ---- SCHEDULE TABLE ---- */
.schedule-wrap {
  overflow-x: auto;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--white);
  box-shadow: var(--shadow);
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.schedule-table th {
  background: var(--charcoal);
  color: rgba(255,255,255,0.75);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.7rem 1rem;
  text-align: left;
  white-space: nowrap;
}

.schedule-table th:first-child {
  color: rgba(255,255,255,0.4);
  width: 90px;
}

.schedule-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.845rem;
  vertical-align: top;
}

.schedule-table tr:last-child td { border-bottom: none; }
.schedule-table tr:hover td { background: var(--off-white); }

.lesson-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.lesson-name {
  font-weight: 600;
  color: var(--charcoal);
  font-size: 0.875rem;
}

.lesson-meta {
  font-size: 0.78rem;
  color: var(--mid-grey);
}

.lesson-instrument {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--orange);
}

.time-cell {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dark-grey);
  white-space: nowrap;
}

.duration-label {
  font-size: 0.72rem;
  color: var(--mid-grey);
  margin-top: 2px;
}

/* ---- STATUS PILLS ---- */
.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.18rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
}

.pill-present       { background: var(--present-bg);       color: var(--present); }
.pill-absent-nc     { background: var(--absent-nc-bg);     color: var(--absent-nc); }
.pill-absent-notice { background: var(--absent-notice-bg); color: var(--absent-notice); }
.pill-cancelled     { background: var(--cancelled-bg);     color: var(--cancelled); }
.pill-scheduled     { background: var(--scheduled-bg);     color: var(--scheduled); }
.pill-online        { background: #ede9fe; color: #7c3aed; }
.pill-trial         { background: #fef3c7; color: #d97706; }
.pill-active        { background: #dcfce7; color: #16a34a; }
.pill-inactive      { background: var(--light-grey); color: var(--mid-grey); }

/* Cancelled lessons row */
tr.lesson-cancelled td { opacity: 0.45; }

/* ---- FILTERS BAR ---- */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-select {
  font-size: 0.82rem;
  font-family: 'Inter', sans-serif;
  padding: 0.48rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--white);
  color: var(--charcoal);
  cursor: pointer;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2rem;
  min-width: 130px;
}

.filter-select:focus { outline: none; border-color: var(--orange); }

/* ---- FORMS ---- */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--charcoal); }
.form-input, .form-select, .form-textarea {
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  padding: 0.62rem 0.85rem;
  border: 1.5px solid var(--light-grey);
  border-radius: var(--r-sm);
  background: var(--off-white);
  color: var(--charcoal);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--orange);
  background: var(--white);
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 0.75rem; color: var(--mid-grey); }
.form-error { font-size: 0.75rem; color: #dc2626; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: var(--r);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-title { font-size: 1rem; font-weight: 700; color: var(--charcoal); }

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--off-white);
  color: var(--dark-grey);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--light-grey); }

.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

/* ---- TOAST ---- */
.toast-wrap {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}

.toast {
  background: var(--charcoal);
  color: var(--white);
  font-size: 0.845rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-h);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

.toast.success { border-left: 3px solid var(--present); }
.toast.error   { border-left: 3px solid var(--absent-nc); }
.toast.warning { border-left: 3px solid var(--absent-notice); }

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

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--mid-grey);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--dark-grey); margin-bottom: 0.4rem; }
.empty-state p { font-size: 0.85rem; }

/* ---- LOADING ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--mid-grey);
  font-size: 0.875rem;
  gap: 0.6rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--light-grey);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---- STATS ROW ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--mid-grey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: rgba(232,73,30,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--charcoal);
  line-height: 1;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--mid-grey);
  margin-top: 0.25rem;
}

/* ---- UTILITY ---- */
.hidden { display: none !important; }
.text-orange { color: var(--orange); }
.text-muted { color: var(--mid-grey); }
.text-sm { font-size: 0.82rem; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .portal-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 64px auto 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    overflow-y: auto;
    padding-bottom: 2rem;
  }

  .sidebar.open { display: block; }

  .main { padding: 1rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .stats-row { grid-template-columns: 1fr; }
}
