/* Styles for Fleet Management Web App - Premium Dark/Light Glassmorphism */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --font-primary: 'Plus Jakarta Sans', 'Kanit', sans-serif;

    /* Colors - PMN24H Brand Theme (White / Blue / Red) */
    --bg-main: #F4F6FA;
    --bg-card: #ffffff;
    --bg-card-hover: #F8FAFC;
    --border-color: #E4E8F0;
    --text-primary: #16213E;
    --text-secondary: #5B6B87;
    --text-muted: #94A0B8;

    /* Dark surfaces (sidebar, login, modals stay on the navy/white pairing) */
    --sidebar-navy: #0F2A57;
    --sidebar-navy-dark: #081A38;
    --on-dark-text: rgba(255, 255, 255, 0.85);
    --on-dark-text-muted: rgba(255, 255, 255, 0.55);
    --on-dark-border: rgba(255, 255, 255, 0.1);

    /* Accent Colors */
    --color-primary: #1B4F9C; /* Blue */
    --color-primary-light: rgba(27, 79, 156, 0.1);
    --color-secondary: #0F2A57; /* Navy */
    --color-secondary-light: rgba(15, 42, 87, 0.08);

    /* Status Colors */
    --color-pending: #B7791F; /* Amber */
    --color-pending-light: rgba(245, 158, 11, 0.14);
    --color-active: #1B4F9C; /* Blue */
    --color-active-light: rgba(27, 79, 156, 0.1);
    --color-completed: #16A34A; /* Green */
    --color-completed-light: rgba(16, 185, 129, 0.14);
    --color-danger: #E12726; /* Red */
    --color-danger-light: rgba(225, 39, 38, 0.1);

    /* Layout Constants */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 64px;
    --header-height: 70px;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;

    --shadow-premium: 0 10px 30px -18px rgba(15, 33, 66, 0.35),
                      0 1px 1px rgba(255, 255, 255, 0.6) inset;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(185deg, var(--sidebar-navy) 0%, var(--sidebar-navy-dark) 100%);
    border-right: 1px solid var(--on-dark-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: width var(--transition-normal);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar toggle button */
.sidebar-toggle {
    position: absolute;
    top: 22px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    transition: transform var(--transition-fast), background var(--transition-fast);
    box-shadow: 0 2px 8px rgba(27, 79, 156, 0.4);
}
.sidebar-toggle:hover { background: var(--color-danger); }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--on-dark-border);
    gap: 12px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.sidebar.collapsed .logo-text { opacity: 0; width: 0; overflow: hidden; pointer-events: none; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-logo i,
.sidebar.collapsed .sidebar-logo img { margin: 0; }

.sidebar-logo i {
    font-size: 24px;
    color: var(--color-primary);
}

.logo-text {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 30%, var(--color-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
}

/* Direct children of .sidebar-menu must not flex-shrink below their natural
   size - otherwise a short window silently squeezes/clips whole groups
   (via .menu-group-items' overflow:hidden) instead of letting the menu's
   own overflow-y:auto take over and scroll. */
.sidebar-menu > .menu-item,
.sidebar-menu > .menu-group-label,
.sidebar-menu > .menu-group-items {
    flex-shrink: 0;
}

.menu-item a {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--on-dark-text-muted);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    font-size: 13px;
    transition: all var(--transition-fast);
    gap: 12px;
    white-space: nowrap;
    overflow: hidden;
}

.menu-item a i {
    font-size: 18px;
    transition: transform var(--transition-fast);
}

.menu-item a:hover {
    color: var(--on-dark-text);
    background: rgba(255, 255, 255, 0.06);
}

.menu-item a:hover i {
    transform: translateX(3px);
}

.menu-item.active a {
    color: #fff;
    background: var(--color-primary);
    box-shadow: 0 4px 15px rgba(27, 79, 156, 0.4);
    border-left: 3px solid var(--color-danger);
    padding-left: 11px;
}
.sidebar.collapsed .menu-item.active a {
    border-left: none;
    padding-left: 0;
}

.menu-item.active a i {
    color: #fff;
}

/* Menu group label - click to collapse/expand its items (state remembered per group) */
.menu-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 4px;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: var(--on-dark-text-muted);
    text-transform: uppercase;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-fast);
    cursor: pointer;
}
.sidebar.collapsed .menu-group-label { opacity: 0; pointer-events: none; height: 0; padding: 0; }

.group-chevron {
    font-size: 10px;
    opacity: 0.55;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}
.group-chevron.rotated { transform: rotate(-90deg); }
.sidebar.collapsed .group-chevron { display: none; }

/* Manually-collapsed group: hidden only in the normal/drawer sidebar - the
   tablet icon-rail (.sidebar.collapsed) always shows items regardless, since
   that mode already communicates "collapsed" via icons-only. */
.sidebar:not(.collapsed) .menu-group-items.group-collapsed { display: none; }

/* Nested sub-group (e.g. Master Data inside Operation) */
.menu-group-label.nested-label { font-size: 12px; margin-left: 4px; }
.menu-group-items.nested {
    margin-left: 14px;
    padding-left: 10px;
    border-left: 1px dashed var(--on-dark-border);
}
.sidebar.collapsed .menu-group-label.nested-label { display: none; }
.sidebar.collapsed .menu-group-items.nested {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
}

.menu-group-items {
    overflow: hidden;
}

/* Roadmap preview items (module not built yet - e.g. DMS/HR future scope) */
.menu-item-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--on-dark-text-muted);
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0.55;
    cursor: default;
}
.menu-item-preview i { font-size: 18px; }
.menu-badge-soon {
    margin-left: auto;
    flex: none;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: var(--on-dark-text-muted);
    background: rgba(255, 255, 255, 0.12);
    padding: 3px 7px;
    border-radius: 999px;
    white-space: nowrap;
}
.sidebar.collapsed .menu-item-preview span,
.sidebar.collapsed .menu-item-preview .menu-badge-soon { display: none; }
.sidebar.collapsed .menu-item-preview { justify-content: center; padding: 10px 0; }

/* Tooltip when sidebar collapsed */
.sidebar.collapsed .menu-item {
    position: relative;
    width: 100%;
}
.sidebar.collapsed .menu-item a span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}
.sidebar.collapsed .menu-item a {
    justify-content: center;
    padding: 10px 0;
    width: 100%;
}
.sidebar.collapsed .menu-item a i {
    font-size: 18px;
    margin: 0;
    flex-shrink: 0;
}
.sidebar.collapsed .menu-item:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--sidebar-navy-dark);
    color: var(--on-dark-text);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid var(--on-dark-border);
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.sidebar.collapsed .sidebar-footer { opacity: 0; pointer-events: none; }

.sidebar-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--on-dark-text-muted);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    font-size: 12.5px;
}
.sidebar-link-item i { font-size: 15px; width: 16px; text-align: center; }
.sidebar-link-item:hover {
    color: var(--on-dark-text);
    background: rgba(255, 255, 255, 0.06);
}
.sidebar.collapsed #driver-sidebar-links { display: none !important; }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--on-dark-border);
    font-size: 12px;
    color: var(--on-dark-text-muted);
    width: 100%;
    transition: opacity var(--transition-fast);
    overflow: hidden;
    white-space: nowrap;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-normal);
    overflow-x: hidden;
}
.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Header */
.top-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title-area h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-title-area p {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-main);
    padding: 6px 14px 6px 6px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
}

.notif-bell-wrapper {
    position: relative;
}

.notif-bell-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-secondary);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notif-bell-btn:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.notif-bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #C0392B;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    max-width: 90vw;
    max-height: 420px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-premium);
    z-index: 200;
}

.notif-panel-header {
    padding: 12px 16px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: #fff;
}

.notif-panel-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.notif-panel-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.notif-panel-item:last-child {
    border-bottom: none;
}

.notif-panel-item:hover {
    background: var(--bg-main);
}

.notif-panel-item.unread {
    background: #EAF1FB;
}

.notif-panel-item-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 2px;
}

.notif-panel-item-message {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.notif-panel-item-time {
    font-size: 11px;
    color: var(--text-secondary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    font-size: 14px;
}

.user-info {
    text-align: left;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    display: block;
}

.user-role {
    font-size: 10px;
    color: var(--text-secondary);
    display: block;
}

/* Page Wrapper */
.content-wrapper {
    padding: 32px;
    flex-grow: 1;
}

.page-panel {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.page-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.premium-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-premium);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.premium-card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
    border-color: rgba(27, 79, 156, 0.25);
}

/* Driver Jobs page ("งานของฉันวันนี้") - mobile-first card list */
.driver-jobs-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 14px 0;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--border-color);
}

.driver-jobs-section-title + .driver-jobs-section-title {
    margin-top: 28px;
}

.driver-jobs-section-title.active {
    background: var(--color-pending-light, rgba(230, 162, 60, 0.12));
    border-left-color: var(--color-pending, #E6A23C);
    color: var(--color-pending, #E6A23C);
}

.driver-jobs-section-title.closed {
    background: var(--color-completed-light, rgba(64, 158, 111, 0.12));
    border-left-color: var(--color-completed, #409E6F);
    color: var(--color-completed, #409E6F);
}

.driver-job-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 640px;
}

.driver-job-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-premium);
}

.driver-job-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 15px;
}

.driver-job-customer {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.driver-job-route {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg-main);
    border-radius: var(--border-radius-sm);
    margin-bottom: 8px;
}

.driver-job-route-point {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Add Points (waypoints) between origin and destination - smaller/muted so
   the actual origin and destination still stand out as the main 2 lines. */
.driver-job-route-waypoint {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 14px;
}
.driver-job-route-waypoint i {
    font-size: 5px;
    color: var(--color-primary);
}
/* Office's remark for one Add Point (what to pick up / drop off there) -
   its own line under the point name, in the note color so it's noticed. */
.driver-job-point-remark {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-pending);
}

.driver-job-distance {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.driver-job-booking-datetime {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.driver-job-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-pending);
    background: rgba(201, 138, 26, 0.1);
    border: 1px solid rgba(201, 138, 26, 0.3);
    border-radius: var(--border-radius-sm);
    padding: 8px 10px;
    margin-bottom: 10px;
}

.driver-job-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.driver-job-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.driver-job-card-actions .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
}

.alcohol-test-group {
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: var(--border-radius-sm);
    padding: 12px 14px;
}

/* Stat Cards specific */
.stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-card.clickable {
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.stat-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-premium);
    border-color: var(--color-primary);
}

.stat-info h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-info .trend {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend.up { color: var(--color-completed); }
.trend.down { color: var(--color-danger); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.primary {
    background: var(--color-primary-light);
    color: var(--color-primary);
}
.stat-icon.secondary {
    background: var(--color-secondary-light);
    color: var(--color-secondary);
}
.stat-icon.success {
    background: var(--color-completed-light);
    color: var(--color-completed);
}
.stat-icon.warning {
    background: var(--color-pending-light);
    color: var(--color-pending);
}
.stat-icon.danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

/* Main Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Tables and Panels */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    gap: 8px;
    text-decoration: none;
    font-family: var(--font-primary);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(27, 79, 156, 0.25);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(27, 79, 156, 0.35);
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: #EDF1F7;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--color-completed);
    color: #fff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 600;
    gap: 4px;
    white-space: nowrap;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-pending {
    background: var(--color-pending-light);
    color: var(--color-pending);
}
.badge-pending .badge-dot { background: var(--color-pending); }

.badge-active {
    background: var(--color-active-light);
    color: var(--color-active);
}
.badge-active .badge-dot { background: var(--color-active); }

.badge-completed {
    background: var(--color-completed-light);
    color: var(--color-completed);
}
.badge-completed .badge-dot { background: var(--color-completed); }

.badge-danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
}
.badge-danger .badge-dot { background: var(--color-danger); }

.badge-info {
    background: var(--color-secondary-light);
    color: var(--color-secondary);
}

.badge-primary {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* Table styling */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.premium-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.premium-table th {
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.premium-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.premium-table tbody tr:last-child td {
    border-bottom: none;
}

.premium-table tbody tr {
    transition: background-color var(--transition-fast);
}

.premium-table tbody tr:hover {
    background: var(--bg-main);
}

/* Tighter padding/font for wide, many-column tables (Job Order, Booking,
   Invoices) so they fit a normal desktop width without horizontal scroll -
   previously only fit at ~90% browser zoom. Column widths/content unchanged,
   just less padding wasted per cell across ~10 columns. */
.premium-table.table-compact th,
.premium-table.table-compact td {
    padding: 9px 10px;
}
.premium-table.table-compact {
    font-size: 13px;
}
.premium-table.table-compact th {
    font-size: 11px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select, textarea {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--color-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(27, 79, 156, 0.15);
}

select option {
    background-color: #ffffff;
    color: #111111;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-premium);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(30px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    flex: 1 1 180px;
    min-width: 0;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.modal-header-actions .btn {
    padding: 8px 14px;
    font-size: 13px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
    background: var(--bg-card);
}

/* Utility classes */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-gap-sm {
    display: flex;
    gap: 8px;
    align-items: center;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Filter Bar */
.filter-bar {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex-grow: 1;
    min-width: 150px;
}

/* Document Printing/Viewing Area */
.doc-preview {
    background: #fff;
    color: #1e293b;
    padding: 40px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-family: 'Sarabun', 'Kanit', sans-serif;
    margin-top: 20px;
    border: 1px solid #cbd5e1;
    font-size: 13px;
    line-height: 1.5;
}

.doc-preview h2, .doc-preview h3, .doc-preview h4 {
    color: #0f172a;
    margin-bottom: 8px;
}

.doc-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.company-info h2 {
    font-size: 22px;
    font-weight: 700;
}

.doc-title-area {
    text-align: right;
}

.doc-title-area h2 {
    font-size: 24px;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.doc-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 30px;
}

.doc-party h4 {
    font-size: 14px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
    margin-bottom: 8px;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.doc-table th {
    background: #f1f5f9;
    padding: 10px 12px;
    font-weight: 600;
    border-top: 1px solid #cbd5e1;
    border-bottom: 1px solid #cbd5e1;
}

.doc-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.doc-summary {
    display: flex;
    justify-content: flex-end;
}

.summary-box {
    width: 300px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed #cbd5e1;
}

.summary-row.total {
    border-bottom: 2px double #0f172a;
    font-weight: 700;
    font-size: 15px;
}

.doc-signatures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 50px;
    text-align: center;
}

.sig-line {
    border-bottom: 1px solid #94a3b8;
    margin-bottom: 8px;
    height: 40px;
}

/* Quick stats list for subcontractor and salary slips */
.slip-calc-details {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.slip-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.slip-row.total {
    font-weight: 700;
    color: var(--color-completed);
    font-size: 16px;
}

/* Login Screen Overlay & Glassmorphism */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #ffffff 0%, var(--bg-main) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 460px;
    padding: 35px 30px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-premium);
    color: var(--text-primary);
}

.login-header {
    text-align: center;
    margin-bottom: 25px;
}

.login-header i {
    font-size: 40px;
    color: var(--color-primary);
    margin-bottom: 12px;
    text-shadow: 0 0 20px rgba(27, 79, 156, 0.4);
}

.login-header h2 {
    font-family: 'Plus Jakarta Sans', 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 6px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.login-error {
    background: var(--color-danger-light);
    border: 1px solid rgba(225, 39, 38, 0.3);
    color: #B91C1C;
    padding: 10px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-block {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
}

.demo-logins {
    margin-top: 25px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.demo-logins h4 {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 600;
}

.demo-logins ul {
    list-style: none;
    padding: 0;
}

.demo-logins li {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.demo-logins li strong {
    color: var(--text-secondary);
}

/* Logout Button & Logged User Customizations */
.logout-btn {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid rgba(225, 39, 38, 0.25);
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 15px;
}

.logout-btn:hover {
    background: rgba(225, 39, 38, 0.2);
    color: var(--color-danger);
    border-color: rgba(225, 39, 38, 0.45);
}

/* ===================================================================
   Responsive — Desktop (>1024px) / Tablet (769-1024px) / Mobile (<=768px)
   Desktop: full sidebar, manual collapse toggle (existing behavior).
   Tablet : sidebar auto-collapses to the icon rail (reuses .collapsed).
   Mobile : sidebar becomes an off-canvas drawer behind a hamburger button.
   =================================================================== */

.mobile-menu-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 12px;
}

.mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 15, 30, 0.55);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}
.mobile-backdrop.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Tablet: stack the 2-column dashboard layouts to 1 column (overrides any
   inline grid-template-columns some panels set directly on the element) */
@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile: sidebar becomes a fixed off-canvas drawer, main content goes full-width */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: none;
    }
    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar {
        width: 280px !important;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        z-index: 300;
        box-shadow: 14px 0 34px rgba(0, 0, 0, 0.35);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    /* On mobile the drawer always shows full labels - .collapsed is not applied
       at this breakpoint (see applyResponsiveSidebar in index.html), but guard
       the visual styles anyway in case of a stale class from a resize. */
    .sidebar.collapsed {
        width: 280px !important;
    }
    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .menu-item a span,
    .sidebar.collapsed .menu-group-label,
    .sidebar.collapsed .menu-item-preview span,
    .sidebar.collapsed .menu-item-preview .menu-badge-soon,
    .sidebar.collapsed .sidebar-footer {
        opacity: 1;
        width: auto;
        height: auto;
        pointer-events: auto;
    }
    .sidebar.collapsed .sidebar-logo {
        justify-content: flex-start;
        padding: 0 20px;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .top-header {
        padding: 0 16px;
    }
    .page-title-area p {
        display: none;
    }
    .header-actions .user-info {
        display: none;
    }
    .header-actions .user-profile {
        padding: 6px 8px;
        gap: 6px;
    }
    .logout-btn span {
        display: none;
    }
    .logout-btn {
        margin-left: 6px;
        padding: 8px;
    }

    .content-wrapper {
        padding: 16px;
    }
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }
    .premium-card {
        padding: 16px;
    }
    .dashboard-layout {
        gap: 16px;
    }
    .section-header {
        flex-wrap: wrap;
        row-gap: 6px;
    }
    .section-header h2 {
        font-size: 15px;
        flex-wrap: wrap;
        min-width: 0;
    }
    .modal-container {
        width: 94%;
        max-height: 90vh;
    }
    .doc-preview {
        padding: 20px;
    }
    .doc-details-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .doc-signatures {
        grid-template-columns: 1fr;
    }
    .login-card {
        width: 90%;
        padding: 28px 20px;
    }
}

/* Job photo evidence viewer (modal-view-photos) - compact thumbnail grid,
   click a thumbnail to enlarge via #photo-lightbox. */
.photo-evidence-section {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.photo-evidence-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.photo-evidence-section h5 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-pending);
    margin-bottom: 6px;
}
.photo-evidence-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.photo-evidence-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.photo-evidence-grid img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: zoom-in;
    transition: transform 0.1s ease;
}
.photo-evidence-grid img:hover {
    transform: scale(1.04);
}

/* Small inline thumbnail strip on the Job Order table row (up to 5 photos,
   click to enlarge via the same #photo-lightbox the full viewer uses). */
.job-row-thumbs {
    display: flex;
    align-items: center;
    gap: 3px;
}
.job-thumb {
    width: 26px;
    height: 26px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    cursor: zoom-in;
    transition: transform 0.1s ease;
}
.job-thumb:hover {
    transform: scale(1.15);
}
.job-thumb-more {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 2px 5px;
    flex-shrink: 0;
}

#photo-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10050;
    padding: 24px;
}
#photo-lightbox.active { display: flex; }
#photo-lightbox img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
#photo-lightbox button {
    position: absolute;
    top: 18px;
    right: 24px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}
