/* ============================================================
   ระบบ ITA วิทยาลัยการอาชีพเวียงสระ
   Design tokens: โทนน้ำเงินกรมท่า + ทอง (เอกลักษณ์สถานศึกษาไทย)
   ============================================================ */

:root {
    /* สีหลัก */
    --navy-900: #0d2a4a;
    --navy-800: #123a63;
    --navy-700: #1a4d7e;
    --navy-600: #235f99;
    --gold-500: #c9941f;
    --gold-400: #dba93f;
    --gold-100: #faf3e1;
    --cream-50: #f7f5ef;
    --ink-900: #1c1f24;
    --ink-600: #4a5160;
    --line: #e2dfd5;
    --white: #ffffff;
    --success: #1e7e4f;
    --danger: #b3261e;
    --warning: #b9831a;

    /* typography */
    --font-display: 'Sarabun', 'Noto Sans Thai', sans-serif;
    --font-body: 'Sarabun', 'Noto Sans Thai', sans-serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 2px 10px rgba(13, 42, 74, 0.08);
    --shadow-lift: 0 8px 24px rgba(13, 42, 74, 0.14);
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--white);
    color: var(--ink-900);
    margin: 0;
    line-height: 1.65;
}

a { text-decoration: none; color: var(--navy-700); }
a:hover { color: var(--gold-500); }

.masthead {
    padding-top: 24px;
}
.masthead-flex {
    display: flex;
    align-items: stretch;
    gap: 25px;
}

/* กล่องซ้าย: แบ่งเป็น 2 ส่วนในตัว (บน=ITA, ล่าง=ชื่อวิทยาลัย) */
.ita-box {
    width:280px;
    flex-shrink:0;
    border-radius:12px;
    overflow:hidden;
    box-shadow:0 5px 15px rgba(0, 0, 0,.1);
}
.ita-box .ita-box-top {
    flex: 1;
    background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
    color: var(--gold-400);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 3rem;
    letter-spacing: 0.05em;
    padding: 18px;
}
.ita-box .ita-box-bottom {
    background: var(--gold-500);
    color: var(--navy-900);
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    padding: 14px 16px;
    line-height: 1.4;
}

/* กล่องขวา: พื้นลายตารางกราฟ + ข้อความ ITA WCC */
.org-box {
    flex: 1;
    min-height: 168px;
    border-radius: 12px;
    overflow:hidden;
    background-image: url(../images/banner.png);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 5px 15px rgba(0, 0, 0,.1);
    position: relative;

}   

@media (max-width: 760px) {
    .ita-box { width: 100%; }
    .org-box { width: 100%; }
}

/* ===================== NAVIGATION ===================== */
.main-nav {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.main-nav .container {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding-top: 4px;
    padding-bottom: 4px;
}
.main-nav a.nav-link {
    display: inline-block;
    padding: 14px 16px;
    color: var(--navy-800);
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 3px solid transparent;
}
.main-nav a.nav-link:hover,
.main-nav a.nav-link.active {
    color: var(--navy-900);
    border-bottom-color: var(--gold-500);
    background: var(--gold-100);
}

/* ===================== CONTAINER ===================== */
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===================== YEAR SELECTOR BLOCK ===================== */
.year-panel {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    margin-top: 25px;
}

.year-panel-left{
    display: flex;
    flex-direction: column;
    gap: 20px;

}




@media (max-width: 760px) {
    .year-panel { grid-template-columns: 1fr; }
}

.year-box {
    background: var(--navy-900);
    border-radius: var(--radius-lg);
    color: var(--white);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 18px 14px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--navy-700);
}
.year-box .label {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--gold-400);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 12px;
    text-align: center;
}
.year-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.year-list-item {
    display: block;
    background: var(--navy-800);
    color: var(--white);
    border: 1px solid var(--navy-600);
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    text-align: center;
    transition: all .15s ease;
}
.year-list-item:hover {
    background: var(--navy-600);
    color: var(--white);
}
.year-list-item.active {
    background: var(--gold-500);
    color: var(--navy-900);
    border-color: var(--gold-500);
}
.year-list-empty {
    text-align: center;
    color: #b9cce3;
    font-size: 0.9rem;
    padding: 10px 0;
}

.year-box-divider {
    height: 1px;
    background: var(--navy-700);
    margin: 16px 0;
}

.year-list-item--alt {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    background: transparent;
    border: 1px solid var(--navy-600);
    color: #d7e3f0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
}
.year-list-item--alt:hover {
    background: var(--navy-800);
    color: var(--gold-400);
    border-color: var(--gold-500);
}

/* ===================== VISIT STATS (in year-box) ===================== */
.visit-stats-title {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--gold-400);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.visit-stats-row {
    display: flex;
    gap: 6px;
}
.visit-stat {
    flex: 1;
    background: var(--navy-800);
    border: 1px solid var(--navy-600);
    border-radius: var(--radius-sm);
    padding: 8px 4px;
    text-align: center;
}
.visit-stat b {
    display: block;
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--gold-400);
    line-height: 1.2;
}
.visit-stat span {
    font-size: 0.66rem;
    color: #d7e3f0;
    white-space: nowrap;
}

/* กล่องสถิติแยกใต้ year-box */
.visit-stats-box {
    background: var(--navy-900);
    border-radius: var(--radius-lg);
    border: 1px solid var(--navy-700);
    padding: 14px;
}
.visit-stats-box .visit-stats-title {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--gold-400);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.visit-stats-box .visit-stats-row {
    display: flex;
    gap: 6px;
}
.visit-stats-box .visit-stat {
    flex: 1;
    background: var(--navy-800);
    border: 1px solid var(--navy-600);
    border-radius: var(--radius-sm);
    padding: 8px 4px;
    text-align: center;
}
.visit-stats-box .visit-stat b {
    display: block;
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--gold-400);
    line-height: 1.2;
}
.visit-stats-box .visit-stat span {
    font-size: 0.66rem;
    color: #d7e3f0;
    white-space: nowrap;
}

/* ปุ่มร้องเรียน/ร้องทุกข์ */
.year-list-item--complaint {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 700;
    background: #7a1a1a;
    border: 1px solid #a02020;
    color: #ffd6d6;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    transition: all .15s ease;
}
.year-list-item--complaint:hover {
    background: #991f1f;
    color: #fff;
    border-color: #c02828;
}

/* captcha box */
.captcha-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--cream-50);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}
.captcha-question {
    font-weight: 700;
    color: var(--navy-900);
    font-size: 1rem;
    white-space: nowrap;
}
.captcha-box input {
    width: 80px;
    padding: 8px 10px;
    border: 1px solid #cfd6de;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-body);
    text-align: center;
}

.info-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--line);
    padding: 22px 26px;
}
.info-card--top {
    margin: 32px 0 0;
}
.info-card h2 {
    font-family: var(--font-display);
    color: var(--navy-900);
    font-size: 1.15rem;
    margin: 0 0 6px;
    font-weight: 800;
}
.info-card p {
    margin: 0;
    color: var(--ink-600);
    font-size: 0.95rem;
}
.info-card .stats-row {
    display: flex;
    gap: 28px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.info-card .stat b {
    display: block;
    font-size: 1.6rem;
    color: var(--navy-800);
    font-family: var(--font-display);
}
.info-card .stat span {
    font-size: 0.8rem;
    color: var(--ink-600);
}

/* ===================== TABLE: 3 COLUMNS DATA TABLE ===================== */
.data-section { margin: 28px 0 48px; }
.year-panel .data-section { margin: 0; min-width: 0; }

.category-banner {
    background: linear-gradient(90deg, var(--navy-800), var(--navy-700));
    color: var(--white);
    padding: 13px 20px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 5px solid var(--gold-500);
}

.ita-table-wrap {
    overflow-x: auto;
    box-shadow: var(--shadow-card);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    margin-bottom: 26px;
    border: 1px solid var(--line);
    border-top: none;
}
table.ita-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: 0.93rem;
}
table.ita-table thead th {
    background: var(--gold-100);
    color: var(--navy-900);
    text-align: left;
    padding: 12px 16px;
    font-weight: 700;
    border-bottom: 2px solid var(--gold-500);
    white-space: nowrap;
}
table.ita-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    color: var(--ink-900);
}
table.ita-table tbody tr:hover { background: #fbfaf6; }
table.ita-table tbody tr:last-child td { border-bottom: none; }

.code-chip {
    display: inline-block;
    background: var(--navy-900);
    color: var(--gold-400);
    font-weight: 800;
    font-family: var(--font-display);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
}

.attach-list { list-style: none; margin: 0; padding: 0; }
.attach-list li { margin-bottom: 6px; }
.attach-list a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    color: var(--navy-700);
    font-weight: 600;
}
.attach-list a:hover { color: var(--gold-500); text-decoration: underline; }

.element-desc {
    color: var(--ink-600);
    font-size: 0.88rem;
    white-space: pre-line;
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--ink-600);
}
.empty-state i { font-size: 2.4rem; color: var(--line); display: block; margin-bottom: 10px; }

/* ===================== FOOTER ===================== */
footer.site-footer {
    padding: 20px 0;
    margin-top: 40px;
    border-top: 1px solid var(--line);
}
.footer-simple {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.footer-copy{
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: var(--ink-600);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}
.admin-entry-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gold-500);
    color: var(--navy-900) !important;
    padding: 9px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
}
.admin-entry-link:hover { background: var(--gold-400); color: var(--navy-900) !important; }

/* ===================== Q&A PAGE ===================== */
.qa-intro {
    margin: 36px 0 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.qa-intro h1 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--navy-900);
    margin: 0 0 10px;
}
.qa-intro p {
    color: var(--ink-600);
    margin: 0 0 14px;
    max-width: 720px;
}
.qa-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--navy-700);
}

.qa-form-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 26px 28px;
    margin-bottom: 36px;
}
.qa-form-card h2 {
    font-family: var(--font-display);
    color: var(--navy-900);
    font-size: 1.1rem;
    margin: 0 0 16px;
}

.qa-list-section { margin-bottom: 48px; }
.qa-list-title {
    font-family: var(--font-display);
    color: var(--navy-900);
    font-size: 1.1rem;
    margin: 0 0 18px;
}

.qa-item {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 20px 22px;
    margin-bottom: 16px;
}
.qa-question-row, .qa-answer-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.qa-answer-row {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--line);
}
.qa-avatar {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--navy-900);
    color: var(--gold-400);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.qa-avatar-admin { background: var(--gold-500); color: var(--navy-900); }
.qa-question-body { flex: 1; min-width: 0; }
.qa-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.qa-meta strong { color: var(--navy-900); font-size: 0.95rem; }
.qa-date { color: var(--ink-600); font-size: 0.8rem; }
.qa-question-text { margin: 0; color: var(--ink-900); font-size: 0.94rem; line-height: 1.6; }
.qa-pending {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
    color: var(--warning);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.92rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s ease;
    font-family: var(--font-body);
}
.btn-primary { background: var(--navy-800); color: var(--white); }
.btn-primary:hover { background: var(--navy-900); color: var(--white); }
.btn-gold { background: var(--gold-500); color: var(--navy-900); }
.btn-gold:hover { background: var(--gold-400); }
.btn-outline { background: transparent; border-color: var(--navy-700); color: var(--navy-700); }
.btn-outline:hover { background: var(--navy-700); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #8f1e18; color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===================== ADMIN LAYOUT ===================== */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 250px;
    background: var(--navy-900);
    color: #d7e3f0;
    flex-shrink: 0;
    padding: 22px 0;
}
.admin-sidebar .brand {
    padding: 0 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 16px;
}
.admin-sidebar .brand b { color: var(--gold-400); font-family: var(--font-display); font-size: 1.2rem; }
.admin-sidebar .brand small { display: block; color: #93a9c2; font-size: 0.78rem; margin-top: 4px;}
.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    color: #c4d4e6;
    font-size: 0.92rem;
    font-weight: 600;
    border-left: 3px solid transparent;
}
.admin-sidebar a:hover, .admin-sidebar a.active {
    background: rgba(255,255,255,0.06);
    color: var(--white);
    border-left-color: var(--gold-500);
}
.admin-main { flex: 1; background: var(--cream-50); min-width: 0; }
.admin-topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.admin-topbar h1 { font-size: 1.2rem; margin: 0; color: var(--navy-900); font-family: var(--font-display); }
.admin-content { padding: 28px; }

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 24px;
    margin-bottom: 22px;
}
.card h2 { font-size: 1.05rem; color: var(--navy-900); margin: 0 0 16px; font-family: var(--font-display); }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--ink-900); font-size: 0.92rem; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cfd6de;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-body);
    background: var(--white);
    color: var(--ink-900);
}
.form-control:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(35,95,153,0.15); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: 0.8rem; color: var(--ink-600); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 0.92rem;
    vertical-align: middle;
}
.admin-table th { background: var(--gold-100); color: var(--navy-900); font-weight: 700; }
.admin-table tr:hover td { background: #fbfaf6; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; }
.badge-success { background: #e3f3ea; color: var(--success); }
.badge-muted { background: #eee; color: #777; }

.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.92rem; }
.alert-success { background: #e3f3ea; color: var(--success); border: 1px solid #bfe3cd; }
.alert-danger { background: #fbeae8; color: var(--danger); border: 1px solid #f3c8c4; }
.alert-info { background: #e8f1fa; color: var(--navy-700); border: 1px solid #c7ddf2; }

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--navy-900), var(--navy-700));
    padding: 20px;
}
.login-box {
    background: var(--white);
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    padding: 38px 34px;
    box-shadow: var(--shadow-lift);
    text-align: center;
}
.login-box .ita-emblem { margin: 0 auto 18px; width: 130px; }
.login-box h1 { font-size: 1.2rem; color: var(--navy-900); margin: 0 0 4px; font-family: var(--font-display); }
.login-box p.sub { color: var(--ink-600); font-size: 0.88rem; margin-bottom: 22px; }

.attachment-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
    padding: 14px 14px 14px 0;
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    position: relative;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.attachment-row:hover { border-color: #c7d6e8; box-shadow: 0 2px 8px rgba(13,42,74,0.06); }
.attachment-row .form-control { margin-bottom: 0; }
.attachment-row .remove-row { flex-shrink: 0; }

.row-index {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--navy-900);
    color: var(--gold-400);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    font-family: var(--font-display);
    margin-left: 14px;
    flex-shrink: 0;
}
.row-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gold-100);
    color: var(--gold-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-left: 14px;
    flex-shrink: 0;
}
.attachment-row .row-fields {
    flex: 1;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.attachment-row .row-fields .label-field { flex: 0 0 220px; }
.attachment-row .row-fields .value-field { flex: 1; min-width: 200px; }
@media (max-width: 700px) {
    .attachment-row .row-fields { flex-direction: column; }
    .attachment-row .row-fields .label-field { flex: 1; }
}
.remove-row-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--ink-600);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .15s ease;
    margin-right: 14px;
    flex-shrink: 0;
}
.remove-row-icon:hover { background: var(--danger); color: var(--white); border-color: var(--danger); }

.existing-file-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--cream-50);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
}
.existing-file-row .file-icon-badge {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--white);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}
.existing-file-row .file-info { flex: 1; min-width: 0; }
.existing-file-row .file-info a {
    font-weight: 700;
    color: var(--navy-900);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.existing-file-row .file-info small { color: var(--ink-600); font-size: 0.8rem; }

.file-drop-zone {
    border: 2px dashed #cfd6de;
    border-radius: var(--radius-md);
    background: var(--cream-50);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color .15s ease, background .15s ease;
    position: relative;
}
.file-drop-zone:hover { border-color: var(--gold-500); background: var(--gold-100); }
.file-drop-zone.has-file { border-style: solid; border-color: var(--success); background: #f1f9f4; }
.file-drop-zone .drop-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--navy-700);
    font-size: 1.2rem;
}
.file-drop-zone.has-file .drop-icon { color: var(--success); }
.file-drop-zone .drop-text { flex: 1; min-width: 0; }
.file-drop-zone .drop-text .drop-main { font-weight: 600; color: var(--navy-900); font-size: 0.92rem; }
.file-drop-zone .drop-text .drop-sub { font-size: 0.8rem; color: var(--ink-600); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop-zone input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.attach-empty {
    text-align: center;
    padding: 28px 16px;
    color: var(--ink-600);
    background: var(--cream-50);
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin-bottom: 14px;
}
.attach-empty i { font-size: 1.8rem; display: block; margin-bottom: 8px; color: #cfd6de; }

.section-subtitle {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--navy-700);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 4px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-subtitle::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.modal-overlay {
    position: fixed; inset: 0; background: rgba(13,42,74,0.55);
    display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--white); border-radius: var(--radius-lg); max-width: 440px; width: 100%;
    padding: 28px; box-shadow: var(--shadow-lift);
}
.modal-box h3 { margin: 0 0 10px; color: var(--navy-900); font-family: var(--font-display); }
.modal-box p { color: var(--ink-600); margin-bottom: 22px; font-size: 0.92rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===================== CHAT WIDGET (ถาม-ตอบกับแอดมิน, มุมขวาล่าง) ===================== */
.ita-chat-widget {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 500;
    font-family: var(--font-body);
}
.ita-chat-toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--gold-500);
    color: var(--navy-900);
    border: none;
    box-shadow: var(--shadow-lift);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform .15s ease, background .15s ease;
}
.ita-chat-toggle:hover {
    background: var(--gold-400);
    transform: scale(1.05);
}
.ita-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.ita-chat-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 330px;
    max-height: 480px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    border: 1px solid var(--line);
    flex-direction: column;
    overflow: hidden;
}
.ita-chat-header {
    background: linear-gradient(135deg, var(--navy-700), var(--navy-900));
    color: var(--white);
    padding: 14px 16px;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.ita-chat-close {
    background: transparent;
    border: none;
    color: var(--white);
    opacity: 0.8;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 4px;
}
.ita-chat-close:hover { opacity: 1; }

.ita-chat-name-prompt {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--cream-50);
}
.ita-chat-name-prompt input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-size: 0.82rem;
    font-family: var(--font-body);
}

.ita-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--cream-50);
    min-height: 220px;
    max-height: 320px;
}
.ita-chat-welcome {
    color: var(--ink-600);
    font-size: 0.85rem;
    text-align: center;
    padding: 18px 8px;
    line-height: 1.6;
}
.ita-chat-welcome i { font-size: 1.6rem; display: block; margin-bottom: 8px; color: var(--gold-500); }

.ita-chat-msg { display: flex; flex-direction: column; max-width: 82%; }
.ita-chat-msg .bubble {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
}
.ita-chat-msg time { font-size: 0.65rem; color: var(--ink-600); margin-top: 3px; opacity: 0.75; }
.ita-chat-msg.guest { align-self: flex-end; align-items: flex-end; }
.ita-chat-msg.guest .bubble { background: var(--navy-800); color: var(--white); }
.ita-chat-msg.admin { align-self: flex-start; align-items: flex-start; }
.ita-chat-msg.admin .bubble { background: var(--white); border: 1px solid var(--line); color: var(--ink-900); }

.ita-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    background: var(--white);
}
.ita-chat-input-row input {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 0.85rem;
    font-family: var(--font-body);
}
.ita-chat-input-row button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gold-500);
    color: var(--navy-900);
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}
.ita-chat-input-row button:hover { background: var(--gold-400); }

@media (max-width: 480px) {
    .ita-chat-panel { width: calc(100vw - 32px); right: -6px; }
    .ita-chat-widget { right: 16px; bottom: 16px; }
}

/* ===================== ADMIN: CHAT INBOX (admin/chat.php) ===================== */
.achat-wrap {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: calc(100vh - 140px);
    min-height: 480px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    border: 1px solid var(--line);
}
@media (max-width: 860px) {
    .achat-wrap { grid-template-columns: 1fr; height: auto; }
    .achat-sidebar { max-height: 280px; }
}

.achat-sidebar {
    border-right: 1px solid var(--line);
    overflow-y: auto;
    background: var(--cream-50);
    display: flex;
    flex-direction: column;
}
.achat-sidebar-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--navy-900);
    padding: 16px;
    margin: 0;
    border-bottom: 1px solid var(--line);
    background: var(--white);
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
}
.achat-loading, .achat-empty-list {
    padding: 28px 16px;
    text-align: center;
    color: var(--ink-600);
    font-size: 0.88rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.achat-loading i { font-size: 1.4rem; animation: achat-spin 1s linear infinite; }
@keyframes achat-spin { to { transform: rotate(360deg); } }
.achat-empty-list i { font-size: 1.6rem; color: var(--line); }

.achat-session {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    position: relative;
    transition: background .12s ease;
}
.achat-session:hover { background: var(--gold-100); }
.achat-session.active { background: var(--navy-900); }
.achat-session.active .achat-session-name,
.achat-session.active .achat-session-preview { color: var(--white); }
.achat-session.active .achat-session-avatar { background: var(--gold-500); color: var(--navy-900); }

.achat-session-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--navy-700);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.achat-session-body { flex: 1; min-width: 0; }
.achat-session-name {
    font-weight: 700;
    color: var(--navy-900);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.achat-session-preview {
    font-size: 0.8rem;
    color: var(--ink-600);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.achat-unread-dot {
    position: absolute;
    right: 14px;
    top: 16px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
}

.achat-main { display: flex; flex-direction: column; min-width: 0; }
.achat-main-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    color: var(--navy-900);
    font-family: var(--font-display);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
}
.achat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--cream-50);
}
.achat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--ink-600);
    font-size: 0.9rem;
}
.achat-empty i { font-size: 2rem; color: var(--line); }

.achat-msg { display: flex; flex-direction: column; max-width: 68%; }
.achat-msg .achat-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    line-height: 1.55;
    word-break: break-word;
}
.achat-msg time { font-size: 0.7rem; color: var(--ink-600); margin-top: 4px; opacity: 0.8; }
.achat-msg.guest { align-self: flex-start; align-items: flex-start; }
.achat-msg.guest .achat-bubble { background: var(--white); border: 1px solid var(--line); color: var(--ink-900); }
.achat-msg.admin { align-self: flex-end; align-items: flex-end; }
.achat-msg.admin .achat-bubble { background: var(--navy-800); color: var(--white); }

.achat-input-row {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    background: var(--white);
}
.achat-input-row input {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 0.92rem;
    font-family: var(--font-body);
}
.achat-input-row input:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(35,95,153,0.15); }
.achat-input-row button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--gold-500);
    color: var(--navy-900);
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 1rem;
}
.achat-input-row button:hover { background: var(--gold-400); }
/* ===================== COMPLAINTS / DASHBOARD ADDITIONS ===================== */

/* permission note */
.admin-permission-note {
    background: #e8f1fa;
    border: 1px solid #c7ddf2;
    color: var(--navy-700);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.88rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* stat tiles row */
.stat-tile-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
@media (max-width: 900px) { .stat-tile-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .stat-tile-row { grid-template-columns: 1fr; } }

.stat-tile {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-card);
}
.stat-tile-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}
.stat-tile-icon--navy   { background: #e8f1fa; color: var(--navy-700); }
.stat-tile-icon--gold   { background: var(--gold-100); color: var(--gold-500); }
.stat-tile-icon--danger { background: #fbeae8; color: var(--danger); }
.stat-tile-icon--success{ background: #e3f3ea; color: var(--success); }

.stat-tile-body { min-width: 0; }
.stat-tile-value { font-size: 1.8rem; font-family: var(--font-display); font-weight: 800; color: var(--navy-900); line-height: 1.1; }
.stat-tile-label { font-size: 0.82rem; color: var(--ink-600); margin-top: 2px; }
.stat-tile-sub   { font-size: 0.76rem; color: var(--ink-600); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* chart grid */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 22px;
}
@media (max-width: 800px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-card { overflow: hidden; }
.chart-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}
.chart-card-head h2 { margin: 0; font-size: 0.98rem; }
.chart-canvas-wrap { position: relative; width: 100%; }

/* period toggle */
.period-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.period-toggle a {
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-600);
    border-right: 1px solid var(--line);
    background: var(--white);
}
.period-toggle a:last-child { border-right: none; }
.period-toggle a:hover, .period-toggle a.active {
    background: var(--navy-800);
    color: var(--white);
}

/* table card head */
.table-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}
.table-card-head h2 { margin: 0; font-size: 0.98rem; }
.table-filter-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.table-filter-form .form-control { width: auto; min-width: 160px; padding: 7px 12px; font-size: 0.85rem; }

/* cell-sub */
.cell-sub { font-size: 0.78rem; color: var(--ink-600); margin-top: 2px; }

/* icon buttons (view/delete) */
.row-actions { display: flex; gap: 6px; }
.icon-btn {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--white);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 0.95rem;
    transition: all .15s ease;
}
.icon-btn--view   { color: var(--navy-700); }
.icon-btn--view:hover { background: var(--navy-800); color: var(--white); border-color: var(--navy-800); }
.icon-btn--delete { color: var(--danger); }
.icon-btn--delete:hover { background: var(--danger); color: var(--white); border-color: var(--danger); }

/* badge additions */
.badge-warning { background: #fff3cd; color: #b9831a; }
.badge-info    { background: #e8f1fa; color: var(--navy-700); }

/* pagination */
.pagination-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}
.pagination-info { font-size: 0.82rem; color: var(--ink-600); }
.pagination-links { display: flex; gap: 4px; flex-wrap: wrap; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--white);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--navy-700);
    transition: all .15s;
}
.page-link:hover, .page-link.active {
    background: var(--navy-800);
    color: var(--white);
    border-color: var(--navy-800);
}

/* view modal */
.modal-box--view {
    max-width: 560px;
}
.view-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gold-500);
}
.view-modal-id {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--navy-900);
}
.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    color: var(--ink-600);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.modal-close-btn:hover { background: var(--cream-50); color: var(--danger); }
.view-modal-body { margin-bottom: 16px; }
.view-row {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--cream-50);
    font-size: 0.9rem;
}
.view-label {
    width: 110px;
    flex-shrink: 0;
    font-weight: 700;
    color: var(--ink-600);
    font-size: 0.82rem;
}
.view-value { color: var(--ink-900); flex: 1; }
.view-divider { height: 1px; background: var(--line); margin: 12px 0; }
.view-subject {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--navy-900);
    margin-bottom: 8px;
}
.view-detail {
    color: var(--ink-900);
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-line;
    background: var(--cream-50);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    border: 1px solid var(--line);
    margin-bottom: 10px;
}
.view-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--navy-700);
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
}
.view-attachment-link:hover { color: var(--gold-500); border-color: var(--gold-500); }