/* Fonts - Loaded via header.php */

:root {
    /* Premium Color Palette */
    --primary: #4F46E5;
    /* Indigo 600 */
    --primary-hover: #4338CA;
    /* Indigo 700 */
    --primary-light: #EEF2FF;
    /* Indigo 50 */

    --secondary: #0EA5E9;
    /* Sky 500 */
    --accent: #F59E0B;
    /* Amber 500 */

    --success: #10B981;
    /* Emerald 500 */
    --danger: #EF4444;
    /* Red 500 */
    --warning: #F59E0B;

    --bg-body: #F3F4F6;
    /* Gray 100 */
    --bg-card: #FFFFFF;

    --text-main: #111827;
    /* Gray 900 */
    --text-muted: #6B7280;
    /* Gray 500 */
    --border: #E5E7EB;
    /* Gray 200 */

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --radius-md: 0.5rem;
    --radius-lg: 1rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Form Input - No Hover Effect */
.form-input {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    width: 100%;
    font-size: 0.875rem;
    background: white;
    transition: none;
}

.form-input:hover,
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: none;
}

body {
    font-family: "Inter", 'Times New Roman', 'Arial', 'Arial Narrow', "Roboto", "Poppins", "Noto Sans Thai Looped", "Noto Sans Lao Looped", 'Phetsarath', 'Phetsarath_OT', 'Phetsarath OT', 'Saysettha OT', 'Saysettha', sans-serif !important;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

table,
tr,
td {
    font-family: 'Times New Roman', 'Arial', 'Arial Narrow', 'Inter', 'Poppins', 'Noto Sans Thai Looped', 'Phetsarath_OT', 'Phetsarath OT', 'Saysettha OT', 'Saysettha', 'Noto Sans Lao Looped', sans-serif;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 10;
    transition: transform 0.3s ease;
    display: block;
    /* Restore display */
}

.main-content {
    flex: 1;
    margin-left: 250px;
    /* Restore margin */
    padding: 2rem;
    width: calc(100% - 250px);
}

/* Sidebar Styling */
.logo-area {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.app-name {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-main);
}

/* Sidebar Nav */
.nav-links {
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.nav-item.active {
    background: linear-gradient(90deg, var(--primary) 4px, #E0E7FF 4px);
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.15);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

/* Top Navigation (Header inside Main Content) */
.top-menu {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: var(--shadow-sm);
    height: 70px;
    margin: -2rem -2rem 2rem -2rem;
    /* Stretch to fill padding */
}

/* Horizontal Top Menu Links */
.top-nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    height: 100%;
    margin-right: auto;
    margin-left: 1.5rem;
    overflow-x: auto;
    /* Allow scrolling */
    scrollbar-width: none;
    /* Firefox hide scrollbar */
    -ms-overflow-style: none;
    /* IE/Edge hide scrollbar */
    max-width: 60vw;
    /* Prevent overlapping User Profile */
}

.top-nav-links::-webkit-scrollbar {
    display: none;
    /* Chrome hide scrollbar */
}

.top-nav-links .nav-item {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    border-radius: var(--radius-md);
    white-space: nowrap;
    flex-shrink: 0;
    /* Prevent squishing */
}

.top-nav-links .nav-item:hover,
.top-nav-links .nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

@media (max-width: 1200px) {

    .top-nav-links>div:first-child,
    .top-nav-links>div:nth-child(2) {
        display: none;
        /* Hide page title and date only */
    }

    /* Keep branch selector visible */
    .top-nav-links>div:last-child {
        display: block !important;
    }
}

@media (max-width: 768px) {

    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        z-index: 100;
        /* Above overlay */
    }

    /* Show sidebar when active class is added */
    .sidebar.active {
        transform: translateX(0);
    }

    /* Sidebar nav links stay visible (inside sidebar) */
    .sidebar .nav-links {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Show hamburger button */
    .hamburger-btn {
        display: flex !important;
    }

    /* Overlay when menu is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 50;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .top-menu {
        padding: 0 1rem;
    }
}

/* Hamburger Button (Hidden by default) */
.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-main);
    transition: all 0.2s;
}

.hamburger-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* User Dropdown Menu */
.user-menu {
    position: relative;
    cursor: pointer;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 0.5rem 0;
    display: none;
    z-index: 1000;
}

.user-menu:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background-color: var(--bg-body);
    color: var(--primary);
}

.dropdown-divider {
    border-top: 1px solid var(--border);
    margin: 0.5rem 0;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-trend {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--danger);
}

/* Table Styling */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-weight: 600;
    font-size: 1.125rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    background-color: #F9FAFB;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #F9FAFB;
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: #D1FAE5;
    color: #065F46;
}

/* Paid */
.badge-warning {
    background-color: #FEF3C7;
    color: #92400E;
}

/* Partial */
.badge-danger {
    background-color: #FEE2E2;
    color: #991B1B;
}

/* Unpaid */

/* Forms */
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: #F9FAFB;
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: white;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Responsive */
/* Top Navigation */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
    margin: -2rem -2rem 2rem -2rem;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .top-nav {
        padding: 1rem;
        margin: -2rem -1rem 2rem -1rem;
    }
}

/* ========================================
   COMPREHENSIVE RESPONSIVE STYLES
   ======================================== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-section h1 {
        font-size: 1.5rem;
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {

    /* Main content padding */
    .main-content {
        padding: 1rem;
    }

    /* Top menu adjustments */
    .top-menu {
        margin: -1rem -1rem 1rem -1rem;
        height: auto;
        min-height: 50px;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    /* Stats grid - single column */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Cards */
    .card {
        padding: 1rem;
    }

    /* Typography */
    .header-section h1 {
        font-size: 1.25rem;
    }

    .header-section p {
        font-size: 0.85rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* Buttons - prevent text wrap */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Tables - horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th,
    td {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Forms */
    .form-input {
        font-size: 16px;
        /* Prevents iOS zoom */
    }

    /* Flex containers - stack vertically */
    .header-section {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    /* Two-column grids become single */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: repeat(2"] {
        grid-template-columns: 1fr !important;
    }

    /* User dropdown */
    .user-menu {
        gap: 0.5rem;
    }

    .user-menu>div:first-child {
        display: none;
        /* Hide name on very small screens */
    }

    .dropdown-menu {
        right: -10px;
        width: 180px;
    }
}

/* Very small screens (max-width: 480px) */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
    }

    .top-menu {
        margin: -0.75rem -0.75rem 0.75rem -0.75rem;
    }

    .header-section h1 {
        font-size: 1.1rem;
    }

    .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .card {
        padding: 0.75rem;
        border-radius: 0.5rem;
    }

    .stats-grid {
        gap: 0.75rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    th,
    td {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Badge smaller */
    .badge {
        padding: 0.15rem 0.5rem;
        font-size: 0.65rem;
    }
}

/* Monthly Stats Grid - Responsive */
.monthly-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.monthly-card .stat-value {
    font-size: 1.5rem;
}

@media (max-width: 1024px) {
    .monthly-stats-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        overflow-x: hidden !important;
    }

    .monthly-card {
        padding: 1rem !important;
        width: 100% !important;
    }

    .monthly-card .stat-label {
        font-size: 0.85rem;
    }

    .monthly-card .stat-value {
        font-size: 1.5rem;
    }

    .monthly-card .stat-trend {
        font-size: 0.75rem;
    }
}

/* Font for Amount/Money Fields in Tables (not Dashboard) */
.font-amount,
table td[data-amount],
.amount-cell {
    font-family: 'Times New Roman', 'Arial', 'Arial Narrow', 'Inter', 'Poppins', 'Noto Sans Thai Looped', 'Phetsarath', 'Phetsarath_OT', 'Phetsarath OT', 'Saysettha OT', 'Saysettha', 'Noto Sans Lao Looped', sans-serif;
}