/* ===== SAMTAMBON CONTACT SYSTEM - Modern Thai Government UI ===== */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,600;0,700;1,400&family=Noto+Serif+Thai:wght@400;600;700&display=swap');

:root {
    --primary: #1a56a0;
    --primary-dark: #0f3a72;
    --primary-light: #2d7dd2;
    --accent: #f5a623;
    --accent-dark: #d4881c;
    --success: #27ae60;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --info: #3498db;
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-alt: #f8fafd;
    --border: #dce6f1;
    --text: #1a2940;
    --text-muted: #5a7395;
    --text-light: #8fa6c0;
    --shadow-sm: 0 2px 8px rgba(26,86,160,0.08);
    --shadow-md: 0 6px 24px rgba(26,86,160,0.13);
    --shadow-lg: 0 16px 48px rgba(26,86,160,0.18);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(26,86,160,0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(45,125,210,0.06) 0%, transparent 50%);
    min-height: 100vh;
    color: var(--text);
    line-height: 1.7;
    font-size: 15px;
}

/* ===== PAGE WRAPPER ===== */
.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 16px;
}

/* ===== HEADER BANNER ===== */
.site-header {
    width: 100%;
    max-width: 700px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 32px 40px 28px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 1;
}

.site-header .emblem {
    width: 72px;
    height: 72px;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    backdrop-filter: blur(4px);
}

.site-header h1 {
    font-family: 'Noto Serif Thai', serif;
    color: #fff;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.4;
    position: relative;
    margin: 0;
}

.site-header .subtitle {
    color: rgba(255,255,255,0.75);
    font-size: 0.88rem;
    margin-top: 6px;
    font-weight: 300;
    position: relative;
}

/* ===== MAIN CONTAINER ===== */
.container {
    background: var(--surface);
    padding: 36px 40px 40px;
    width: 100%;
    max-width: 700px;
    box-shadow: var(--shadow-lg);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border: 1px solid var(--border);
    border-top: none;
}

/* Legacy container for pages without .page-wrapper */
body > .container:first-child {
    border-radius: var(--radius-lg);
    margin: 40px auto;
    border-top: 4px solid var(--primary);
}

/* ===== SECTION DIVIDER ===== */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.8rem;
    margin: 28px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    background: var(--accent);
    border-radius: 2px;
}

/* ===== FORM STYLES ===== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

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

.form-group label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 0.93rem;
}

.form-group label .fas,
.form-group label .fa {
    color: var(--primary-light);
    font-size: 0.9em;
    width: 18px;
    text-align: center;
}

.required-mark {
    color: var(--danger);
    font-size: 0.8em;
    margin-left: 2px;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.97rem;
    font-family: 'Sarabun', sans-serif;
    background: var(--surface-alt);
    color: var(--text);
    transition: var(--transition);
    appearance: none;
}

.form-group input[type="text"]:hover,
.form-group input[type="date"]:hover,
.form-group input[type="tel"]:hover,
.form-group input[type="password"]:hover,
.form-group textarea:hover,
.form-group select:hover {
    border-color: #a8c4e8;
}

.form-group input[type="text"]:focus,
.form-group input[type="date"]:focus,
.form-group input[type="tel"]:focus,
.form-group input[type="password"]:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(45,125,210,0.12);
}

.form-group textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.6;
}

.thai-date-display {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
    padding: 4px 10px;
    background: rgba(26,86,160,0.05);
    border-radius: 4px;
    display: inline-block;
    min-height: 20px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.btn-primary,
.submit-button {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Sarabun', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(26,86,160,0.3);
    letter-spacing: 0.02em;
    margin-top: 8px;
}

.btn-primary:hover,
.submit-button:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    box-shadow: 0 6px 20px rgba(26,86,160,0.4);
    transform: translateY(-1px);
}

.btn-primary:active,
.submit-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(26,86,160,0.25);
}

.btn-secondary {
    background: var(--surface-alt);
    color: var(--primary);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    border-color: #a8c4e8;
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 3px 10px rgba(231,76,60,0.25);
}

.btn-danger:hover {
    background: var(--danger-dark);
    box-shadow: 0 4px 14px rgba(231,76,60,0.35);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 3px 10px rgba(39,174,96,0.25);
}

.btn-success:hover {
    background: #219a52;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 6px;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
}

/* ===== ALERT / MESSAGES ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.93rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #e8f8f0;
    color: #1a7a42;
    border: 1px solid #a3e4be;
}

.alert-danger, .error {
    background: #fdecea;
    color: #b71c1c;
    border: 1px solid #f5b8b8;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 0.93rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-info {
    background: #e8f4fd;
    color: #0d5c8f;
    border: 1px solid #a8d8f5;
}

/* ===== ADMIN LAYOUT ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

.admin-sidebar {
    width: 240px;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    padding: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(26,86,160,0.2);
}

.sidebar-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    text-align: center;
}

.sidebar-brand .brand-icon {
    width: 52px;
    height: 52px;
    background: rgba(255,255,255,0.15);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin: 0 auto 12px;
    color: #fff;
}

.sidebar-brand h2 {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
}

.sidebar-brand p {
    color: rgba(255,255,255,0.6);
    font-size: 0.78rem;
    margin-top: 3px;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-weight: 600;
}

.nav-item .fas {
    width: 18px;
    text-align: center;
    font-size: 0.9em;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.12);
}

/* ===== ADMIN CONTENT ===== */
.admin-content {
    flex: 1;
    padding: 28px 32px;
    overflow-x: auto;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-topbar h1 {
    font-size: 1.5rem;
    color: var(--primary-dark);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-topbar h1 .fas {
    color: var(--primary-light);
}

/* ===== STATS CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #e3f0fc; color: var(--primary); }
.stat-icon.green { background: #e6f7ee; color: var(--success); }
.stat-icon.orange { background: #fef5e4; color: #e67e22; }
.stat-icon.red { background: #fdecea; color: var(--danger); }

.stat-info .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-info .label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ===== TABLE ===== */
.table-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.table-header h2 {
    font-size: 1rem;
    color: var(--primary-dark);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-header h2 .fas {
    color: var(--primary-light);
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead tr {
    background: var(--surface-alt);
    border-bottom: 2px solid var(--border);
}

thead th {
    padding: 13px 16px;
    text-align: left;
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(26,86,160,0.03);
}

tbody td {
    padding: 13px 16px;
    color: var(--text);
    vertical-align: middle;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-blue { background: #ddeeff; color: var(--primary); }
.badge-green { background: #dcf7e8; color: #196f3d; }

/* ===== ACTION BUTTONS IN TABLE ===== */
.action-group {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

/* ===== DETAIL BOX ===== */
.detail-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.detail-card-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    padding: 20px 24px;
    color: white;
}

.detail-card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-card-body {
    padding: 24px;
}

.detail-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px 20px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    align-items: start;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 7px;
}

.detail-label .fas {
    color: var(--primary-light);
    width: 16px;
    text-align: center;
}

.detail-value {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Legacy detail-box */
.detail-box {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
}

.detail-box p {
    margin-bottom: 12px;
    color: var(--text);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.detail-box p:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.detail-box strong {
    color: var(--primary-dark);
    font-weight: 600;
    display: inline-block;
    min-width: 120px;
}

/* ===== SUCCESS PAGE ===== */
.success-card {
    text-align: center;
    padding: 48px 32px;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: #fff;
    margin: 0 auto 24px;
    box-shadow: 0 8px 24px rgba(39,174,96,0.3);
    animation: pop-in 0.5s cubic-bezier(0.36,0.07,0.19,0.97);
}

@keyframes pop-in {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.success-card h1 {
    color: var(--primary-dark);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.success-card p {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 28px;
    line-height: 1.7;
}

/* ===== LOGIN PAGE ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    background-size: 200% 200%;
    animation: gradient-shift 8s ease infinite;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-card {
    background: var(--surface);
    padding: 48px 40px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.25);
    animation: slide-up 0.4s ease;
}

@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: white;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(26,86,160,0.3);
}

.login-logo h1 {
    font-size: 1.3rem;
    color: var(--primary-dark);
    font-weight: 700;
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.breadcrumb a:hover {
    color: var(--primary-dark);
}

.breadcrumb .sep {
    color: var(--text-light);
    font-size: 0.75em;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 52px;
    color: var(--border);
    margin-bottom: 16px;
    display: block;
}

.empty-state h3 {
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.88rem;
}

/* ===== FOOTER ===== */
.site-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===== LINKS ===== */
a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .admin-layout {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        min-height: auto;
    }
    .admin-content {
        padding: 20px 16px;
    }
    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px;
    }
    .nav-item {
        margin-bottom: 0;
    }
}

@media (max-width: 640px) {
    .page-wrapper {
        padding: 20px 0;
    }
    .container, .site-header {
        border-radius: 0;
    }
    .container {
        padding: 24px 20px;
        max-width: 100%;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .login-card {
        padding: 36px 24px;
    }
    .admin-topbar h1 {
        font-size: 1.2rem;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .detail-row {
        grid-template-columns: 1fr;
    }
}

/* ===== UTILITY ===== */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 0.88rem; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }

/* ===== TABLE NUMBER ===== */
.row-num {
    font-size: 0.8rem;
    color: var(--text-light);
    background: var(--surface-alt);
    border-radius: 4px;
    padding: 2px 7px;
    font-weight: 600;
}
