/* === Basic Reset & Body Styling === */
*, *::before, *::after {
    box-sizing: border-box; /* Apply box-sizing universally */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; /* Modern font stack */
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa; /* Lighter background */
    color: #212529; /* Darker default text */
    display: flex; /* Needed if page-wrapper is direct child */
    min-height: 100vh;
    font-size: 16px; /* Base font size */
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
}
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

a {
    color: #007bff;
    text-decoration: none;
    background-color: transparent;
}
a:hover {
    color: #0056b3;
    text-decoration: underline;
}

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

/* === Layout with Sidebar === */
.page-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden; /* Prevent wrapper causing horizontal scroll */
}

/* Sidebar Styles */
.sidebar {
    width: 250px; /* Sidebar width */
    background-color: #343a40; /* Dark background */
    color: #adb5bd; /* Light text color */
    flex-shrink: 0; /* Prevent sidebar from shrinking */
    display: flex;
    flex-direction: column;
    position: fixed; /* Fixed position by default */
    left: 0;
    top: 0;
    height: 100vh; /* Full viewport height */
    z-index: 1030; /* High z-index */
    transition: left 0.3s ease-in-out; /* Animate sliding */
}

.sidebar-header {
    padding: 15px 20px;
    background-color: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    color: #fff;
    flex-shrink: 0;
    border-bottom: 1px solid #495057;
}
.sidebar-header .logo-text { font-size: 1.8em; font-weight: bold; margin-right: 10px; color: #a855f7; }
.sidebar-header .sidebar-title { font-size: 1.1em; font-weight: 500; }

.sidebar-nav {
    flex-grow: 1; /* Allow nav to fill remaining space */
    overflow-y: auto; /* Add scroll if menu is long */
    padding-top: 10px; /* Space above first menu item */
}
.sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li { margin: 0; }
.sidebar-nav .menu-header { padding: 15px 20px 5px 20px; font-size: 0.75em; font-weight: 700; color: #6c757d; text-transform: uppercase; letter-spacing: 0.8px; }
.sidebar-nav a { display: block; padding: 10px 20px; color: #dee2e6; text-decoration: none; font-size: 0.95em; border-left: 4px solid transparent; transition: background-color 0.2s ease, border-left-color 0.2s ease, color 0.2s ease; }
.sidebar-nav a:hover { background-color: rgba(255, 255, 255, 0.05); color: #fff; }
.sidebar-nav li.active > a { background-color: rgba(255, 255, 255, 0.08); color: #fff; font-weight: 500; border-left-color: #a855f7; }

/* Content Wrapper Styles */
.content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa; /* Main background */
    margin-left: 250px; /* Space for the sidebar */
    transition: margin-left 0.3s ease-in-out; /* Match sidebar */
    min-width: 0; /* Important for flex item responsiveness */
}

/* Top Bar Styles */
.top-bar {
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0 15px;
    height: 60px; /* Adjust height */
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    flex-shrink: 0;
    position: sticky; /* Make top bar sticky */
    top: 0;
    z-index: 1020; /* Below sidebar */
}
.mobile-menu-toggle { display: none; background: none; border: none; font-size: 1.8em; cursor: pointer; color: #333; margin-right: 15px; padding: 5px; line-height: 1; }
.top-bar-title { font-size: 1.2em; font-weight: 500; color: #333; margin-left: 10px; }

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 25px;
    margin: 0;
    overflow-y: auto; /* Allow content itself to scroll if needed */
}

/* Footer Styles */
.main-footer {
    background-color: #e9ecef;
    color: #495057;
    text-align: center;
    padding: 15px 25px;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
}


/* === Component Styles === */

/* Forms */
form { margin-bottom: 20px; }
form p, form div[style*="margin-bottom"] { margin-bottom: 1rem; } /* Target divs with mb */
label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: #495057; }
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
    display: block; width: 100%; padding: 0.5rem 0.75rem; font-size: 1rem; line-height: 1.5; color: #495057; background-color: #fff; background-clip: padding-box; border: 1px solid #ced4da; border-radius: 0.25rem; transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out; box-sizing: border-box;
}
input:focus, select:focus, textarea:focus { border-color: #80bdff; outline: 0; box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25); }
textarea { min-height: 80px; resize: vertical; }
fieldset { padding: 1rem 1.5rem; margin-bottom: 1rem; border: 1px solid #ced4da; border-radius: 0.25rem; }
legend { width: auto; padding: 0 0.5rem; font-size: 1rem; font-weight: 500; }

/* Buttons */
button, input[type="submit"], a.button { display: inline-block; font-weight: 400; color: #fff; text-align: center; vertical-align: middle; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background-color: #28a745; border: 1px solid #28a745; padding: 0.5rem 1rem; font-size: 1rem; line-height: 1.5; border-radius: 0.25rem; transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out; text-decoration: none !important; margin: 0; }
button:hover, input[type="submit"]:hover, a.button:hover { background-color: #218838; border-color: #1e7e34; color: #fff; }
button:focus, input[type="submit"]:focus, a.button:focus { box-shadow: 0 0 0 0.2rem rgba(40,167,69,.5); }
button:disabled, input[type="submit"]:disabled, a.button.disabled { background-color: #28a745; border-color: #28a745; opacity: .65; cursor: not-allowed; }
button.secondary, a.button.secondary { background-color: #6c757d; border-color: #6c757d; }
button.secondary:hover, a.button.secondary:hover { background-color: #5a6268; border-color: #545b62; }
button.secondary:focus, a.button.secondary:focus { box-shadow: 0 0 0 0.2rem rgba(108,117,125,.5); }
button.danger, .delete-btn, a.button.danger { background-color: #dc3545; border-color: #dc3545; }
button.danger:hover, .delete-btn:hover, a.button.danger:hover { background-color: #c82333; border-color: #bd2130; }
button.danger:focus, .delete-btn:focus, a.button.danger:focus { box-shadow: 0 0 0 0.2rem rgba(220,53,69,.5); }

/* Tables */
table { width: 100%; margin-bottom: 1rem; color: #212529; border-collapse: collapse; }
th, td { padding: 0.75rem; vertical-align: top; border: 1px solid #dee2e6; }
thead th { vertical-align: bottom; border-bottom: 2px solid #dee2e6; background-color: #e9ecef; font-weight: 500; white-space: nowrap;}
tbody tr:nth-of-type(odd) { background-color: rgba(0,0,0,.03); }

/* Flash Messages */
.flash-message { padding: 1rem 1.25rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 0.25rem; font-weight: 500; }
.flash-message.success { color: #155724; background-color: #d4edda; border-color: #c3e6cb; }
.flash-message.error { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; }
.flash-message.info { color: #0c5460; background-color: #d1ecf1; border-color: #bee5eb; }
.flash-message.warning { color: #856404; background-color: #fff3cd; border-color: #ffeeba; }

/* Form Field Errors */
.error-message { color: #dc3545; font-size: 0.875em; margin-top: 0.25rem; display: block; }
input.error, select.error, textarea.error { border-color: #dc3545 !important; } /* Use !important cautiously */
input.error:focus, select.error:focus, textarea.error:focus { border-color: #dc3545; box-shadow: 0 0 0 0.2rem rgba(220,53,69,.25); }

/* Status Badges (Example) */
.status {
    display: inline-block; /* Ensure padding/background applies correctly */
    padding: 0.3em 0.65em; /* Adjust padding */
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.375rem; /* Updated border-radius */
    color: #fff; /* Default white text */
}
.status.pending,
.status.pending-manager,
.status.pending-admin {
    background-color: #ffc107; /* Bootstrap warning yellow/orange */
    color: #212529; /* DARK text for yellow background */
}
.status.approved { background-color: #198754; color: #fff; } /* Bootstrap success green */
.status.rejected { background-color: #dc3545; color: #fff; } /* Bootstrap danger red */
.status.cancelled { background-color: #6c757d; color: #fff; } /* Bootstrap secondary grey */

/* === Dashboard Specific Styles === */
.dashboard-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 30px; }
.kpi-card { background-color: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.05); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.kpi-card .kpi-number { font-size: 2.2rem; font-weight: 600; color: #333; display: block; margin-bottom: 5px; }
.kpi-card .kpi-label { font-size: 0.9em; color: #666; }
.kpi-card a { text-decoration: none; color: inherit; display: block; }
.dashboard-section { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 30px; }
.widget { background-color: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); display: flex; flex-direction: column; }
.widget h3 { margin-top: 0; margin-bottom: 15px; font-size: 1.15em; color: #444; border-bottom: 1px solid #eee; padding-bottom: 8px; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center;}
.widget h3 .widget-action { font-size: 0.8em; font-weight: normal; color: #007bff; }
.widget h3 .widget-action:hover { text-decoration: underline; }
.widget ul { list-style: none; padding: 0; margin: 0; max-height: 200px; overflow-y: auto; flex-grow: 1; }
.widget li { padding: 8px 0; border-bottom: 1px dashed #eee; font-size: 0.95em; display: flex; justify-content: space-between; align-items: center; }
.widget li:last-child { border-bottom: none; }
.widget .detail { font-size: 0.85em; color: #777; margin-left: 10px; white-space: nowrap; flex-shrink: 0; }
.widget .list-item-main { flex-grow: 1; margin-right: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.widget p { color: #666; font-style: italic; margin-top: 10px; flex-grow: 1; }
.chart-widget { position: relative; height: 350px; } /* Chart container */
.chart-widget canvas { max-width: 100%; flex-grow: 1; }
.quick-links { background-color: #f8f9fa; padding: 15px; border-radius: 5px; text-align: center; border: 1px solid #e0e0e0; }
.quick-links h3 { margin-bottom: 15px; }
.quick-links a.button { margin: 5px; }

/* Calendar Styles */
.calendar-controls { margin-bottom: 20px; padding: 15px; border: 1px solid #eee; background: #f9f9f9; border-radius: 5px; }
.calendar-controls > div { display: flex; flex-wrap: wrap; gap: 15px; align-items: flex-end; } /* Adjust alignment */
.calendar-container { margin-top: 30px; }
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th, .calendar td { border: 1px solid #ddd; padding: 6px; text-align: left; height: 110px; vertical-align: top; overflow: hidden;}
.calendar th { background-color: #f2f2f2; text-align: center; height: auto; font-weight: 500;}
.calendar .day-number { font-weight: 500; display: block; margin-bottom: 5px; text-align: right; font-size: 1em; color: #6c757d;}
.calendar .holiday { font-size: 0.75em; color: #856404; background-color: #fff3cd; padding: 2px 4px; border-radius: 3px; margin-bottom: 3px; display: inline-block; font-weight: 500;}
.calendar .weekend { background-color: #f9f9f9; }
.calendar .leave-info { font-size: 0.75em; margin-top: 3px; line-height: 1.4; max-height: 65px; overflow-y: auto; }
.calendar .leave-name { display: block; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background-color: #e9f5ff; padding: 2px 4px; border-radius: 3px; border: 1px solid #b8daff; }
.calendar .leave-half-am { border-left: 3px solid #ffc107; padding-left: 5px; }
.calendar .leave-half-pm { border-left: 3px solid #17a2b8; padding-left: 5px; }

/* === Login Page Specific Styles === */

.login-page-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #e9ecef; /* Light grey background for the page */
    padding: 20px; /* Add padding for small screens */
    flex-direction: column; /* Stack container and footer */
}

.login-container {
    width: 100%;
    max-width: 420px; /* Max width of the login box */
    background-color: #fff; /* White background for the box */
    padding: 30px 40px; /* Generous padding inside the box */
    border-radius: 8px; /* Rounded corners */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    text-align: center; /* Center header/logo */
    margin-bottom: 20px; /* Space above footer */
}

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

.login-header .logo-text { /* Reuse logo style */
    font-size: 2.5em;
    font-weight: bold;
    color: #a855f7; /* Purple */
    display: block; /* Make it block to center */
    margin-bottom: 10px;
}

.login-header h2 {
    font-size: 1.5em;
    color: #343a40; /* Dark grey heading */
    margin-bottom: 5px;
}

/* Style for login form elements */
.login-form .form-group {
    margin-bottom: 1.25rem;
    text-align: left; /* Align labels left */
}

.login-form label {
    font-weight: 500;
    font-size: 0.9em;
    color: #495057;
    margin-bottom: 0.3rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem; /* Adjust padding */
    font-size: 1rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box; /* Include padding in width */
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
     border-color: #80bdff;
     outline: 0;
     box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.login-form .login-button {
    width: 100%; /* Make login button full width */
    padding: 0.7rem 1rem; /* Slightly larger padding */
    font-size: 1.05em;
    font-weight: 500;
    background-color: #007bff; /* Bootstrap primary blue */
    border-color: #007bff;
    transition: background-color .15s ease-in-out, border-color .15s ease-in-out;
}
.login-form .login-button:hover {
     background-color: #0069d9;
     border-color: #0062cc;
}
.login-form .login-button:focus {
     box-shadow: 0 0 0 0.2rem rgba(38,143,255,.5);
}


/* Styling for login errors / flash messages */
.login-flash-message {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    font-size: 0.95em;
    text-align: center;
}
/* Use existing flash message colors */
.login-flash-message.success { color: #155724; background-color: #d4edda; border-color: #c3e6cb; }
.login-flash-message.error { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; }
.login-flash-message.info { color: #0c5460; background-color: #d1ecf1; border-color: #bee5eb; }
.login-flash-message.warning { color: #856404; background-color: #fff3cd; border-color: #ffeeba; }


/* Optional links styling */
.login-links {
    margin-top: 1.5rem;
    font-size: 0.9em;
}
.login-links a {
    color: #007bff;
    text-decoration: none;
}
.login-links a:hover {
    text-decoration: underline;
}

/* Footer specific to login page */
.login-footer {
    margin-top: auto; /* Push footer down if content is short */
    padding: 15px;
    text-align: center;
    font-size: 0.85em;
    color: #6c757d; /* Muted color */
    width: 100%;
}

/* === Responsive Adjustments === */
@media (max-width: 991.98px) { /* Sidebar breakpoint */
    .sidebar {
        left: -250px; /* Start off-screen */
    }
    .sidebar.sidebar-visible {
        left: 0; /* Slide in */
        box-shadow: 0 0 15px rgba(0,0,0,0.2);
    }
    .content-wrapper {
         margin-left: 0; /* Content takes full width */
    }
    .mobile-menu-toggle {
        display: block; /* Show toggle button */
    }
    .page-wrapper.sidebar-active .content-wrapper::before { /* Optional overlay */
        content: ''; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.4); z-index: 1029; /* Below sidebar */
    }
}

@media (max-width: 768px) {
    .main-content { padding: 15px; }
    .main-footer { padding: 10px 15px; font-size: 0.9em; }
    .kpi-card .kpi-number { font-size: 2em; }
    .widget h3 { font-size: 1.1em; }
    .calendar th, .calendar td { height: 90px; font-size: 0.9em; }
    .calendar .leave-info { max-height: 50px; font-size: 0.7em;}
}

@media (max-width: 480px) {
     .kpi-card .kpi-number { font-size: 1.8em; }
     .widget h3 { font-size: 1.05em; }
     .calendar th { font-size: 0.8em; }
     .calendar td { height: 75px; padding: 4px;}
     .calendar .day-number { font-size: 0.9em; }
     .calendar .leave-info { max-height: 45px;}
     .quick-links a.button { padding: 6px 10px; font-size: 0.9em; }
     .top-bar-title { font-size: 1.1em; }
}