/* AIS visual refresh — loaded after assets/css/style.css in links.php.
   Overrides only; no markup or logic changes. Remove this file's <link> to revert. */

/* ---------- Tokens ---------- */
:root {
  --ais-primary: #1E3A5F;
  --ais-primary-hover: #163050;
  --ais-secondary: #2563EB;
  --ais-accent: #8A5A00;          /* darkened gold, >=4.5:1 on white */
  --ais-bg: #F5F7FA;
  --ais-card: #FFFFFF;
  --ais-fg: #0F172A;
  --ais-muted-fg: #475569;        /* >=4.5:1 on white and on --ais-bg */
  --ais-border: #CBD5E1;
  --ais-danger: #B91C1C;
  --ais-focus: #1E3A5F;
  --ais-radius: 10px;
  --ais-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.05);
  --ais-font-ui: 'Nunito', 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ---------- Base ---------- */
html, body {
  font-family: var(--ais-font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ais-fg);
  background: var(--ais-bg);
}
body { -webkit-font-smoothing: antialiased; }

h1, h2, h3, h4, h5, h6 {
  color: var(--ais-primary);
  font-family: var(--ais-font-ui);
  font-weight: 700;
  letter-spacing: -0.01em;
}

a { color: var(--ais-secondary); }
a:hover { color: var(--ais-primary); }

/* Visible keyboard focus everywhere */
:focus-visible {
  outline: 3px solid var(--ais-focus);
  outline-offset: 2px;
}

/* Brand colour: template blue text-primary -> navy */
.text-primary { color: var(--ais-primary) !important; }

/* Dashboard banner: template near-black -> navy */
.text-bg-dark {
  background-color: var(--ais-primary) !important;
  color: #FFFFFF !important;
}

/* Sidebar list buttons (Instructor etc.): template bright-blue active/focus -> soft navy tint */
.list-group-item.active,
.list-group-item.show,
.list-group-item-action:hover,
.list-group-item-action:focus,
.list-group-item-action:active {
  background-color: #E8EEF6 !important;
  color: var(--ais-primary) !important;
  border-color: var(--ais-border) !important;
}

/* Pill tabs: template bright-blue active -> navy */
.nav-pills {
  --bs-nav-pills-link-active-bg: var(--ais-primary);
}
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
  background-color: var(--ais-primary) !important;
  color: #FFFFFF !important;
}

/* Inactive pill tabs: template bright blue -> navy */
.nav-pills .nav-link:not(.active) {
  color: var(--ais-primary);
}
.nav-pills .nav-link:not(.active):hover {
  background-color: #E8EEF6;
}

/* Header subtitles on navy banners: 50% white was too faint */
.card-header small.text-white-50 {
  color: #E2E8F0 !important;
}

/* Accordions: template indigo active heading -> navy on soft tint */
.accordion {
  --bs-accordion-active-color: var(--ais-primary);
  --bs-accordion-active-bg: #E8EEF6;
  --bs-accordion-btn-focus-border-color: var(--ais-primary);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.25);
}
.accordion-button:not(.collapsed) {
  color: var(--ais-primary) !important;
  background-color: #E8EEF6 !important;
}
.accordion-button:not(.collapsed) span,
.accordion-button:not(.collapsed) i {
  color: var(--ais-primary) !important;
}

/* Back-to-top button: template periwinkle -> navy */
.back-to-top {
  background: var(--ais-primary) !important;
}
.back-to-top:hover,
.back-to-top:focus-visible {
  background: var(--ais-primary-hover) !important;
}

/* Solid primary badges: template periwinkle-blue -> palette secondary blue */
.badge.bg-primary {
  background-color: var(--ais-secondary) !important;
  color: #FFFFFF !important;
}

/* Info badges: template cyan with white text failed contrast */
.badge.bg-info {
  background-color: #0E7490 !important;
  color: #FFFFFF !important;
}

/* Logout keeps its danger tint (hover rule above must not override it) */
.list-group-item.list-group-item-danger,
.list-group-item-action.list-group-item-danger:hover,
.list-group-item-action.list-group-item-danger:focus {
  background-color: #FEE2E2 !important;
  color: #991B1B !important;
  border-color: var(--ais-border) !important;
}

/* Secondary outline buttons: template grey text was too faint */
.btn-outline-secondary {
  color: #334155;
  border-color: #64748B;
  background: #FFFFFF;
}
.btn-outline-secondary:hover {
  background: #E8EEF6;
  color: var(--ais-primary);
  border-color: var(--ais-primary);
}

/* Muted text: ensure contrast (overrides low-contrast template greys) */
.text-muted, .small.text-muted, .card-title span, .text-secondary {
  color: var(--ais-muted-fg) !important;
}

/* ---------- Header ---------- */
.header {
  background: var(--ais-primary);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);
  border-bottom: 0;
}
.header .logo span,
.header .nav-profile span,
.header .toggle-sidebar-btn,
.header .nav-link,
.header .bi {
  color: #FFFFFF !important;
}
.header .logo span { font-weight: 700; }
.header .nav-profile img { border: 2px solid rgba(255, 255, 255, 0.6); }
.header .nav-link:focus-visible,
.header .toggle-sidebar-btn:focus-visible {
  outline-color: #FFFFFF;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: #FFFFFF;
  border-right: 1px solid var(--ais-border);
  box-shadow: none;
}
.sidebar-nav .nav-link {
  color: var(--ais-fg);
  font-weight: 600;
  border-radius: 8px;
  margin: 2px 10px;
}
.sidebar-nav .nav-link i { color: var(--ais-primary); }
.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  background: #E8EEF6;
  color: var(--ais-primary);
}
.sidebar-nav .nav-link.collapsed:hover { background: #E8EEF6; }
.sidebar-nav .nav-heading { color: var(--ais-muted-fg); font-weight: 700; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--ais-card);
  border: 1px solid var(--ais-border);
  border-radius: var(--ais-radius);
  box-shadow: var(--ais-shadow);
}
.card-title {
  color: var(--ais-primary);
  font-weight: 700;
}
.card-header, .card-footer {
  background: transparent;
  border-color: var(--ais-border);
}

/* ---------- Buttons ---------- */
.btn {
  border-radius: 8px;
  font-weight: 600;
  min-height: 40px;
  padding: 0.4rem 0.9rem;
  /* Icon and label centred on one line box, so text sits vertically middle */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  line-height: 1.25;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.btn.bi::before,
.btn > i[class^="bi-"],
.btn > i[class*=" bi-"] {
  line-height: 1;
  vertical-align: middle;
}
.btn-sm { min-height: 32px; padding: 0.2rem 0.6rem; }
.btn-lg { min-height: 46px; padding: 0.5rem 1.1rem; }

/* Full-width action buttons in grouped rows (e.g. attendance actions):
   one shared height; labels that wrap to two lines still fit and stay centred */
.btn.col-12 {
  min-height: 40px;
  padding: 0.25rem 0.5rem;
  font-size: 0.88rem;
  line-height: 1.15;
}
.btn-primary {
  background-color: var(--ais-primary);
  border-color: var(--ais-primary);
  color: #FFFFFF;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--ais-primary-hover);
  border-color: var(--ais-primary-hover);
  color: #FFFFFF;
}
.btn-outline-primary {
  color: var(--ais-primary);
  border-color: var(--ais-primary);
}
.btn-outline-primary:hover {
  background: var(--ais-primary);
  color: #FFFFFF;
}
.btn-danger { background-color: var(--ais-danger); border-color: var(--ais-danger); }
.btn-danger:hover { background-color: #991B1B; border-color: #991B1B; }
.btn:disabled, .btn.disabled { opacity: 0.6; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; color: var(--ais-fg); }
.form-control, .form-select {
  border-color: #94A3B8;          /* stronger than default for 3:1 field boundary */
  border-radius: 8px;
  min-height: 44px;
  color: var(--ais-fg);
}
.form-control:focus, .form-select:focus {
  border-color: var(--ais-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.25);
}
.form-control::placeholder { color: #64748B; opacity: 1; }
.invalid-feedback, .text-danger { color: var(--ais-danger) !important; }

/* ---------- Tables (incl. DataTables) ---------- */
.table {
  --bs-table-bg: transparent;
  color: var(--ais-fg);
}
.table > :not(caption) > * > * { padding: 0.75rem 0.9rem; border-color: #E2E8F0; }
.table thead th, .table thead td {
  background: #F1F5F9;
  color: var(--ais-primary);
  font-weight: 700;
  border-bottom: 2px solid var(--ais-border);
}
.table-hover > tbody > tr:hover > * { background-color: #F1F5F9; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: #F8FAFC; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--ais-primary) !important;
  border-color: var(--ais-primary) !important;
  color: #FFFFFF !important;
  border-radius: 6px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: #E8EEF6 !important;
  color: var(--ais-primary) !important;
}

/* ---------- Badges & alerts ---------- */
.badge { font-weight: 600; border-radius: 6px; }
.alert { border-radius: var(--ais-radius); border-width: 1px; }

/* ---------- Modals ---------- */
.modal-content {
  border-radius: 14px !important;
  border: 1px solid var(--ais-border) !important;
}
.modal-header { border-bottom-color: var(--ais-border); }
.modal-title { color: var(--ais-primary); font-weight: 700; }
/* Dark/navy modal headers: title must stay white */
.modal-header.text-white .modal-title,
.modal-header.bg-dark .modal-title { color: #FFFFFF; }

/* ---------- Links & transitions ---------- */
.card, .btn, .sidebar-nav .nav-link {
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

/* ---------- Responsive ---------- */
@media (max-width: 575.98px) {
  .card-body { padding: 1rem; }
  .table-responsive { border-radius: var(--ais-radius); }
}

/* ---------- Mobile (phones, <768px) ---------- */
@media (max-width: 767.98px) {
  html, body { font-size: 15px; }

  /* Oversized page titles and section headings */
  .fs-1 { font-size: 1.75rem !important; }
  .fs-2 { font-size: 1.4rem !important; }
  .fs-3 { font-size: 1.25rem !important; }
  .fs-4 { font-size: 1.1rem !important; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.15rem; }
  h4 { font-size: 1.05rem; }
  h5 { font-size: 1rem; }
  .card-title { font-size: 1rem; }

  /* Badges and labels wrap instead of bleeding past their card */
  .badge {
    white-space: normal !important;
    max-width: 100%;
    text-align: left;
    line-height: 1.35;
  }
  .card-header,
  .card-header > div {
    min-width: 0;
    flex-wrap: wrap;
  }
  .card-header .badge { display: inline-block; }

  /* Cards and body spacing */
  .card-body, .card-header, .card-footer { padding-left: 0.85rem; padding-right: 0.85rem; }
  .card { margin-bottom: 0.85rem; }

  /* Wide tables scroll inside their card, never push the page */
  .table-responsive,
  .card .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .table > :not(caption) > * > * { padding: 0.55rem 0.6rem; white-space: nowrap; }
  .table td, .table th { font-size: 0.875rem; }

  /* DataTables controls stack vertically */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none;
    text-align: left;
    margin-bottom: 0.5rem;
  }
  .dataTables_wrapper .dataTables_filter input { width: 100%; max-width: 100%; }

  /* Buttons and form controls: full width, touch-sized */
  /* Buttons: compact on phones, text centred both ways even when it wraps */
  .btn,
  .btn-lg,
  .btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal;
    min-height: 40px;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    line-height: 1.25;
    gap: 0.35rem;
  }
  .btn-sm { min-height: 34px; padding: 0.25rem 0.6rem; font-size: 0.8rem; }

  /* Action rows (Student Attendance / View-Edit / Delete): stack full width.
     Equal 3-column flex squeezed labels into one-letter-per-line columns. */
  .row > .col.col-lg,
  .row > .btn-group.col.col-lg,
  .row > .col-lg {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin-right: 0 !important;
  }
  .row > .col.col-lg > .btn,
  .row > .btn-group.col.col-lg > .btn {
    width: 100%;
  }

  /* Attendance subject picker: Bootstrap utility px-3/py-1 forced tall, wide buttons */
  .get_subjects .btn,
  .get_subjects label.btn {
    padding-top: 0.35rem !important;
    padding-bottom: 0.35rem !important;
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
    min-height: 40px;
    font-size: 0.85rem;
    line-height: 1.25;
    /* Left-align icon and label as one unit, so the row reads as a list item */
    justify-content: flex-start !important;
    text-align: left !important;
    align-items: center;
    width: 100%;
  }
  .get_subjects .btn i { margin-right: 0.5rem !important; flex-shrink: 0; }
  .btn-group .btn { min-height: 40px; }
  .btn > i, .btn > .bi { line-height: 1; flex-shrink: 0; }
  .form-control, .form-select { font-size: 16px; /* stops iOS zoom on focus */ }

  /* Modals fit the screen */
  .modal-dialog { margin: 0.5rem; max-width: calc(100% - 1rem); }
  .modal-body { padding: 0.9rem; }

  /* Tabs and pill navs wrap */
  .nav-pills { flex-wrap: wrap; }
  .nav-pills .nav-link { font-size: 0.9rem; }

  /* Long words and emails never overflow */
  .card, .card-body, .list-group-item, p, li, td, th, span {
    overflow-wrap: anywhere;
  }
  img, video, iframe { max-width: 100%; height: auto; }

  /* Profile avatars: smaller on phones (inline 120px overridden) */
  #student_photo_placeholder,
  #student_photo,
  img.rounded-circle[style*="120px"] {
    width: 96px !important;
    height: 96px !important;
  }
  #student_photo_placeholder i { font-size: 44px !important; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
