@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;700&display=swap');

:root {
    /* Modern Sapphire Navy Palette */
    --gov-black: #0B2545; /* Deep Navy */
    --gov-gray-dark: #13315C;
    --gov-gray-medium: #134074;
    --gov-gray-light: #EEF4ED;
    --gov-gray-ultra-light: #F8F9FA;
    --gov-white: #ffffff;
    
    /* Highlight Colors */
    --highlight-bg: #E2E8F0;
    --highlight-border: #134074;
    --soft-shadow: 0 4px 15px rgba(11, 37, 69, 0.08);
    --premium-shadow: 0 10px 35px rgba(11, 37, 69, 0.12);
}

body {
    font-family: 'TH Sarabun New', 'Inter', sans-serif;
    font-size: 18pt;
    line-height: 1.6;
    color: var(--gov-black);
    background-color: var(--gov-gray-ultra-light);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: bold;
    color: var(--gov-black);
    border-bottom: 2px solid var(--gov-black);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.bg-dark h1, .bg-dark h2, .bg-dark h3, .bg-dark h4, .bg-dark h5, .bg-dark h6 {
    color: var(--gov-white);
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.btn-gov {
    background-color: var(--gov-black);
    color: var(--gov-white);
    border: 2px solid var(--gov-black);
    font-weight: bold;
    padding: 0.75rem 1.5rem;
    font-size: 1.2rem;
    border-radius: 0;
    text-transform: uppercase;
    transition: all 0.2s ease-in-out;
}

.btn-gov:hover {
    background-color: var(--gov-white);
    color: var(--gov-black);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-gov-outline {
    background-color: var(--gov-white);
    color: var(--gov-black);
    border: 2px solid var(--gov-black);
    font-weight: bold;
    padding: 0.75rem 1.5rem;
    font-size: 1.2rem;
    border-radius: 0;
    transition: all 0.2s ease-in-out;
}

.btn-gov-outline:hover {
    background-color: var(--gov-black);
    color: var(--gov-white);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.form-control {
    border: 2px solid var(--gov-black);
    border-radius: 0;
    padding: 0.75rem;
    font-size: 1.2rem;
}

.form-control:focus {
    box-shadow: none;
    border-color: var(--gov-black);
    outline: 3px solid #000;
}

.card-gov {
    border: 2px solid var(--gov-black);
    border-radius: 0;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.card-gov:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.card-header-gov {
    background-color: var(--gov-black);
    color: var(--gov-white);
    border-radius: 0;
    font-weight: bold;
    padding: 1rem;
}

/* Formal Thai Memo Layout */
.memo-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 4rem;
    border: 1px solid #ccc;
    background: #fff;
    box-shadow: none;
}

.memo-header {
    text-align: center;
    margin-bottom: 3rem;
}

.memo-logo {
    max-height: 100px;
    width: auto;
    display: block;
    margin: 0 auto 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.memo-title {
    font-size: 24pt;
    font-weight: bold;
    text-decoration: underline;
}

.status-badge {
    padding: 0.5rem 1rem;
    border: 2px solid var(--gov-black);
    font-weight: bold;
    text-transform: uppercase;
}

.satt-footer {
    background: linear-gradient(160deg, #0B2545 0%, #13315C 100%);
    color: #fff;
    width: 100%;
    margin-top: auto;
}
.satt-footer h5, .satt-footer h6 {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    color: rgba(255,255,255,0.85) !important;
}
.satt-footer-brand {
    font-size: 1.4rem;
    color: #fff;
    letter-spacing: -0.5px;
}
.satt-footer-heading {
    color: rgba(255,255,255,0.85);
    letter-spacing: 1px;
}
.satt-footer-link {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    transition: color 0.2s ease;
}
.satt-footer-link:hover {
    color: #C5A24D;
    text-decoration: none;
}

.content-wrapper {
    flex: 1 0 auto;
    padding-bottom: 3rem;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ===== SLIM TOP BAR ===== */
.satt-topbar {
    background: var(--gov-white);
    border-bottom: 1px solid #e5e5e5;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1045;
    height: 56px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}


/* ===== SIDEBAR NAVIGATION ===== */
.satt-sidebar {
    width: 260px !important;
    background: linear-gradient(180deg, var(--gov-black) 0%, var(--gov-gray-dark) 100%) !important;
    border-right: 1px solid rgba(255,255,255,0.08);
}

.satt-sidebar .offcanvas-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.satt-sidebar .sidebar-brand {
    color: rgba(255,255,255,0.9);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.3;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.satt-sidebar .offcanvas-body {
    padding: 0.5rem 0;
    overflow-y: auto;
}

.satt-sidebar .nav-section-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.3);
    padding: 1.25rem 1.25rem 0.4rem;
    font-weight: 700;
}

.satt-sidebar .sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.55rem 1.25rem;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.satt-sidebar .sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(197, 162, 77, 0.4);
}

.satt-sidebar .sidebar-link.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-left-color: #C5A24D;
    font-weight: 700;
}

.satt-sidebar .sidebar-link i {
    width: 20px;
    text-align: center;
    margin-right: 0.65rem;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.satt-sidebar .sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 0.75rem 1.25rem;
}

/* ===== SIDEBAR COLLAPSE TOGGLE (in top bar) ===== */
.satt-topbar .sidebar-collapse-btn {
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.satt-topbar .sidebar-collapse-btn:hover {
    opacity: 1;
}

/* ===== SIDEBAR DESKTOP OVERRIDES (Bootstrap offcanvas-lg resets) ===== */
@media (min-width: 992px) {
    .satt-sidebar {
        position: fixed !important;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 260px !important;
        z-index: 1030;
        background: linear-gradient(180deg, var(--gov-black) 0%, var(--gov-gray-dark) 100%) !important;
        border-right: 1px solid rgba(255,255,255,0.08) !important;
        transform: none !important;
        visibility: visible !important;
        display: flex !important;
        flex-direction: column;
        transition: width 0.2s ease;
    }

    .satt-sidebar .offcanvas-header {
        display: flex !important;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .satt-sidebar .offcanvas-header .btn-close {
        display: none;
    }

    .satt-sidebar .offcanvas-body {
        display: block !important;
        padding: 0.5rem 0 !important;
        overflow-y: auto !important;
        flex-grow: 1;
    }

    /* --- Collapsed State --- */
    .satt-sidebar.collapsed {
        width: 72px !important;
    }

    .satt-sidebar.collapsed .sidebar-brand,
    .satt-sidebar.collapsed .sidebar-text {
        display: none;
    }

    .satt-sidebar.collapsed .offcanvas-header {
        justify-content: center;
        padding: 1rem 0.5rem;
    }

    .satt-sidebar.collapsed .sidebar-logo {
        justify-content: center;
    }

    .satt-sidebar.collapsed .nav-section-label {
        height: 1px;
        padding: 0;
        margin: 0.75rem 0.75rem 0.4rem;
        background: rgba(255,255,255,0.08);
        overflow: hidden;
    }

    .satt-sidebar.collapsed .sidebar-link {
        justify-content: center;
        padding: 0.65rem 0;
    }

    .satt-sidebar.collapsed .sidebar-link i {
        margin-right: 0;
        font-size: 1.1rem;
    }

    .satt-sidebar.collapsed .sidebar-link {
        border-left-width: 0;
    }

    .satt-sidebar.collapsed .sidebar-link.active {
        border-left-width: 3px;
    }

    .satt-sidebar.collapsed .sidebar-divider {
        margin: 0.75rem 0.5rem;
    }

    .satt-sidebar.collapsed .sidebar-collapse-btn i {
        transform: rotate(180deg);
    }
}

/* ===== APP LAYOUT WRAPPER ===== */
.satt-app-wrapper {
    min-height: calc(100vh - 56px);
    padding-top: 56px;
}

.satt-main-content {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 56px);
    transition: margin-left 0.2s ease;
}

.satt-main-content .content-wrapper,
.satt-main-content > main {
    flex: 1 0 auto;
}

@media (min-width: 992px) {
    .satt-main-content:not(.satt-main-content--full) {
        margin-left: 260px;
    }

    .satt-main-content.satt-main-content--collapsed:not(.satt-main-content--full) {
        margin-left: 72px;
    }
}

/* 📱 GLOBAL MOBILE RESPONSIVENESS OVERHAUL (Phase 4) */
@media (max-width: 767.98px) {
    body {
        font-size: 16pt; /* Slightly smaller base font for mobile */
    }

    h1, h2, h3, h4, h5, h6 {
        margin-bottom: 1rem;
    }

    /* Make cards take up the entire width on mobile to save margin space */
    .card-gov {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        margin-bottom: 1.5rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .card-body {
        padding: 1rem 0.5rem;
    }

    /* Redesign Memo Layout to fit seamlessly on mobile devices */
    .memo-container {
        padding: 1rem 0.5rem;
        margin: 1rem -0.5rem;
        border: none;
        border-top: 1px solid #ccc;
        border-bottom: 1px solid #ccc;
    }

    .memo-title {
        font-size: 20pt;
    }

    .memo-logo {
        max-height: 80px;
    }
    
    /* Optimize buttons for thumbs */
    .btn-gov, .btn-gov-outline {
        padding: 0.6rem 1rem;
        font-size: 1.1rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Ensure all generic tables force a horizontal scroll wrapper natively if they don't have one */
    table.table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== HOME DASHBOARD ===== */
.home-welcome-card {
    background: linear-gradient(135deg, var(--gov-black) 0%, var(--gov-gray-dark) 100%);
    color: #fff;
    border: none;
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
}

.home-welcome-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #C5A24D, transparent);
}

.home-welcome-card h2,
.home-welcome-card h5 {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    color: #fff !important;
}

.home-stat-card {
    border: none;
    border-radius: 0.75rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    position: relative;
}

.home-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.home-stat-card h5,
.home-stat-card h6 {
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

.home-stat-card .stat-icon {
    position: absolute;
    right: -5px;
    bottom: -15px;
    font-size: 4.5rem;
    opacity: 0.08;
}

.home-stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
}

.home-stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    opacity: 0.7;
}

/* Quick Action Cards */
.home-action-card {
    border: 2px solid var(--gov-black);
    border-radius: 0.75rem;
    transition: all 0.25s ease;
    text-align: center;
    padding: 1.5rem 1rem;
    text-decoration: none;
    display: block;
    color: var(--gov-black);
}

.home-action-card:hover {
    background: var(--gov-black);
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(11,37,69,0.2);
    text-decoration: none;
}

.home-action-card:hover .action-icon {
    color: #C5A24D !important;
}

.home-action-card .action-icon {
    font-size: 2rem;
    color: var(--gov-black);
    transition: color 0.25s ease;
}

/* Status Badge Variants */
.badge-status-draft {
    background: rgba(108,117,125,0.1);
    color: #6c757d;
    border: 1px solid rgba(108,117,125,0.3);
    border-radius: 50px;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
}
.badge-status-pending {
    background: rgba(232,163,23,0.1);
    color: #b47d00;
    border: 1px solid rgba(232,163,23,0.3);
    border-radius: 50px;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
}
.badge-status-approved {
    background: rgba(25,135,84,0.1);
    color: #198754;
    border: 1px solid rgba(25,135,84,0.3);
    border-radius: 50px;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
}
.badge-status-rejected {
    background: rgba(220,53,69,0.1);
    color: #dc3545;
    border: 1px solid rgba(220,53,69,0.3);
    border-radius: 50px;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
}
.badge-status-completed {
    background: rgba(13,110,253,0.1);
    color: #0d6efd;
    border: 1px solid rgba(13,110,253,0.3);
    border-radius: 50px;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
}

/* Modern Documents Table */
.home-doc-card {
    border: none;
    border-radius: 0.75rem;
    overflow: hidden;
}

.home-doc-card .card-header {
    background: var(--gov-black);
    color: #fff;
    border-radius: 0.75rem 0.75rem 0 0 !important;
    padding: 1rem 1.25rem;
}

.home-doc-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    font-weight: 700;
    border-bottom: 2px solid #dee2e6;
}

.home-doc-table tbody tr {
    transition: background 0.15s ease;
}

.home-doc-table tbody tr:hover {
    background: rgba(19,64,116,0.03);
}

/* ===== DASHBOARD ===== */
.dash-budget-progress {
    height: 8px;
    border-radius: 4px;
    background: var(--gov-gray-light);
}

.dash-budget-progress .progress-bar {
    background: linear-gradient(90deg, var(--gov-black), var(--gov-gray-medium));
    border-radius: 4px;
}

.dash-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #adb5bd;
}

.dash-empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 0.75rem;
}

.home-doc-card .card-header h5 {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    color: #fff !important;
}

/* ===== CREATE FORM ===== */
.create-wrapper {
    border: none;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--premium-shadow);
}

.create-wrapper .memo-header {
    background: linear-gradient(135deg, var(--gov-black) 0%, var(--gov-gray-dark) 100%);
    color: #fff;
    padding: 1.5rem 2rem;
    position: relative;
}

.create-wrapper .memo-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #C5A24D, transparent);
}

.create-wrapper .memo-header h1 {
    color: #fff !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    font-size: 1.5rem;
}

.create-stepper {
    padding: 1.5rem 2rem;
    background: #fff;
}

.create-stepper .progress {
    height: 3px;
    background: var(--gov-gray-light);
}

.create-stepper .progress-bar {
    background: linear-gradient(90deg, var(--gov-black), #C5A24D);
}

.create-stepper .step-circle {
    width: 38px;
    height: 38px;
    border: 3px solid #fff;
    transition: all 0.3s ease;
    font-weight: 700;
    font-size: 0.9rem;
}

.create-step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--gov-gray-light);
}

.create-step-header .step-num {
    width: 32px;
    height: 32px;
    background: var(--gov-black);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.create-step-header h5 {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

.ai-magic-card {
    border: 2px solid var(--gov-black) !important;
    border-radius: 0.75rem !important;
    overflow: hidden;
    position: relative;
}

.ai-magic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gov-black), #C5A24D);
}

.ai-magic-card .ai-icon-wrap {
    width: 44px;
    height: 44px;
    background: var(--gov-black);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #C5A24D;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.btn-navy {
    background: var(--gov-black);
    color: #fff;
    border: none;
    font-weight: 700;
}

.btn-navy:hover {
    background: var(--gov-gray-dark);
    color: #fff;
}

.btn-gold {
    background: #C5A24D;
    color: var(--gov-black);
    border: none;
    font-weight: 700;
}

.btn-gold:hover {
    background: #d4b35c;
    color: var(--gov-black);
}