/* ============================================
   HVN Teachers Portal – Design System
   InnerCity Mission for Children
   ============================================ */

:root {
  /* Brand */
  --green-900: #064e3b;
  --green-800: #065f46;
  --green-700: #0b6e4f;
  --green-600: #059669;
  --green-500: #10b981;
  --green-100: #d1fae5;
  --green-50: #ecfdf5;

  --blue-600: #2563eb;
  --blue-100: #dbeafe;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;
  --purple-600: #7c3aed;
  --purple-100: #ede9fe;

  --gray-950: #0f172a;
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;

  --danger: #ef4444;
  --danger-bg: #fef2f2;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);

  --sidebar-w: 260px;
  --topbar-h: 72px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 15px; }
body {
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }
button, input, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ========== AUTH (Login) ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  background: var(--white);
}

.auth-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  min-height: 100vh;
}

.auth-brand {
  background: linear-gradient(145deg, var(--green-900) 0%, var(--green-700) 55%, #047857 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.08) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(255,255,255,0.06) 0%, transparent 40%);
}

.brand-content {
  position: relative;
  z-index: 1;
  max-width: 380px;
}

.logo-mark {
  margin-bottom: 1.75rem;
}

.auth-brand h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.tagline {
  font-size: 0.95rem;
  opacity: 0.85;
  margin-bottom: 1.75rem;
  font-weight: 500;
}

.mission-text {
  font-size: 1.05rem;
  line-height: 1.65;
  opacity: 0.92;
}

.mission-text strong {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 1.15rem;
  color: #a7f3d0;
}

.brand-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.2);
  font-size: 0.85rem;
  opacity: 0.75;
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  background: var(--white);
}

.auth-form-wrapper {
  width: 100%;
  max-width: 400px;
}

.form-header {
  margin-bottom: 2rem;
}

.form-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.form-header p {
  color: var(--gray-500);
  margin-top: 0.35rem;
}

.auth-form .form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-900);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.form-group input::placeholder {
  color: var(--gray-400);
}

.password-wrapper {
  position: relative;
}

.password-wrapper input {
  padding-right: 2.75rem;
}

.toggle-password {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  padding: 0.25rem;
  display: flex;
}

.toggle-password:hover { color: var(--gray-600); }

.error-msg {
  display: block;
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 0.3rem;
  min-height: 1.1em;
}

.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--gray-600);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--green-600);
}

.forgot-link {
  color: var(--green-700);
  font-weight: 500;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green-700);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--green-800);
}

.btn-primary:active {
  background: var(--green-900);
}

.btn-outline {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-full { width: 100%; }
.btn-sm { padding: 0.5rem 0.9rem; font-size: 0.85rem; }

.btn-loader { display: none; }
.btn.loading .btn-text { display: none; }
.btn.loading .btn-loader { display: inline-flex; }

.spinner {
  animation: spin 0.8s linear infinite;
}

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

.auth-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ========== APP LAYOUT ========== */
.app-body {
  display: flex;
  min-height: 100vh;
  background: var(--gray-50);
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

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

.logo-small {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--green-700);
  color: var(--white);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.logo-text strong {
  font-size: 0.9rem;
  color: var(--gray-900);
}

.logo-text span {
  font-size: 0.72rem;
  color: var(--gray-500);
}

.sidebar-close {
  display: none;
  color: var(--gray-500);
  padding: 0.25rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
  text-decoration: none;
}

.nav-item.active {
  background: var(--green-50);
  color: var(--green-800);
}

.nav-item.active svg {
  stroke: var(--green-700);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.user-info {
  min-width: 0;
  line-height: 1.25;
}

.user-info strong {
  display: block;
  font-size: 0.85rem;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  font-size: 0.72rem;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.btn-logout {
  color: var(--gray-400);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.btn-logout:hover {
  background: var(--gray-100);
  color: var(--danger);
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  color: var(--gray-600);
  padding: 0.35rem;
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 0.1rem;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
}

.content {
  padding: 1.5rem 1.75rem 2.5rem;
  flex: 1;
}

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

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.green { background: var(--green-100); color: var(--green-700); }
.stat-icon.blue { background: var(--blue-100); color: var(--blue-600); }
.stat-icon.amber { background: var(--amber-100); color: var(--amber-500); }
.stat-icon.purple { background: var(--purple-100); color: var(--purple-600); }

.stat-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.stat-change {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 0.15rem;
}

.stat-change.positive { color: var(--green-600); }

/* Cards & grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-900);
}

.link-sm {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--green-700);
}

/* Activity */
.activity-list {
  list-style: none;
  padding: 0.5rem 0;
}

.activity-item {
  display: flex;
  gap: 0.9rem;
  padding: 0.85rem 1.25rem;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.45rem;
  flex-shrink: 0;
}

.activity-dot.green { background: var(--green-500); }
.activity-dot.blue { background: var(--blue-600); }
.activity-dot.amber { background: var(--amber-500); }
.activity-dot.purple { background: var(--purple-600); }

.activity-content p {
  font-size: 0.875rem;
  color: var(--gray-700);
}

.activity-content time {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.15rem;
  display: block;
}

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  padding: 1rem 1.25rem 1.25rem;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  text-decoration: none;
}

.action-btn:hover {
  border-color: var(--green-500);
  background: var(--green-50);
  color: var(--green-800);
  text-decoration: none;
}

.action-btn svg {
  color: var(--green-600);
}

/* Upcoming */
.upcoming-list {
  list-style: none;
  padding: 0.5rem 0 1rem;
}

.upcoming-list li {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  align-items: flex-start;
}

.date-badge {
  width: 44px;
  text-align: center;
  background: var(--green-50);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0;
  flex-shrink: 0;
}

.date-badge .day {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: var(--green-800);
  line-height: 1.2;
}

.date-badge .month {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--green-600);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.upcoming-list strong {
  font-size: 0.875rem;
  color: var(--gray-900);
  display: block;
}

.upcoming-list p {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 0.15rem;
}

/* ========== USERS TABLE ========== */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.6rem 0.9rem 0.6rem 2.5rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.search-box input:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.filter-group {
  display: flex;
  gap: 0.5rem;
}

.select {
  padding: 0.55rem 2rem 0.55rem 0.85rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--gray-700);
  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='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  cursor: pointer;
}

.select:focus {
  outline: none;
  border-color: var(--green-600);
}

.table-card {
  padding: 0;
}

.table-responsive {
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-700);
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.user-name {
  font-weight: 500;
  color: var(--gray-900);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-active {
  background: var(--green-100);
  color: var(--green-800);
}

.badge-pending {
  background: var(--amber-100);
  color: #b45309;
}

.badge-inactive {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge-role {
  background: var(--blue-100);
  color: #1d4ed8;
}

.actions-cell {
  display: flex;
  gap: 0.35rem;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.icon-btn.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--gray-100);
  font-size: 0.85rem;
  color: var(--gray-500);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  background: var(--white);
}

.page-btn:hover:not(:disabled) {
  background: var(--gray-50);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  font-size: 0.85rem;
  color: var(--gray-600);
  min-width: 70px;
  text-align: center;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

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

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-close {
  color: var(--gray-400);
  padding: 0.25rem;
}

.modal-close:hover { color: var(--gray-700); }

.modal-body {
  padding: 1.35rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0;
}

.modal-body .form-group {
  margin-bottom: 1.1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

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

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

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close {
    display: flex;
  }
  .main-wrapper {
    margin-left: 0;
  }
  .menu-toggle {
    display: flex;
  }
  .auth-container {
    grid-template-columns: 1fr;
  }
  .auth-brand {
    display: none;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 1rem;
  }
  .topbar {
    padding: 0 1rem;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .quick-actions {
    grid-template-columns: 1fr;
  }
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    flex-wrap: wrap;
  }
}
