:root {
    /* Light Mode (Default) */
    --primary: #2c3e50;
    --accent: #3498db;
    --success: #27ae60;
    --pending: #f1c40f;
    --danger: #e74c3c;
    --bg: #ecf0f1;
    --card-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --border: #cccccc;
    --weekend: #e0e0e0;
    --holiday: #e5e8e8;
    --day-hover: #f8f9fa;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    --input-bg: #ffffff;
}

body.dark-mode {
    /* Dark Mode */
    --primary: #ecf0f1;
    --accent: #5dade2;
    --success: #2ecc71;
    --pending: #f39c12;
    --danger: #e74c3c;
    --bg: #1a1a1a;
    --card-bg: #2d2d2d;
    --sidebar-bg: #252525;
    --text-main: #ecf0f1;
    --text-muted: #aaaaaa;
    --border: #444444;
    --weekend: #222222;
    --holiday: #333333;
    --day-hover: #404040;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --input-bg: #3d3d3d;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    display: flex;
    height: 100vh;
    background: var(--bg);
    color: var(--text-main);
    transition: background 0.3s, color 0.3s;
    user-select: none;
    overflow: hidden;
    /* Desktop: Scrollbars only in containers */
}

/* MOBILE OPTIMIZATION */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        height: auto;
        overflow: auto;
        /* Mobile: Body scrolls normally */
        padding-bottom: 20px;
    }

    #sidebar {
        width: 100% !important;
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow: visible;
        position: relative;
        z-index: 10;
    }

    #main {
        height: auto;
        overflow: visible;
        padding: 10px;
    }

    .day {
        min-height: 60px !important;
        /* More compact on mobile */
        padding: 2px !important;
    }

    .day-number {
        font-size: 10px;
        margin-bottom: 2px;
    }

    .vacation-bar {
        font-size: 9px;
        padding: 2px 4px;
    }

    /* Login Box on Mobile */
    .login-container {
        width: 85% !important;
        padding: 20px !important;
    }

    /* Logo Image Responsive */
    .login-logo-img {
        max-width: 100%;
        height: auto;
    }

    h2 {
        font-size: 1.2em;
    }
}

#sidebar {
    width: 380px;
    background: var(--sidebar-bg);
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
    z-index: 10;
    border-right: 1px solid var(--border);
}

#sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

#sidebar-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

#main {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

h1,
h2,
h3 {
    color: var(--primary);
    margin-top: 0;
}

h3 {
    font-size: 1.1em;
    border-bottom: 2px solid var(--border);
    padding-bottom: 5px;
    margin-bottom: 10px;
}

select,
input,
button {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 14px;
    box-sizing: border-box;
    background: var(--input-bg);
    color: var(--text-main);
}

button {
    background: var(--primary);
    color: var(--bg);
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

body.dark-mode button {
    color: #1a1a1a;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button.green {
    background: var(--success);
    color: white;
}

button.red {
    background: var(--danger);
    color: white;
}

button.grey {
    background: #7f8c8d;
    color: white;
}

button.purple {
    background: #9b59b6;
    color: white;
}

button.small {
    padding: 5px 10px;
    font-size: 12px;
    width: auto;
    margin: 0;
    display: inline-block;
}

button.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 5px;
    width: auto;
    margin: 0;
    color: var(--text-main);
}

button.icon-btn:hover {
    transform: scale(1.2);
}

.card {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    transition: background 0.3s;
}

/* Calendar Styles */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.day-label {
    text-align: center;
    font-weight: bold;
    color: #7f8c8d;
    padding: 5px;
    font-size: 0.9em;
    text-transform: uppercase;
}

.day {
    background: var(--card-bg);
    min-height: 100px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    font-size: 12px;
    overflow: hidden;
    transition: border-color 0.2s, background 0.3s;
}

.day:hover {
    background: var(--day-hover);
    border-color: var(--accent);
}

.day.selected {
    border: 2px solid var(--accent);
}

.day.is-weekend {
    background: var(--weekend);
    color: #95a5a6;
}

.day.is-holiday {
    background: var(--holiday);
    color: #7f8c8d;
    border-color: var(--border);
}

.day.is-holiday .day-number {
    color: var(--danger);
}

.day-number {
    font-weight: bold;
    margin-bottom: 5px;
}

.holiday-name {
    font-size: 10px;
    color: var(--danger);
    margin-top: 2px;
    line-height: 1.1;
    font-weight: normal;
    opacity: 0.8;
}

.day.other-month {
    opacity: 0.3;
    pointer-events: none;
}

/* Vacation Bars in Calendar */
.vacation-bar {
    padding: 3px 6px;
    margin-bottom: 2px;
    border-radius: 3px;
    color: black;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.status-pending {
    background-color: var(--pending);
    color: #5a4a00;
    border-left: 3px solid #f39c12;
}

.status-approved {
    background-color: var(--success);
    color: white;
    border-left: 3px solid #1e8449;
}

.status-rejected {
    background-color: var(--danger);
    color: white;
    opacity: 0.6;
    text-decoration: line-through;
}

/* Lists & Stats */
.request-item {
    border-left: 4px solid var(--pending);
    padding: 10px;
    margin-bottom: 10px;
    background: var(--day-hover);
    border-radius: 0 4px 4px 0;
    font-size: 13px;
    position: relative;
}

.overview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 10px;
    color: var(--text-main);
}

.overview-table th {
    text-align: left;
    border-bottom: 2px solid var(--border);
    padding: 5px;
    color: var(--text-muted);
}

.overview-table td {
    border-bottom: 1px solid var(--border);
    padding: 5px;
    vertical-align: middle;
}

.overview-table input[type="number"] {
    margin: 0;
    width: 50px;
    padding: 4px;
    text-align: center;
    border: 1px solid var(--accent);
    border-radius: 3px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 5px;
    text-align: center;
    margin-bottom: 5px;
}

.stat-box {
    background: var(--day-hover);
    padding: 8px 2px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.stat-val {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* User Bubble List */
.user-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 15px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 5px;
}

.user-list-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    color: #333;
    transition: transform 0.1s;
}

.user-list-item:hover {
    transform: translateX(2px);
    filter: brightness(0.95);
}

/* GLOBAL LOGIN OVERLAY */
#globalLoginOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 5000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s;
}

.login-container {
    width: 90%;
    max-width: 350px;
    /* Responsive Width */
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    border: 1px solid var(--border);
}

.login-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.login-tab {
    flex: 1;
    padding: 10px;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    font-weight: bold;
}

.login-tab.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
}

/* LOGO */
.login-logo-img {
    max-width: 100%;
    height: auto;
    margin-bottom: 15px;
    border-radius: 4px;
}

/* Modal & Loader */
#modalOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

#modalBox {
    background: var(--card-bg);
    color: var(--text-main);
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    text-align: center;
    border: 1px solid var(--border);
}

#backendStatus {
    font-size: 10px;
    text-align: right;
    color: var(--text-muted);
    margin-bottom: 5px;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}