/* ============================================================
   style.css — ทำเนียบบุคลากรโรงเรียนจอมสุรางค์อุปถัมภ์
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&family=Noto+Sans+Thai:wght@300;400;500;600;700&display=swap');

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy:        #0a1628;
    --navy-mid:    #112240;
    --navy-light:  #1e3a5f;
    --gold:        #c9973a;
    --gold-light:  #e8b84b;
    --gold-pale:   #fdf3dc;
    --cream:       #fdf8f0;
    --white:       #ffffff;
    --text-dark:   #1a1a2e;
    --text-mid:    #3d4060;
    --text-light:  #6b7280;
    --border:      #e8dfc8;
    --shadow-sm:   0 2px 8px rgba(10,22,40,.08);
    --shadow-md:   0 6px 24px rgba(10,22,40,.14);
    --shadow-lg:   0 12px 40px rgba(10,22,40,.2);
    --radius:      14px;
    --radius-sm:   8px;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Sarabun', 'Noto Sans Thai', sans-serif;
    background: var(--cream);
    color: var(--text-dark);
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, var(--navy-light) 100%);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.4));
    flex-shrink: 0;
    transition: transform .3s;
}
.header-logo:hover { transform: scale(1.06); }

.header-titles {
    flex: 1;
}

.header-subtitle {
    font-size: .78rem;
    font-weight: 500;
    color: var(--gold-light);
    letter-spacing: .12em;
    text-transform: uppercase;
    opacity: .85;
}

.header-title {
    font-size: clamp(1.2rem, 3vw, 1.75rem);
    font-weight: 800;
    color: var(--white);
    line-height: 1.25;
    text-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.header-title span {
    color: var(--gold-light);
}

.header-nav {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all .25s;
    white-space: nowrap;
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--navy);
    box-shadow: 0 3px 12px rgba(201,151,58,.4);
}
.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(201,151,58,.5);
}

.btn-outline {
    background: transparent;
    color: var(--white);
    border: 2px solid rgba(255,255,255,.3);
}
.btn-outline:hover {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.6);
}

/* ============================================================
   HERO BANNER
   ============================================================ */
.hero {
    background: linear-gradient(160deg, var(--navy-mid) 0%, var(--navy-light) 100%);
    padding: 56px 24px 48px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 70% 50%, rgba(201,151,58,.15) 0%, transparent 70%);
}

.hero-content { position: relative; z-index: 1; }

.hero-badge {
    display: inline-block;
    background: rgba(201,151,58,.2);
    color: var(--gold-light);
    border: 1px solid rgba(201,151,58,.4);
    border-radius: 50px;
    padding: 6px 20px;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .1em;
    margin-bottom: 16px;
}

.hero h1 {
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    font-weight: 800;
    color: var(--white);
    margin-bottom: 10px;
    text-shadow: 0 4px 20px rgba(0,0,0,.3);
}

.hero p {
    font-size: 1.05rem;
    color: rgba(255,255,255,.7);
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px 24px;
    flex: 1;
    width: 100%;
}

/* ---- Section Heading ---- */
.section-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--border);
}

.section-heading .icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--navy), var(--navy-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.section-heading h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--navy);
}
.section-heading p {
    font-size: .85rem;
    color: var(--text-light);
}

/* ---- Director Section ---- */
.director-section {
    margin-bottom: 56px;
}

.director-card {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
    border-radius: var(--radius);
    padding: 40px;
    display: flex;
    align-items: center;
    gap: 40px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    max-width: 700px;
    margin: 0 auto;
}

.director-card::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(201,151,58,.2) 0%, transparent 70%);
    border-radius: 50%;
}

.director-photo {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--gold);
    box-shadow: 0 0 0 8px rgba(201,151,58,.2), var(--shadow-md);
    flex-shrink: 0;
    background: var(--navy-light);
    cursor: pointer;
    transition: transform .3s;
}
.director-photo:hover { transform: scale(1.05); }

.director-info { flex: 1; }
.director-role {
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .15em;
    color: var(--gold-light);
    text-transform: uppercase;
    margin-bottom: 6px;
}
.director-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1.3;
}
.director-dept {
    font-size: .9rem;
    color: rgba(255,255,255,.6);
    margin-top: 6px;
}

/* ---- Vice Directors ---- */
.vice-section {
    margin-bottom: 56px;
}

.vice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.vice-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all .3s;
    position: relative;
    overflow: hidden;
}

.vice-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

.vice-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--gold);
}

.vice-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gold-light);
    background: var(--gold-pale);
    margin: 0 auto 14px;
    display: block;
    cursor: pointer;
    transition: transform .3s;
}
.vice-photo:hover { transform: scale(1.07); }

.vice-role-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--navy), var(--navy-light));
    color: var(--gold-light);
    border-radius: 50px;
    padding: 3px 12px;
    font-size: .72rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: .05em;
}

.vice-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.35;
}

.vice-dept-label {
    font-size: .82rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* ---- Teachers Section ---- */
.teachers-section {
    margin-bottom: 48px;
}

.dept-group {
    margin-bottom: 44px;
}

.dept-header {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--white);
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-sm);
}

.dept-header .dept-icon {
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}

.dept-header .dept-count {
    margin-left: auto;
    background: var(--gold);
    color: var(--navy);
    border-radius: 50px;
    padding: 2px 10px;
    font-size: .8rem;
    font-weight: 700;
}

.teacher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.teacher-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 22px 14px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all .25s;
}

.teacher-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(201,151,58,.4);
}

.teacher-photo {
    width: 106px;
    height: 106px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold-light);
    background: var(--gold-pale);
    margin: 0 auto 12px;
    display: block;
    cursor: pointer;
    transition: transform .3s;
}
.teacher-photo:hover { transform: scale(1.08); }

.teacher-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.4;
}

/* ---- Dept Head ---- */
.dept-head-row {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.dept-head-card {
    border-color: var(--gold) !important;
    border-width: 2px !important;
    background: linear-gradient(160deg, #fffdf5 0%, var(--white) 100%) !important;
    box-shadow: 0 4px 20px rgba(201,151,58,.22) !important;
    min-width: 160px;
    max-width: 200px;
    position: relative;
}

.dept-head-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
    border-radius: var(--radius) var(--radius) 0 0;
}

.dept-head-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--navy);
    border-radius: 50px;
    padding: 3px 12px;
    font-size: .72rem;
    font-weight: 700;
    margin-top: 8px;
    margin-bottom: 4px;
    letter-spacing: .03em;
    box-shadow: 0 2px 6px rgba(201,151,58,.35);
}

/* In admin table */
.badge-dept-head {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--navy);
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 50px;
    display: inline-block;
    margin-left: 4px;
}

/* Checkbox toggle */
.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 16px;
    background: var(--gold-pale);
    border: 1.5px solid var(--gold);
    border-radius: var(--radius-sm);
    font-size: .93rem;
    font-weight: 600;
    color: #7d5a12;
    transition: background .2s;
}
.toggle-label:hover { background: #f5e0b0; }
.toggle-label input[type=checkbox] {
    width: 18px; height: 18px;
    accent-color: var(--gold);
    cursor: pointer;
}

/* staff / support same as teacher-card */
.staff-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 14px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: all .25s;
}

.staff-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(201,151,58,.3);
}

.staff-photo {
    width: 106px;
    height: 106px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    background: #f3f4f6;
    margin: 0 auto 12px;
    display: block;
    cursor: pointer;
    transition: transform .3s;
}
.staff-photo:hover { transform: scale(1.08); }

.staff-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.4;
}

/* Placeholder photo */
.photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: rgba(201,151,58,.5);
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(5, 10, 20, .88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: lbFadeIn .2s ease;
}
.lightbox-overlay.active { display: flex; }

@keyframes lbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.lightbox-inner {
    position: relative;
    text-align: center;
    animation: lbZoomIn .25s cubic-bezier(.34,1.56,.64,1);
}

@keyframes lbZoomIn {
    from { transform: scale(.7); opacity: 0; }
    to   { transform: scale(1);  opacity: 1; }
}

.lightbox-img {
    max-width: 88vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    border-radius: 16px;
    border: 4px solid var(--gold);
    box-shadow: 0 0 0 8px rgba(201,151,58,.15), 0 20px 60px rgba(0,0,0,.6);
    display: block;
    object-fit: contain;
}

.lightbox-caption {
    margin-top: 14px;
    color: var(--white);
    font-size: 1.05rem;
    font-weight: 600;
    text-shadow: 0 2px 8px rgba(0,0,0,.5);
}

.lightbox-close {
    position: absolute;
    top: -16px;
    right: -16px;
    width: 36px;
    height: 36px;
    background: var(--gold);
    color: var(--navy);
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
    transition: transform .2s, background .2s;
    line-height: 1;
}
.lightbox-close:hover { transform: scale(1.15); background: var(--gold-light); }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: var(--navy);
    color: rgba(255,255,255,.6);
    padding: 28px 24px;
    text-align: center;
    font-size: .88rem;
    line-height: 1.8;
}

.site-footer strong {
    color: var(--gold-light);
    font-weight: 600;
}

/* ============================================================
   ADMIN PAGES
   ============================================================ */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 260px;
    background: var(--navy);
    color: var(--white);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 24px 20px;
    background: rgba(0,0,0,.2);
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.sidebar-brand-text {
    font-size: .9rem;
    font-weight: 700;
    color: var(--gold-light);
    line-height: 1.3;
}

.sidebar-nav {
    list-style: none;
    padding: 16px 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 22px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: .93rem;
    font-weight: 500;
    transition: all .2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    color: var(--white);
    background: rgba(255,255,255,.07);
    border-left-color: var(--gold);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .82rem;
    color: rgba(255,255,255,.4);
}

.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--cream);
    overflow: hidden;
}

.admin-topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.admin-topbar h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--navy);
}

.admin-content {
    padding: 32px 28px;
    flex: 1;
    overflow-y: auto;
}

/* ---- Admin Cards ---- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--navy);
}

.card-body {
    padding: 24px;
}

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }

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

table.data-table th {
    background: var(--navy);
    color: var(--gold-light);
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

table.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table tr:hover td {
    background: var(--gold-pale);
}

.thumb-sm {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold-light);
    background: var(--gold-pale);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-navy  { background: #e8edf4; color: var(--navy); }
.badge-gold  { background: var(--gold-pale); color: #7d5a12; }
.badge-green { background: #d1fae5; color: #065f46; }

/* ---- Forms ---- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-mid);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .93rem;
    color: var(--text-dark);
    background: var(--white);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,151,58,.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Action buttons */
.btn-sm {
    padding: 6px 14px;
    font-size: .8rem;
}

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

.btn-edit {
    background: var(--gold-pale);
    color: #7d5a12;
    border: 1px solid var(--gold);
}
.btn-edit:hover { background: #f5e0b0; }

.btn-navy {
    background: var(--navy);
    color: var(--white);
    border: none;
}
.btn-navy:hover { background: var(--navy-light); }

/* Alert messages */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: .92rem;
    font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 22px 20px;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: .82rem;
    color: var(--text-light);
    margin-top: 6px;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    padding: 24px;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-box img {
    width: 80px;
    margin-bottom: 20px;
}

.login-box h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--navy);
    margin-bottom: 6px;
}

.login-box p {
    font-size: .88rem;
    color: var(--text-light);
    margin-bottom: 28px;
}

/* ============================================================
   Upload preview
   ============================================================ */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s;
}
.upload-area:hover { border-color: var(--gold); }
.upload-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gold-light);
    margin: 10px auto 0;
    display: block;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .header-inner { gap: 12px; }
    .header-logo  { width: 56px; height: 56px; }
    .director-card { flex-direction: column; text-align: center; }
    .teacher-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .admin-sidebar { display: none; }
    .form-row { grid-template-columns: 1fr; }
    .admin-topbar h1 { font-size: 1rem; }
}
