/* =========================================================
   คลังข้อมูลคณะวิทยาศาสตร์และเทคโนโลยี — ธีมสีเหลืองประจำคณะ
   ========================================================= */
:root {
    --brand: #f2b705;
    --brand-600: #d99f00;
    --brand-700: #a67a00;
    --brand-soft: #fff6d6;
    --brand-ink: #2a2100;

    --sidebar-bg: #1b1d23;
    --sidebar-fg: #b9bcc6;
    --sidebar-hover: #262932;
    --sidebar-w: 264px;

    --radius: 14px;
    --radius-sm: 10px;

    --bs-body-font-family: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-body-font-size: .9375rem;
    --bs-primary: var(--brand);
    --bs-primary-rgb: 242, 183, 5;
    --bs-link-color: #8a6500;
    --bs-link-color-rgb: 138, 101, 0;
    --bs-link-hover-color: #5e4500;
    --bs-link-hover-color-rgb: 94, 69, 0;
    --bs-focus-ring-color: rgba(242, 183, 5, .35);
    --bs-border-radius: 10px;
    --bs-border-radius-lg: 14px;
}

[data-bs-theme="light"] {
    --bs-body-bg: #f6f5f1;
    --bs-body-color: #22252c;
    --bs-secondary-color: #6b6f7a;
    --bs-border-color: #e6e3da;
    --surface: #ffffff;
    --surface-2: #faf9f6;
}

[data-bs-theme="dark"] {
    --bs-body-bg: #121318;
    --bs-body-color: #e6e7ea;
    --bs-border-color: #2b2e37;
    --bs-link-color: #f6cb4a;
    --bs-link-color-rgb: 246, 203, 74;
    --bs-link-hover-color: #ffe08a;
    --bs-link-hover-color-rgb: 255, 224, 138;
    --surface: #1a1c22;
    --surface-2: #20232a;
    --brand-soft: rgba(242, 183, 5, .12);
    --sidebar-bg: #0e0f13;
    --sidebar-hover: #1b1d24;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: "Mitr", var(--bs-body-font-family);
    font-weight: 500;
    letter-spacing: 0;
    color: var(--bs-body-color);
}
.hero h2 { color: var(--brand-ink); }

.pagination {
    --bs-pagination-color: var(--bs-body-color); --bs-pagination-bg: var(--surface);
    --bs-pagination-border-color: var(--bs-border-color); --bs-pagination-hover-bg: var(--surface-2);
    --bs-pagination-hover-color: var(--bs-body-color); --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(242,183,5,.25);
    --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-active-color: var(--brand-ink);
    --bs-pagination-disabled-bg: var(--surface); --bs-pagination-disabled-border-color: var(--bs-border-color);
}
.btn-primary { background-image: none; }

a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.min-w-0 { min-width: 0; }
.skip-link { position: absolute; top: .5rem; left: .5rem; z-index: 2000; background: var(--brand); color: var(--brand-ink); padding: .5rem 1rem; border-radius: 8px; }

/* ---------- Layout ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--sidebar-bg); color: var(--sidebar-fg);
    display: flex; flex-direction: column; z-index: 1045;
}
@media (min-width: 992px) {
    .sidebar.offcanvas-lg { visibility: visible !important; transform: none !important; background-color: var(--sidebar-bg) !important; }
    .app-main { margin-left: var(--sidebar-w); }
}
@media (max-width: 991.98px) {
    .sidebar.offcanvas-lg { --bs-offcanvas-width: var(--sidebar-w); --bs-offcanvas-bg: var(--sidebar-bg); }
}

.sidebar-brand { display: flex; align-items: center; padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-brand a:hover { text-decoration: none; }
.brand-logo {
    width: 42px; height: 42px; border-radius: 12px; background: var(--brand);
    display: grid; place-items: center; overflow: hidden; flex: none; color: var(--brand-ink); font-size: 1.2rem;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: "Mitr", sans-serif; font-weight: 500; color: #fff; font-size: 1rem; }
.brand-text small { color: var(--sidebar-fg); font-size: .75rem; }

.sidebar-nav { padding: 1rem .75rem; flex: 1; overflow-y: auto; }
.nav-label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #6f7380; padding: 0 .75rem .5rem; }
.sidebar .nav-item {
    display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; margin-bottom: 2px;
    color: var(--sidebar-fg); border-radius: var(--radius-sm); position: relative; transition: background .15s, color .15s;
}
.sidebar .nav-item i { width: 1.25rem; text-align: center; opacity: .85; }
.sidebar .nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar .nav-item.active { background: rgba(242,183,5,.12); color: #ffd24d; font-weight: 500; }
.sidebar .nav-item.active::before {
    content: ""; position: absolute; left: -.75rem; top: 8px; bottom: 8px; width: 4px;
    background: var(--brand); border-radius: 0 4px 4px 0;
}
.sidebar .nav-item.active i { opacity: 1; }

.sidebar-user {
    display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.06); color: #fff;
}
.status-dot { color: var(--sidebar-fg); font-size: .75rem; }
.status-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #34c759; margin-right: 5px; vertical-align: 1px; }
.btn-sidebar { color: var(--sidebar-fg); }
.btn-sidebar:hover { color: #fff; background: var(--sidebar-hover); }

.app-main { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
    padding: .7rem 1.5rem; background: color-mix(in srgb, var(--bs-body-bg) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--bs-border-color);
}
.breadcrumb { font-size: .875rem; --bs-breadcrumb-divider-color: var(--bs-secondary-color); }
.breadcrumb a { color: var(--bs-secondary-color); }
.content { padding: 1.75rem 1.5rem 2rem; flex: 1; width: 100%; max-width: 1440px; }
@media (min-width: 1200px) { .content { padding: 2rem 2.25rem; } }
.app-footer { padding: 1rem 2.25rem 1.5rem; font-size: .8rem; color: var(--bs-secondary-color); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-title { font-size: 1.6rem; margin: 0; }
.page-subtitle { color: var(--bs-secondary-color); margin: .25rem 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Components ---------- */
.card, .panel {
    background: var(--surface); border: 1px solid var(--bs-border-color); border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(20, 20, 10, .04);
}
.card { --bs-card-bg: var(--surface); --bs-card-border-color: var(--bs-border-color); --bs-card-border-radius: var(--radius); --bs-card-cap-bg: transparent; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--bs-border-color); flex-wrap: wrap; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; padding: .85rem 1.25rem; border-top: 1px solid var(--bs-border-color); font-size: .85rem; color: var(--bs-secondary-color); }

.btn { --bs-btn-font-weight: 500; border-radius: var(--radius-sm); }
.btn-primary, .btn-brand {
    --bs-btn-color: var(--brand-ink); --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-color: var(--brand-ink); --bs-btn-hover-bg: #ffc61a; --bs-btn-hover-border-color: #ffc61a;
    --bs-btn-active-color: var(--brand-ink); --bs-btn-active-bg: var(--brand-600); --bs-btn-active-border-color: var(--brand-600);
    --bs-btn-disabled-color: var(--brand-ink); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: 242, 183, 5;
}
.btn-light { --bs-btn-bg: var(--surface-2); --bs-btn-border-color: var(--bs-border-color); --bs-btn-color: var(--bs-body-color); --bs-btn-hover-bg: var(--bs-border-color); --bs-btn-hover-border-color: var(--bs-border-color); --bs-btn-hover-color: var(--bs-body-color); }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border-radius: 10px; color: var(--bs-secondary-color); border: 0; }
.btn-icon:hover { background: var(--surface-2); color: var(--bs-body-color); }
.btn-sm.btn-icon { width: 32px; height: 32px; }
.btn-ghost-danger:hover { background: rgba(220, 53, 69, .1); color: #dc3545; }
.btn-ghost-brand:hover { background: var(--brand-soft); color: var(--brand-700); }
[data-bs-theme="dark"] .btn-ghost-brand:hover { color: #ffd24d; }

.form-control, .form-select { border-radius: var(--radius-sm); padding: .55rem .85rem; background-color: var(--surface); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(242,183,5,.25); }
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .35rem; }
.form-text { font-size: .8rem; }
.req::after { content: " *"; color: #dc3545; }

.search-box { position: relative; min-width: 240px; flex: 1; max-width: 420px; }
.search-box i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); pointer-events: none; }
.search-box .form-control { padding-left: 2.35rem; }

/* Table */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--surface-2); margin: 0; }
.table > thead th {
    font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--bs-secondary-color); background: var(--surface-2); border-bottom-width: 1px; white-space: nowrap; padding: .75rem 1rem;
}
.table > tbody td { padding: .75rem 1rem; vertical-align: middle; border-color: var(--bs-border-color); }
.table > tbody tr:last-child td { border-bottom: 0; }
.cell-main { font-weight: 500; color: var(--bs-body-color); }
.cell-main:hover { color: var(--bs-link-hover-color); }
.cell-sub { font-size: .8rem; color: var(--bs-secondary-color); }
.row-actions { white-space: nowrap; text-align: right; }

/* Badges */
.badge { font-weight: 500; font-size: .78rem; padding: .4em .75em; border-radius: 999px; white-space: nowrap; }
.badge-soft-success { background: rgba(25, 135, 84, .12); color: #146c43; }
.badge-soft-warning { background: rgba(242, 183, 5, .18); color: #8a6500; }
.badge-soft-danger { background: rgba(220, 53, 69, .12); color: #b02a37; }
.badge-soft-secondary { background: rgba(108, 117, 125, .14); color: #565e64; }
.badge-soft-info { background: rgba(13, 110, 253, .1); color: #0a58ca; }
[data-bs-theme="dark"] .badge-soft-success { color: #75d6a5; }
[data-bs-theme="dark"] .badge-soft-warning { color: #ffd24d; }
[data-bs-theme="dark"] .badge-soft-danger { color: #f1919b; }
[data-bs-theme="dark"] .badge-soft-secondary { color: #b4bac0; }
[data-bs-theme="dark"] .badge-soft-info { color: #8bb9fe; }

/* Avatars */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; }
.avatar-sm { width: 34px; height: 34px; font-size: .85rem; }
.avatar-md { width: 40px; height: 40px; font-size: .95rem; }
.avatar-xl { width: 120px; height: 120px; font-size: 2.6rem; }
.avatar-initials { background: var(--brand-soft); color: var(--brand-700); font-family: "Mitr", sans-serif; }
[data-bs-theme="dark"] .avatar-initials { color: #ffd24d; }
.sidebar .avatar-initials { background: var(--brand); color: var(--brand-ink); }

/* Stat cards (dashboard) */
.stat { display: flex; gap: 1rem; align-items: center; padding: 1.25rem; height: 100%; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
a.stat:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(20,20,10,.07); border-color: var(--brand); text-decoration: none; color: inherit; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex: none; background: var(--brand-soft); color: var(--brand-700); }
[data-bs-theme="dark"] .stat-icon { color: #ffd24d; }
.stat-value { font-family: "Mitr", sans-serif; font-size: 1.75rem; line-height: 1.1; font-weight: 500; }
.stat-label { color: var(--bs-secondary-color); font-size: .875rem; }

.hero {
    position: relative; overflow: hidden; padding: 1.75rem; border-radius: var(--radius);
    background: linear-gradient(120deg, #f2b705 0%, #ffd54f 60%, #ffe58a 100%); color: var(--brand-ink); border: 0;
}
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%; background: rgba(255,255,255,.22); }
.hero h2 { font-size: 1.35rem; margin-bottom: .35rem; }
.hero p { margin: 0; opacity: .85; }

.progress-thin { height: 8px; border-radius: 99px; background: var(--surface-2); }
.progress-thin .progress-bar { border-radius: 99px; }

/* Forms */
.form-section { padding: 1.5rem; }
.form-section + .form-section { border-top: 1px solid var(--bs-border-color); }
.form-section-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.1rem; }
.form-section-head h2 { font-size: 1rem; margin: 0; }
.form-section-head i { color: var(--brand-600); }
.section-no { width: 26px; height: 26px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-700); display: grid; place-items: center; font-size: .8rem; font-weight: 600; }
[data-bs-theme="dark"] .section-no { color: #ffd24d; }
.form-actions {
    position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.5rem;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
    border-top: 1px solid var(--bs-border-color); border-radius: 0 0 var(--radius) var(--radius);
}
.photo-picker { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.photo-picker .preview { width: 96px; height: 96px; border-radius: 16px; object-fit: cover; border: 1px dashed var(--bs-border-color); background: var(--surface-2); display: grid; place-items: center; color: var(--bs-secondary-color); font-size: 1.5rem; overflow: hidden; }
.photo-picker .preview img { width: 100%; height: 100%; object-fit: cover; }

/* Student rows (งานวิจัยนักศึกษา) */
.student-head, .student-row { display: grid; grid-template-columns: minmax(110px, 180px) 1fr 36px; gap: .5rem; align-items: center; }
.student-head { font-size: .8rem; font-weight: 500; color: var(--bs-secondary-color); margin-bottom: .35rem; }
.student-row + .student-row { margin-top: .5rem; }
@media (max-width: 575.98px) {
    .student-head { display: none; }
    .student-row { grid-template-columns: 1fr 36px; }
    .student-row input[name="student_code[]"] { grid-column: 1 / -1; }
}
.file-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border-radius: 8px; font-size: .8rem; font-weight: 500;
    background: rgba(220, 53, 69, .08); color: #b02a37; white-space: nowrap; }
.file-chip:hover { background: rgba(220, 53, 69, .15); color: #b02a37; text-decoration: none; }
[data-bs-theme="dark"] .file-chip { color: #f1919b; }

/* Research preview */
.research-cover { padding: 1.75rem; border-top: 4px solid var(--brand); }
.research-title { font-size: 1.35rem; line-height: 1.55; margin-bottom: 1.5rem; }
.research-label { font-family: var(--bs-body-font-family); font-size: .75rem; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); margin: 1.25rem 0 .6rem; }
.student-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.student-list li { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.abstract-viewer { width: 100%; flex: 1; min-height: 70vh; border: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface-2); }
.research-nav .btn { max-width: 48%; }
@media print {
    .research-nav, .abstract-viewer { display: none !important; }
    .content { max-width: none; padding: 0; }
}

/* Profile */
.profile-card { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; padding: 1.5rem; }
.info-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.info-list dt { font-size: .78rem; color: var(--bs-secondary-color); font-weight: 400; margin-bottom: .15rem; }
.info-list dd { margin: 0; font-weight: 500; word-break: break-word; }

.nav-tabs-modern { border: 0; gap: .25rem; padding: .5rem .75rem 0; border-bottom: 1px solid var(--bs-border-color); }
.nav-tabs-modern .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--bs-secondary-color); padding: .75rem 1rem; border-radius: 0; font-weight: 500; }
.nav-tabs-modern .nav-link.active { color: var(--bs-body-color); background: none; border-bottom-color: var(--brand); }
.count-pill { display: inline-block; min-width: 1.6em; padding: 0 .45em; margin-left: .35rem; border-radius: 99px; font-size: .75rem; background: var(--surface-2); color: var(--bs-secondary-color); }

/* Empty state */
.empty { text-align: center; padding: 3rem 1rem; color: var(--bs-secondary-color); }
.empty i { font-size: 2.25rem; color: var(--brand); opacity: .7; margin-bottom: .75rem; }

/* Filters (chips) */
.chip-group { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { padding: .35rem .85rem; border-radius: 99px; border: 1px solid var(--bs-border-color); background: var(--surface); color: var(--bs-body-color); font-size: .85rem; }
.chip:hover { border-color: var(--brand); text-decoration: none; color: var(--bs-body-color); }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 500; }

/* Toast */
.toast { border: 0; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.12); background: var(--surface); border-left: 4px solid var(--bs-secondary-color); }
.toast-success { border-left-color: #198754; } .toast-success i.fa-solid { color: #198754; }
.toast-danger  { border-left-color: #dc3545; } .toast-danger i.fa-solid { color: #dc3545; }
.toast-warning { border-left-color: var(--brand); } .toast-warning i.fa-solid { color: var(--brand-600); }
.toast-info    { border-left-color: #0d6efd; } .toast-info i.fa-solid { color: #0d6efd; }

.modal-content { border: 0; border-radius: 18px; background: var(--surface); }
.confirm-icon { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: rgba(220,53,69,.1); color: #dc3545; }

/* Theme toggle icons */
[data-bs-theme="light"] .theme-icon-light, [data-bs-theme="dark"] .theme-icon-dark { display: none; }

/* ---------- Auth pages ---------- */
.auth {
    min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--bs-body-bg);
}
@media (min-width: 992px) { .auth { grid-template-columns: 1.1fr 1fr; } }
.auth-art {
    display: none; position: relative; overflow: hidden; padding: 3rem; color: var(--brand-ink);
    background: radial-gradient(circle at 20% 20%, #ffe58a 0, transparent 45%), radial-gradient(circle at 80% 80%, #ffd54f 0, transparent 50%), #f2b705;
}
@media (min-width: 992px) { .auth-art { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-art h1 { font-size: 2.3rem; line-height: 1.3; max-width: 14em; }
.auth-art .orb { position: absolute; border-radius: 50%; border: 2px solid rgba(42,33,0,.12); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand-logo { width: 56px; height: 56px; border-radius: 16px; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); }
.input-icon .form-control { padding-left: 2.5rem; height: 48px; }
.input-icon .toggle-pass { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); }

@media print {
    .sidebar, .topbar, .page-actions, .row-actions, .app-footer, .panel-head form { display: none !important; }
    .app-main { margin: 0 !important; }
}

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