/* ============================================================
   SHAHEEN CAMBRIDGE ACADEMY — Global CSS Design System
   
   Color Palette:
   Primary Red   : #E04349
   Primary Green : #84C064
   White         : #FFFFFF
   Dark Sidebar  : #1B1D2A
   Body Bg       : #F4F5F7

   This file is loaded on EVERY page of the CRM.
   Only put styles here that are used across multiple pages.
   Page-specific styles go in their own separate CSS files.
============================================================ */

/* ============================================================
   1. CSS VARIABLES (Design Tokens)
   
   Why variables? If client says "change red to orange tomorrow"
   you change ONE line here — entire CRM updates automatically.
   Without variables you'd hunt through 50 files.
============================================================ */
:root {

  /* Brand Colors */
  --red          : #E04349;
  --red-dark     : #c03540;
  --red-light    : #fdf0f0;
  --red-shadow   : rgba(224, 67, 73, 0.25);

  --green        : #84C064;
  --green-dark   : #6aaa4d;
  --green-light  : #f0f8eb;

  /* Sidebar */
  --sidebar-bg         : #12141f;
  --sidebar-hover      : #1e2130;
  --sidebar-text       : #8b8fa8;
  --sidebar-width      : 265px;

  /* Layout */
  --body-bg      : #f0f2f8;
  --white        : #FFFFFF;
  --topbar-h     : 64px;

  /* Typography */
  --text-dark    : #1a1d2e;
  --text-mid     : #495057;
  --text-light   : #6c757d;

  /* Upgraded Shadows — more 3D depth */
  --shadow-sm    : 0 2px 12px rgba(0,0,0,0.06);
  --shadow-md    : 0 6px 24px rgba(0,0,0,0.10);
  --shadow-lg    : 0 12px 40px rgba(0,0,0,0.14);
  --shadow-red   : 0 4px 20px rgba(224,67,73,0.35);
  --shadow-green : 0 4px 20px rgba(132,192,100,0.35);

  /* Border Radius */
  --radius-sm    : 10px;
  --radius-md    : 14px;
  --radius-lg    : 18px;
  --radius-xl    : 26px;

  /* Transitions */
  --transition   : all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}


/* ============================================================
   2. RESET & BASE
============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   3. LAYOUT — Sidebar + Main Content
============================================================ */
.crm-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   4. SIDEBAR
============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition);

  /* Subtle 3D depth on the right edge */
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

/* Brand area at top of sidebar */
.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-decoration: none;
  display: block;
}

.sidebar-brand .brand-icon {
  width: 42px;
  height: 42px;
  background: var(--red);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;

  /* 3D effect on logo box */
  box-shadow: 0 4px 12px var(--red-shadow),
              inset 0 1px 0 rgba(255,255,255,0.15);
  transition: var(--transition);
}

.sidebar-brand:hover .brand-icon {
  transform: scale(1.08) rotate(-3deg);
  box-shadow: 0 6px 20px var(--red-shadow);
}

.sidebar-brand .brand-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  display: block;
  line-height: 1.3;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--sidebar-text);
  display: block;
  margin-top: 2px;
}

/* Section labels inside sidebar */
.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(255,255,255,0.25);
  padding: 20px 20px 6px;
}

/* Nav links */
.sidebar-nav {
  list-style: none;
  padding: 4px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--transition);
  position: relative;
}

.sidebar-nav a i {
  font-size: 18px;
  width: 20px;
  flex-shrink: 0;
  transition: var(--transition);
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
  padding-left: 24px; /* subtle slide effect on hover */
}

.sidebar-nav a:hover i {
  color: var(--red);
  transform: scale(1.15);
}

.sidebar-nav a.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--red);
  padding-left: 24px;
}

.sidebar-nav a.active i {
  color: var(--red);
}

/* Sidebar footer (logout) */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-footer a:hover {
  background: rgba(224,67,73,0.12);
  color: var(--red);
}

/* ============================================================
   5. MAIN CONTENT AREA
============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   6. TOPBAR
============================================================ */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid #eef0f3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 999;

  /* Slight 3D separation from content below */
  box-shadow: 0 1px 12px rgba(0,0,0,0.05);
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dark);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-date {
  font-size: 13px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Admin chip (name + avatar in topbar) */
.admin-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--body-bg);
  border: 1px solid #eef0f3;
  border-radius: 50px;
  padding: 5px 14px 5px 5px;
  cursor: pointer;
  transition: var(--transition);
}

.admin-chip:hover {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-shadow);
}

.admin-avatar {
  width: 32px;
  height: 32px;
  background: var(--red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 8px var(--red-shadow);
}

.admin-chip-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

/* ============================================================
   7. PAGE CONTENT AREA
============================================================ */
.page-content {
  padding: 28px;
  flex: 1;
}

/* Page header row (title + action button on same line) */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
}

.page-header p {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ============================================================
   8. STAT CARDS (Dashboard)
============================================================ */
.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px 20px 18px;
  border: 1px solid rgba(238,240,243,0.8);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  transform: translateY(0);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  transition: var(--transition);
}

.stat-icon.red    { background: var(--red-light);  color: var(--red);        box-shadow: 0 4px 12px var(--red-shadow); }
.stat-icon.green  { background: var(--green-light); color: var(--green-dark); box-shadow: var(--shadow-green); }
.stat-icon.blue   { background: #eef4ff;             color: #3b6fcc;           box-shadow: 0 4px 12px rgba(59,111,204,0.20); }
.stat-icon.amber  { background: #fff8eb;             color: #d97706;           box-shadow: 0 4px 12px rgba(217,119,6,0.20); }
.stat-icon.purple { background: #f3efff;             color: #7c3aed;           box-shadow: 0 4px 12px rgba(124,58,237,0.20); }

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(-5deg);
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1.2;
  word-break: break-word;
}

.stat-label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
  margin-top: 2px;
}

/* ============================================================
   9. CRM CARDS (general content cards)
============================================================ */
.crm-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid #eef0f3;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  transition: var(--transition);
  overflow: hidden;
}

.crm-card:hover {
  box-shadow: var(--shadow-md);
}

.crm-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid #eef0f3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
}

.crm-card-header h5 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-card-header h5 i {
  color: var(--red);
  font-size: 18px;
}

.crm-card-body {
  padding: 24px;
}

/* ============================================================
   10. TABLES
============================================================ */
.crm-table {
  width: 100%;
  border-collapse: collapse;
}

.crm-table thead th {
  background: var(--body-bg);
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  border-bottom: 1px solid #eef0f3;
  white-space: nowrap;
}

.crm-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid #f5f6f8;
  color: var(--text-mid);
  vertical-align: middle;
  font-size: 13.5px;
}

.crm-table tbody tr:last-child td {
  border-bottom: none;
}

.crm-table tbody tr {
  transition: var(--transition);
}

.crm-table tbody tr:hover td {
  background: #fafbff;
}

/* ============================================================
   11. BUTTONS
============================================================ */

/* Primary Red Button */
.btn-crm {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

/* Shine sweep animation on hover */
.btn-crm::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.25),
    transparent
  );
  transition: left 0.4s ease;
}

.btn-crm:hover::after {
  left: 150%;
}

.btn-crm.red {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 14px var(--red-shadow);
}

.btn-crm.red:hover {
  background: var(--red-dark);
  color: #fff;
  box-shadow: 0 6px 20px var(--red-shadow);
  transform: translateY(-2px);
}

.btn-crm.green {
  background: var(--green);
  color: #fff;
  box-shadow: var(--shadow-green);
}

.btn-crm.green:hover {
  background: var(--green-dark);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow-green);
}

.btn-crm.outline {
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red);
  box-shadow: none;
}

.btn-crm.outline:hover {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 14px var(--red-shadow);
  transform: translateY(-2px);
}

.btn-crm.ghost {
  background: var(--body-bg);
  color: var(--text-mid);
  border: 1px solid #eef0f3;
}

.btn-crm.ghost:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Small icon action buttons used in tables */
.action-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid #eef0f3;
  background: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-light);
  font-size: 16px;
  transition: var(--transition);
}

.action-btn:hover {
  background: var(--red-light);
  color: var(--red);
  border-color: var(--red);
  transform: scale(1.1);
}

.action-btn.green-btn:hover {
  background: var(--green-light);
  color: var(--green-dark);
  border-color: var(--green);
}

/* ============================================================
   12. FORMS
============================================================ */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 5px;
  display: block;
}

.form-control,
.form-select {
  width: 100%;
  border: 1.5px solid #dee2e6;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--text-dark);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-shadow);
}

.form-control::placeholder {
  color: #adb5bd;
}

/* ============================================================
   13. FLASH MESSAGES (success / error alerts)
============================================================ */
.flash-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 20px;

  /* Slide in from top animation */
  animation: slideDown 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.flash-msg i { font-size: 18px; }

.flash-success {
  background: var(--green-light);
  color: #1e5631;
  border: 1px solid #b8dfa7;
}

.flash-error {
  background: var(--red-light);
  color: #7a1c1f;
  border: 1px solid #f1b0b3;
}

/* ============================================================
   14. STUDENT AVATAR in tables
============================================================ */
.student-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #eef0f3;
  box-shadow: var(--shadow-sm);
}

.student-avatar-initial {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--red-light);
  color: var(--red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  border: 2px solid #f1b0b3;
  flex-shrink: 0;
}

/* ============================================================
   15. ANIMATIONS
============================================================ */

/* Slide in from top — used for flash messages */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade up — used for cards loading in */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pulse — used on stat values */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.03); }
}

/* Apply fade-up to page content on load */
.page-content {
  animation: fadeUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stagger delay for stat cards */
.stat-card:nth-child(1) { animation: fadeUp 0.4s ease both; }
.stat-card:nth-child(2) { animation: fadeUp 0.4s 0.07s ease both; }
.stat-card:nth-child(3) { animation: fadeUp 0.4s 0.14s ease both; }
.stat-card:nth-child(4) { animation: fadeUp 0.4s 0.21s ease both; }
.stat-card:nth-child(5) { animation: fadeUp 0.4s 0.28s ease both; }
.stat-card:nth-child(6) { animation: fadeUp 0.4s 0.35s ease both; }

/* ============================================================
   16. SCROLLBAR (make it match the theme)
============================================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--body-bg);
}

::-webkit-scrollbar-thumb {
  background: #ced4da;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--red);
}

/* ============================================================
   17. RESPONSIVE
============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-260px);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .page-content {
    padding: 16px;
  }
  .topbar {
    padding: 0 16px;
  }
}