/* =====================================================================
   Dhamma Arana — Common Stylesheet
   Theme: "Morning Stillness" — a fresh meditation environment
   Misty sage greens, warm saffron accents, soft linen surfaces.
   Used by every page via includes/header.php (and login.php).
===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Nunito+Sans:wght@400;600;700;800&display=swap');

:root {
    /* Palette */
    --bg:            #F2F5EF;   /* misty morning sage-white   */
    --bg-deep:       #E6ECE3;   /* shaded garden              */
    --surface:       #FFFFFF;
    --surface-soft:  #F8FAF5;
    --ink:           #2E3A33;   /* deep forest ink (text)     */
    --muted:         #6E7B72;   /* stone grey-green           */
    --line:          #E1E7DD;   /* hairline borders           */

    --primary:       #4E7A64;   /* fresh jade / sage          */
    --primary-deep:  #35574A;   /* forest shade               */
    --primary-soft:  #E3EEE7;   /* pale leaf                  */
    --accent:        #B78730;   /* Dhamma-wheel gold (logo)   */
    --accent-soft:   #F6EEDD;
    --lotus:         #D9A7A0;   /* lotus blush                */

    --danger:        #B65A52;
    --danger-soft:   #FBEDEB;
    --success:       #3E7D58;
    --success-soft:  #E7F3EB;
    --warning:       #C1862A;
    --warning-soft:  #FBF2E1;

    /* Legacy aliases (kept so any old markup still works) */
    --bg-color: var(--bg);
    --card-bg:  var(--surface);
    --text:     var(--ink);

    /* Shape & motion */
    --radius-lg: 18px;
    --radius:    12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(46, 58, 51, .04), 0 2px 8px rgba(46, 58, 51, .04);
    --shadow:    0 2px 4px rgba(46, 58, 51, .03), 0 10px 30px rgba(46, 58, 51, .06);
    --shadow-lg: 0 18px 50px rgba(53, 87, 74, .16);
    --ease:      cubic-bezier(.4, .1, .2, 1);
    --transition: all .25s var(--ease);

    --font-body:    'Nunito Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-heading: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --container: 1320px;
}

/* =====================================================================
   BASE
===================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    background-color: var(--bg);
    /* soft morning light + garden shade */
    background-image:
        radial-gradient(1100px 600px at -10% -10%, rgba(78, 122, 100, .10), transparent 60%),
        radial-gradient(900px 500px at 110% 0%, rgba(200, 164, 101, .10), transparent 60%),
        radial-gradient(1000px 700px at 50% 120%, rgba(217, 167, 160, .08), transparent 60%);
    background-attachment: fixed;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--primary-deep);
    line-height: 1.2;
    letter-spacing: .2px;
}

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

small { font-size: .85em; }
.text-muted { color: var(--muted); }
.help-text { font-size: .8em; color: var(--muted); margin-top: 2px; }

::selection { background: var(--primary-soft); color: var(--primary-deep); }

:focus-visible { outline: 3px solid rgba(78, 122, 100, .35); outline-offset: 2px; }

/* =====================================================================
   COMMON NAVIGATION (includes/header.php)
===================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.site-header::after {           /* thin saffron thread */
    content: "";
    display: block;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), var(--lotus), var(--primary), transparent);
    opacity: .55;
}

.navbar {
    max-width: var(--container);
    margin: 0 auto;
    padding: 12px 28px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 30% 30%, #fff, var(--primary-soft));
    box-shadow: inset 0 0 0 1px rgba(78, 122, 100, .18);
}
.brand-mark svg { width: 28px; height: 28px; }

/* Dhamma wheel logo */
.brand-logo {
    height: 48px;
    width: auto;
    display: block;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(183, 135, 48, .18));
    transition: transform .6s var(--ease);
}
.brand:hover .brand-logo { transform: rotate(-8deg); }
.login-logo {
    display: block;
    height: 130px;
    width: auto;
    margin: 0 auto 16px;
    filter: drop-shadow(0 6px 14px rgba(183, 135, 48, .25));
}
.welcome-wheel {
    position: absolute;
    right: 40px;
    top: 50%;
    height: 170%;
    width: auto;
    transform: translateY(-50%) rotate(-12deg);
    opacity: .12;
    pointer-events: none;
}
.welcome-card > *:not(.welcome-wheel) { position: relative; z-index: 1; }

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--primary-deep);
}
.brand-text small {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-menu {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    font-size: .88rem;
    white-space: nowrap;
    color: var(--muted);
    transition: var(--transition);
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-link:hover { color: var(--primary-deep); background: var(--primary-soft); }
.nav-link.active {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 4px 14px rgba(78, 122, 100, .30);
}

.nav-user { display: flex; align-items: center; gap: 12px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: .85rem;
    font-weight: 800;
    color: var(--primary-deep);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px rgba(200, 164, 101, .45);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1.5px solid rgba(182, 90, 82, .45);
    color: var(--danger);
    background: transparent;
    text-decoration: none;
    font-weight: 700;
    font-size: .85rem;
    transition: var(--transition);
}
.btn-logout { font-family: inherit; cursor: pointer; }
.btn-logout svg { width: 15px; height: 15px; }
.logout-form { margin: 0; }
.btn-logout:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.nav-toggle {
    display: none;
    margin-left: auto;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    padding: 0;
    place-items: center;
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--primary-deep);
    position: relative;
    transition: var(--transition);
}
.nav-toggle span::before, .nav-toggle span::after { content: ""; position: absolute; left: 0; }
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after  { top: 6px; }
.nav-open .nav-toggle span { background: transparent; }
.nav-open .nav-toggle span::before { top: 0; transform: rotate(45deg); }
.nav-open .nav-toggle span::after  { top: 0; transform: rotate(-45deg); }

/* =====================================================================
   PAGE LAYOUT
===================================================================== */
.page {
    flex: 1;
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 32px 28px 40px;
    animation: fadeIn .35s var(--ease);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.page-intro { margin-bottom: 26px; }
.page-intro h1 { margin: 0; font-size: 2.2rem; }
.page-intro p  { margin: 4px 0 0; color: var(--muted); }
.page-intro::after {
    content: "";
    display: block;
    width: 56px;
    height: 3px;
    margin-top: 12px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--lotus));
}

.site-footer {
    text-align: center;
    padding: 22px 16px 28px;
    color: var(--muted);
    font-size: .85rem;
}
.site-footer .quote {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--primary);
    display: block;
    margin-bottom: 2px;
}

/* =====================================================================
   CARDS
===================================================================== */
.card, .filter-card {
    background: var(--surface);
    border: 1px solid rgba(225, 231, 221, .8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 26px;
    margin-bottom: 26px;
    height: fit-content;
}
.filter-card { padding: 18px 22px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-title { padding: 20px 24px 0; }

.card h2, .card h3, .card-title {
    margin: 0 0 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.card h3 a {
    font-family: var(--font-body);
    font-size: .8rem;
    font-weight: 700;
    text-decoration: none;
}
.card h3 small { font-family: var(--font-body); font-size: .75rem; color: var(--warning); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
    margin-bottom: 20px;
}
.card-header h3 { margin: 0; padding: 0; border: 0; }
.card-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.welcome-card {
    position: relative;
    overflow: hidden;
    color: #fff;
    padding: 34px 36px;
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
    background:
        radial-gradient(420px 220px at 95% 10%, rgba(255, 255, 255, .18), transparent 70%),
        linear-gradient(135deg, var(--primary-deep) 0%, var(--primary) 55%, #7FA08A 100%);
    box-shadow: var(--shadow-lg);
}
.welcome-card h1 { color: #fff; margin: 0 0 6px; font-size: 2.2rem; }
.welcome-card p  { margin: 0; opacity: .9; max-width: 640px; }
.welcome-card .date-line {
    display: inline-block;
    margin-bottom: 10px;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: rgba(255, 255, 255, .16);
}

/* =====================================================================
   GRIDS
===================================================================== */
.grid-container {
    display: grid;
    grid-template-columns: minmax(300px, 380px) 1fr;
    gap: 26px;
    align-items: start;
}
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 26px;
    align-items: start;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 4px 18px;
}
.detail-view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    padding: 24px;
    border-radius: var(--radius);
}

/* =====================================================================
   BUTTONS
===================================================================== */
.btn, .btn-submit, .btn-filter, .btn-reset, .btn-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-family: inherit;
    font-weight: 700;
    font-size: .88rem;
    line-height: 1.2;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary, .btn-submit, .btn-filter {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(78, 122, 100, .25);
}
.btn-primary:hover, .btn-submit:hover, .btn-filter:hover {
    background: var(--primary-deep);
    color: #fff;
    transform: translateY(-1px);
}

.btn-submit { width: 100%; padding: 12px 20px; font-size: .95rem; }
.btn-submit.btn-update, .btn-update { background: var(--accent); box-shadow: 0 4px 14px rgba(200, 164, 101, .35); }
.btn-submit.btn-update:hover { background: #B08D50; }

.btn-secondary, .btn-reset {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}
.btn-secondary:hover, .btn-reset:hover { background: var(--primary-soft); border-color: #cfdcd2; color: var(--primary-deep); }

.btn-cancel {
    width: 100%;
    margin-top: 10px;
    background: transparent;
    color: var(--muted);
    border-color: var(--line);
}
.btn-cancel:hover { color: var(--ink); background: var(--surface-soft); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9E4A43; color: #fff; }

.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* Table row actions */
.btn-edit, .btn-delete, .btn-view {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    background: transparent;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-view   { color: var(--primary); border: 1px solid rgba(78, 122, 100, .45); }
.btn-view:hover { background: var(--primary); color: #fff; }
.btn-edit   { color: var(--warning); border: 1px solid rgba(193, 134, 42, .5); }
.btn-edit:hover { background: var(--warning); color: #fff; }
.btn-delete { color: var(--danger); border: 1px solid rgba(182, 90, 82, .45); }
.btn-delete:hover { background: var(--danger); color: #fff; }

.action-cell { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.action-cell form { margin: 0; display: inline-flex; }
.notice { background: var(--warning-soft); color: #8A5F16; border-color: #EEDCB8; }
.notice::before { content: "i"; }

/* Dashboard quick actions */
.quick-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 18px;
    border-radius: var(--radius);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    color: var(--primary-deep);
    text-decoration: none;
    font-weight: 700;
    font-size: .92rem;
    transition: var(--transition);
}
.btn-action:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: translateX(4px);
}

/* =====================================================================
   FORMS
===================================================================== */
.form-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 28px 0 14px;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-deep);
}
.form-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--line), transparent);
}
.form-section-title:first-of-type { margin-top: 6px; }

.form-group, .filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.form-group.full-width { grid-column: 1 / -1; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; min-width: 0; }

label {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .3px;
    color: var(--primary-deep);
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #D8E0D5;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    color: var(--ink);
    font-family: inherit;
    font-size: .92rem;
    transition: var(--transition);
}
textarea { resize: vertical; min-height: 70px; }
input::placeholder, textarea::placeholder { color: #A3AEA6; }

input:hover, select:hover, textarea:hover { border-color: #C5D2C8; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(78, 122, 100, .14);
}

.filter-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-group { flex: 1; min-width: 160px; margin-bottom: 0; }
.filter-group.grow-2 { flex: 2; }

.search-box { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search-box input { flex: 1; min-width: 200px; }

/* =====================================================================
   TABLES
===================================================================== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 13px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
    font-size: .9rem;
}
th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}
tbody tr { transition: background .2s; }
tbody tr:hover { background: #F6F9F4; }
tbody tr:last-child td { border-bottom: 0; }
tr.row-highlight { background: var(--accent-soft) !important; }
td.empty { text-align: center; color: var(--muted); padding: 28px; font-style: italic; }

.badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-deep);
    font-size: .75rem;
    font-weight: 800;
    white-space: nowrap;
}
.badge-gold { background: var(--accent-soft); color: #8A6A2E; }

/* =====================================================================
   DASHBOARD STAT CARDS
===================================================================== */
.stat-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 22px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid rgba(225, 231, 221, .8);
    box-shadow: var(--shadow-sm);
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
    --tone: var(--primary);
}
.stat-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--tone);
    opacity: .85;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.stat-card.upcoming-card { --tone: var(--accent); }
.stat-card.students-card { --tone: #6FA287; }
.stat-card.teachers-card { --tone: #8C9C6B; }
.stat-card.types-card    { --tone: #7F9FAE; }
.stat-card.users-card    { --tone: var(--lotus); }

.stat-label  { font-size: .72rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.stat-number { font-family: var(--font-heading); font-size: 2.9rem; font-weight: 700; line-height: 1; margin: 12px 0 4px; color: var(--primary-deep); }
.stat-link-text { font-size: .8rem; font-weight: 700; color: var(--primary); margin-top: 12px; }

/* =====================================================================
   STUDENTS: AVATARS, DETAIL VIEW, WEBCAM
===================================================================== */
.student-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-deep);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 800;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--line);
}
.student-avatar.lg { width: 110px; height: 110px; font-size: 2rem; }

.profile-head { display: flex; gap: 22px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }
.profile-head h2 { margin: 0; border: 0; padding: 0; font-size: 2rem; }
.profile-head p  { margin: 4px 0 0; color: var(--muted); }

.detail-item { font-size: .92rem; }
.detail-item strong {
    display: block;
    margin-bottom: 3px;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary);
}

/* Photo capture panel */
.photo-capture {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    align-items: start;
    padding: 20px;
    border: 1px dashed #C9D6CC;
    border-radius: var(--radius);
    background: var(--surface-soft);
}
.photo-stage {
    position: relative;
    width: 260px;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 38%, #fff 0 18%, transparent 19%),
        radial-gradient(ellipse at 50% 100%, #fff 0 38%, transparent 39%),
        var(--bg-deep);
    box-shadow: inset 0 0 0 1px var(--line);
}
.photo-stage img,
.photo-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-stage video { transform: scaleX(-1); } /* mirror preview like a looking-glass */
.photo-stage .guide {                          /* face-framing oval */
    position: absolute;
    inset: 12% 22% 18%;
    border: 2px dashed rgba(255, 255, 255, .75);
    border-radius: 50%;
    pointer-events: none;
}
.photo-stage .flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
}
.photo-stage .flash.go { animation: flash .45s ease-out; }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }

.photo-badge {
    position: absolute;
    left: 10px;
    bottom: 10px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(46, 58, 51, .7);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .5px;
}

.photo-controls { display: flex; flex-direction: column; gap: 12px; }
.photo-controls .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-controls select { max-width: 340px; }
.cam-status { font-size: .85rem; color: var(--muted); margin: 0; }
.cam-status.error { color: var(--danger); }
.cam-status.ok { color: var(--success); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.photo-capture.compact { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
.photo-capture.compact .photo-stage { width: 200px; margin: 0 auto; }
.photo-capture.compact .photo-controls { align-items: stretch; text-align: center; }
.photo-capture.compact .btn-row { justify-content: center; }
.photo-capture.compact .btn { padding: 8px 14px; font-size: .82rem; }
.teacher-cell { display: flex; gap: 12px; align-items: center; }

.is-hidden { display: none !important; }

/* =====================================================================
   ALERTS
===================================================================== */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    border-radius: var(--radius);
    margin-bottom: 22px;
    font-size: .92rem;
    font-weight: 700;
    border: 1px solid transparent;
}
.alert::before { font-size: 1.1rem; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #CDE5D5; }
.alert-success::before { content: "✓"; }
.alert-danger, .alert-error { background: var(--danger-soft); color: var(--danger); border-color: #F1D3CF; }
.alert-danger::before, .alert-error::before { content: "!"; }

/* =====================================================================
   LOGIN PAGE
===================================================================== */
body.login-page {
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-image:
        radial-gradient(700px 500px at 15% 20%, rgba(78, 122, 100, .20), transparent 60%),
        radial-gradient(600px 450px at 85% 80%, rgba(200, 164, 101, .20), transparent 60%),
        radial-gradient(500px 400px at 80% 15%, rgba(217, 167, 160, .16), transparent 60%);
}
.login-container {
    width: 100%;
    max-width: 410px;
    padding: 42px 40px 36px;
    border-radius: 24px;
    text-align: center;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, .9);
    box-shadow: var(--shadow-lg);
    animation: fadeIn .6s var(--ease);
}
.login-container .brand-mark { width: 74px; height: 74px; margin: 0 auto 14px; }
.login-container .brand-mark svg { width: 46px; height: 46px; }
.login-container h2 { margin: 0; font-size: 2.2rem; }
.login-container .subtitle {
    margin: 2px 0 26px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--muted);
}
.login-container .form-group { text-align: left; }
.login-container .btn-submit { margin-top: 8px; }
.login-container .quote {
    margin: 24px 0 0;
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--primary);
}

/* =====================================================================
   RESPONSIVE
===================================================================== */
@media (max-width: 1440px) {
    .user-name { display: none; }                /* avatar only; full name in tooltip */
}

@media (max-width: 1180px) {
    .nav-link span.label { display: none; }     /* icon-only on mid screens */
    .nav-link { padding: 9px 11px; }
}

@media (max-width: 992px) {
    .grid-container, .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .navbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
    .nav-toggle { display: grid; }
    .nav-menu {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 8px 0 14px;
    }
    .nav-open .nav-menu { display: flex; }
    .brand-logo { height: 40px; }
    .nav-links { flex-direction: column; align-items: stretch; }
    .nav-link { padding: 11px 14px; border-radius: var(--radius-sm); }
    .nav-link span.label { display: inline; }
    .user-name { display: inline; }
    .nav-user { justify-content: space-between; border-top: 1px solid var(--line); padding-top: 12px; }
}

@media (max-width: 700px) {
    body { font-size: 14.5px; }
    .page { padding: 20px 16px 28px; }
    .page-intro h1, .welcome-card h1 { font-size: 1.8rem; }
    .welcome-card { padding: 26px 22px; }
    .card { padding: 20px 18px; }
    .form-row { flex-direction: column; gap: 0; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .filter-group { min-width: 100%; }
    .btn-filter, .btn-reset { width: 100%; }
    .card h2, .card h3 { flex-direction: column; align-items: flex-start; }
    .photo-capture { grid-template-columns: 1fr; }
    .photo-stage { width: 100%; max-width: 320px; margin: 0 auto; }
    table { min-width: 620px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =====================================================================
   AUTO IDs, DEACTIVATED RECORDS, ROLES
===================================================================== */
input.auto-id {
    background: repeating-linear-gradient(135deg, var(--surface-soft) 0 8px, #F1F4EE 8px 16px);
    color: var(--primary-deep);
    font-weight: 800;
    letter-spacing: .5px;
    cursor: default;
    border-style: dashed;
}
input.auto-id:focus { box-shadow: none; border-color: #D8E0D5; }

tr.row-inactive td { background: #FAF7F4; color: #9AA39D; }
tr.row-inactive img.student-avatar { filter: grayscale(1); opacity: .6; }
tr.row-inactive .badge:not(.badge-inactive) { opacity: .55; }

.badge-inactive {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #F1D3CF;
    margin-left: 6px;
    font-size: .68rem;
    letter-spacing: .4px;
    text-transform: uppercase;
    vertical-align: middle;
}

.btn-restore {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid #CDE5D5;
    transition: var(--transition);
}
.btn-restore:hover { background: var(--success); color: #fff; }

/* Admin toggle: "Show deactivated records" */
.toggle-inactive {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: .78rem;
    font-weight: 700;
    color: var(--muted);
    text-decoration: none;
    padding: 5px 12px 5px 6px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    white-space: nowrap;
}
.toggle-inactive .switch {
    width: 28px; height: 16px; border-radius: 999px;
    background: #D5DCD4; position: relative; transition: var(--transition);
}
.toggle-inactive .switch::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 12px; height: 12px; border-radius: 50%; background: #fff;
    transition: var(--transition); box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle-inactive.on { color: var(--danger); border-color: #F1D3CF; background: var(--danger-soft); }
.toggle-inactive.on .switch { background: var(--danger); }
.toggle-inactive.on .switch::after { left: 14px; }
.toggle-inactive .count {
    background: var(--bg-deep); color: var(--ink);
    border-radius: 999px; padding: 0 7px; font-size: .72rem;
}
.toggle-inactive:hover { border-color: #C5D2C8; color: var(--ink); }

/* Role badges + legend (users page) */
.badge.role-admin   { background: var(--accent-soft); color: #7A5717; }
.badge.role-manager { background: #E4EDF3; color: #3F6479; }
.badge.role-user    { background: var(--primary-soft); color: var(--primary-deep); }
.role-legend {
    display: flex; flex-wrap: wrap; gap: 8px 18px;
    font-size: .8rem; color: var(--muted); margin: -6px 0 14px;
}
.role-legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* =====================================================================
   COURSE PARTICIPANTS (course_view.php) & STUDENT COURSE HISTORY
===================================================================== */
.back-link { display: inline-block; margin-bottom: 14px; font-weight: 700; font-size: .88rem; text-decoration: none; }
.person-link { color: var(--primary-deep); text-decoration: none; border-bottom: 1px dotted rgba(53, 87, 74, .4); }
.person-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

.course-hero {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap;
    background: var(--surface); border: 1px solid rgba(225, 231, 221, .8);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px 28px; margin-bottom: 20px;
}
.course-hero h1 { margin: 8px 0 4px; font-size: 2.1rem; }
.course-hero-top { display: flex; gap: 8px; flex-wrap: wrap; }
.course-meta { margin: 0; color: var(--ink); }
.course-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.course-hero-actions form { margin: 0; }
.badge.phase-upcoming    { background: #E4EDF3; color: #3F6479; }
.badge.phase-in-progress { background: var(--accent-soft); color: #7A5717; }
.badge.phase-finished    { background: var(--bg-deep); color: var(--muted); }

.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 22px; }
.mini-stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 16px; font-size: .78rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .6px; border-top: 3px solid var(--primary);
}
.mini-stat span { display: block; font-family: var(--font-heading); font-size: 2rem; line-height: 1.1; color: var(--primary-deep); text-transform: none; letter-spacing: 0; }
.mini-stat.ok   { border-top-color: var(--success); }
.mini-stat.bad  { border-top-color: var(--danger); }
.mini-stat.gold { border-top-color: var(--accent); }

.count-pill {
    font-family: var(--font-body); font-size: .75rem; font-weight: 800;
    background: var(--bg-deep); color: var(--ink); border-radius: 999px; padding: 2px 10px;
}
.card h3 .count-pill { margin-left: auto; }
.empty-note { color: var(--muted); font-style: italic; margin: 4px 0; }

/* Student / Teacher switch */
.seg { display: flex; gap: 6px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.seg label { position: relative; flex: 1; text-align: center; padding: 7px 10px; border-radius: 999px; cursor: pointer; font-size: .88rem; color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(78,122,100,.25); }
select[size] { padding: 6px; }
select[size] option { padding: 6px 8px; border-radius: 6px; }

/* Participation & result badges */
.badge.part-sitting  { background: var(--primary-soft); color: var(--primary-deep); }
.badge.part-service  { background: var(--accent-soft); color: #7A5717; }
.badge.part-teaching { background: #EDE7F3; color: #5B4A74; }
.badge.st-registered   { background: #E4EDF3; color: #3F6479; }
.badge.st-completed    { background: var(--success-soft); color: var(--success); }
.badge.st-discontinued { background: var(--danger-soft); color: var(--danger); }

/* Inline "Update" editor in participant rows */
details.row-editor { position: relative; }
details.row-editor summary { list-style: none; }
details.row-editor summary::-webkit-details-marker { display: none; }
details.row-editor[open] summary { background: var(--warning); color: #fff; }
.status-form {
    margin-top: 8px; width: 240px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 14px; display: grid; gap: 10px;
}
.status-form label { display: grid; gap: 4px; font-size: .75rem; }
.status-form input, .status-form select { padding: 7px 10px; font-size: .85rem; }

/* Student profile: history summary + quick assign */
.history-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.hs-item {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px;
}
.hs-item strong { font-size: .85rem; color: var(--primary-deep); margin-right: 4px; }
.inline-assign { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.inline-assign select { width: auto; max-width: 340px; padding: 8px 12px; }

/* =====================================================================
   DISCONTINUED / LEFT EARLY
===================================================================== */
tr.row-left td { background: #FDF6F5; }
tr.row-left td:first-child { box-shadow: inset 4px 0 0 var(--danger); }

.left-early-box {
    background: var(--danger-soft);
    border: 1px solid #F1D3CF;
    border-left: 5px solid var(--danger);
    border-radius: var(--radius-lg);
    padding: 16px 22px;
    margin-bottom: 22px;
}
.left-early-box h3 {
    margin: 0 0 10px; padding: 0; border: 0;
    color: var(--danger); font-size: 1.35rem; display: flex; align-items: center; gap: 10px;
}
.left-early-box ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.left-early-box li {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
    background: rgba(255,255,255,.7); border-radius: var(--radius-sm); padding: 8px 12px;
}
.le-when   { font-weight: 800; color: var(--danger); font-size: .88rem; }
.le-reason { font-style: italic; color: var(--ink); font-size: .88rem; }

.chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 9px; margin: 2px 3px 2px 0; border-radius: 999px;
    font-size: .74rem; font-weight: 800; text-decoration: none; white-space: nowrap;
}
.chip.ok  { background: var(--success-soft); color: var(--success); }
.chip.bad { background: var(--danger-soft);  color: var(--danger); border: 1px solid #F1D3CF; }
.chip.reg { background: #E4EDF3; color: #3F6479; }
.chip.srv { background: var(--accent-soft); color: #7A5717; }
a.chip.bad:hover { background: var(--danger); color: #fff; }
.record-line { margin-top: 4px; font-size: .72rem; color: var(--muted); }
option.opt-warn { color: var(--danger); }

/* =====================================================================
   "UPDATE RESULT" WINDOW (course_view.php)
===================================================================== */
.result-dialog {
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    border: 0;
    border-radius: 20px;
    padding: 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 30px 80px rgba(30, 45, 38, .35);
}
.result-dialog::backdrop { background: rgba(35, 50, 42, .45); backdrop-filter: blur(3px); }
.result-dialog[open] { animation: fadeIn .25s var(--ease); }
.result-dialog form { padding: 24px 28px 26px; }
.result-dialog .form-group { margin-bottom: 18px; }
.result-dialog label { font-size: .9rem; }
.result-dialog input, .result-dialog select, .result-dialog textarea { font-size: 1rem; padding: 12px 14px; }

.rd-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 18px;
}
.rd-head h2 { margin: 0; font-size: 1.7rem; }
.rd-head p { margin: 2px 0 0; font-size: 1rem; }
.rd-close {
    border: 0; background: var(--surface-soft); color: var(--muted);
    width: 38px; height: 38px; border-radius: 50%; font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.rd-close:hover { background: var(--danger-soft); color: var(--danger); }

.result-choices { display: grid; gap: 10px; }
.rc { position: relative; display: block; cursor: pointer; }
.rc input { position: absolute; opacity: 0; pointer-events: none; }
.rc span {
    display: block; padding: 12px 16px; border-radius: var(--radius);
    border: 2px solid var(--line); background: var(--surface-soft);
    font-size: 1rem; font-weight: 800; color: var(--ink); transition: var(--transition);
}
.rc span small { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-top: 2px; }
.rc:hover span { border-color: #C5D2C8; }
.rc-registered input:checked + span   { border-color: #3F6479; background: #E4EDF3; color: #3F6479; }
.rc-completed input:checked + span    { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.rc-discontinued input:checked + span { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.rc input:focus-visible + span { outline: 3px solid rgba(78, 122, 100, .35); outline-offset: 2px; }

.rd-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.rd-actions .btn { padding: 12px 22px; font-size: .95rem; }
@media (max-width: 520px) {
    .result-dialog form { padding: 18px; }
    .rd-actions .btn { flex: 1; }
}

/* Conducting teachers (several per course) */
.teacher-chip {
    display: inline-flex; align-items: center; gap: 4px;
    margin: 2px 6px 2px 0; padding: 3px 10px; border-radius: 999px;
    background: #EDE7F3; color: #5B4A74; font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.course-meta.conducting { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.check-list {
    max-height: 220px; overflow-y: auto; display: grid; gap: 4px;
    border: 1px solid #D8E0D5; border-radius: var(--radius-sm); background: var(--surface-soft); padding: 6px;
}
.check-item {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    padding: 8px 10px; border-radius: 8px; font-size: .92rem; font-weight: 600; color: var(--ink); letter-spacing: 0;
}
.check-item:hover { background: var(--primary-soft); }
.check-item input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--primary); margin: 0; }
.check-item:has(input:checked) { background: #EDE7F3; }

/* =====================================================================
   A4 PRINTABLE COURSE REGISTER (course_register.php)
===================================================================== */
.register-sheet {
    background: #fff;
    color: #000;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    overflow-x: auto;
}
.reg-head {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 26px;
    border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 10px;
}
.reg-title { display: flex; flex-direction: column; margin-right: auto; }
.reg-title strong { font-family: var(--font-heading); font-size: 1.35rem; color: #000; }
.reg-title span { font-size: .85rem; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.reg-meta { font-size: .82rem; line-height: 1.5; }
.reg-meta span { color: #555; }
.reg-group {
    align-self: center; border: 2px solid #000; border-radius: 6px;
    padding: 5px 16px; font-size: 1rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
}

table.reg-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.reg-table th, .reg-table td {
    border: 1px solid #000;
    padding: 3px 4px;
    font-size: 8.5pt;
    line-height: 1.25;
    vertical-align: top;
    text-align: left;
    color: #000;
    background: #fff;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    text-transform: none;
    letter-spacing: 0;
}
.reg-table th { font-weight: 800; text-align: center; font-size: 7.6pt; line-height: 1.15; padding: 4px 2px; hyphens: auto; }
.reg-table td.c-no, .reg-table td.c-age, .reg-table td.c-num, .reg-table td.c-new { text-align: center; }
.reg-table .c-no    { width: 26px; }
.reg-table .c-name  { width: 120px; }
.reg-table .c-addr  { width: 140px; }
.reg-table .c-age   { width: 30px; }
.reg-table .c-new   { width: 38px; }
.reg-table .c-num   { width: 32px; }
.reg-table .c-num-wide { width: 44px; }
.reg-table .c-edu   { width: 76px; }
.reg-table .c-occ   { width: 76px; }
.reg-table .c-blank { width: 42px; }
.reg-table .c-other { width: 70px; }
.reg-table td.c-name small { display: block; font-size: 7pt; color: #444; }
.reg-table tbody tr { height: 26px; }
.reg-table tbody tr:hover { background: #fff; }
.reg-table .blank-row td { height: 30px; }

.reg-foot {
    display: flex; flex-wrap: wrap; gap: 8px 30px; align-items: center;
    margin-top: 10px; font-size: .82rem;
}
.reg-foot span { color: #555; }
.reg-foot .sign { margin-left: auto; }

/* ---------- printing ---------- */
@media print {
    @page { size: A4 landscape; margin: 8mm; }
    html, body {
        background: #fff !important;
        background-image: none !important;
        font-size: 11px;
        color: #000;
    }
    .site-header, .site-footer, .no-print, .page-intro, .alert { display: none !important; }
    .page { max-width: none; padding: 0; margin: 0; animation: none; }
    .register-sheet { border: 0; border-radius: 0; padding: 0; overflow: visible; }
    .reg-table { page-break-inside: auto; }
    .reg-table thead { display: table-header-group; }   /* repeat the header on every page */
    .reg-table tr { page-break-inside: avoid; break-inside: avoid; }
    .reg-table tbody { break-inside: auto; }
    .reg-table tbody tr:last-child td { border-bottom: 1px solid #000; }
    .reg-foot { page-break-inside: avoid; }
    a[href]::after { content: none !important; }
}

/* Seat numbers & a teacher sitting the course */
.reg-table td.seat-no { font-weight: 800; text-align: center; }
.reg-table tr.reg-teacher td { background: #F4F4F4; }
@media print { .reg-table tr.reg-teacher td { background: #fff; font-weight: 600; } }


/* ---- Blocked (permanently locked) accounts --------------------------- */
.badge-blocked {
    background: #FBE9E7;
    color: #8E2B20;
    border: 1px solid #E8B4AC;
    font-weight: 600;
}
.action-cell form { display: inline-block; margin: 0; }
