/* Base Styles */
:root {
    --primary: #3498db;
    --secondary: #2c3e50;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --light: #ecf0f1;
    --dark: #34495e;
    --gray: #95a5a6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    font-size: 14px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Header Styles */
header {
    background-color: var(--secondary);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: bold;
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid white;
    color: white;
}

.btn-outline:hover {
    background: white;
    color: var(--secondary);
}

/* ===== Navigation Styles (Vertical) ===== */
nav {
    background-color: var(--primary);
    position: sticky;
    top: 68px;
    z-index: 99;
}

.nav-menu {
    display: flex;
    flex-direction: row;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.nav-menu li {
    flex: 1;
    min-width: 120px;
    border-bottom: 3px solid transparent;
    transition: border-color 0.3s;
}

.nav-menu li:hover,
.nav-menu li:has(a.active) {
    border-bottom-color: white;
}

.nav-menu a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 1rem;
    text-align: center;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.nav-menu a:hover,
.nav-menu a.active {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Hamburger button (hidden on desktop) */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    flex-direction: column;
    justify-content: space-between;
    width: 40px;
    height: 34px;
}

.menu-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background: white;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

.menu-toggle.active span:nth-child(1) {
    transform: translateY(11px) rotate(45deg);
}
.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}
.menu-toggle.active span:nth-child(3) {
    transform: translateY(-11px) rotate(-45deg);
}

/* Overlay (mobile only) */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s;
}

.nav-overlay.active {
    display: block;
    opacity: 1;
}

/* Main Content Styles */
main {
    padding: 1.5rem 0;
    min-height: calc(100vh - 140px);
}

.section {
    display: none;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
    flex-direction: column;
    gap: 1rem;
}

.section-header h2 {
    color: var(--secondary);
    margin: 0;
    font-size: 1.5rem;
}

.section-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

input, select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.btn {
    display: inline-block;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
    border: 1px solid transparent;
}

.btn:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-success {
    background-color: var(--success);
}

.btn-success:hover {
    background-color: #27ae60;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-warning {
    background-color: var(--warning);
}

.btn-warning:hover {
    background-color: #d35400;
}

.btn-info {
    background-color: var(--primary);
}

.btn-info:hover {
    background-color: #2980b9;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    min-width: 600px;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #f8f9fa;
}

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Dashboard Styles */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 1.25rem;
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    margin: 0.5rem 0;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

/* Search Bar */
.search-container {
    margin-bottom: 1rem;
}

.search-bar {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23999'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 20px;
    padding-left: 40px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Login Page Styles */
.login-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    overflow: hidden;
}

.login-header {
    background: var(--secondary);
    color: white;
    padding: 2rem;
    text-align: center;
}

.login-header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
}

.login-header p {
    margin: 0;
    opacity: 0.8;
}

.login-form {
    padding: 2rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.login-footer {
    padding: 1rem 2rem;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    font-size: 0.875rem;
    color: #666;
}

/* Report Styles */
.report-header {
    background: #f8f9fa;
    padding: 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
}

.report-summary {
    background: #e8f4fd;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
}

.report-summary p {
    margin: 0.5rem 0;
}

/* Footer Styles */
footer {
    background-color: var(--secondary);
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
}

/* Utility Classes */
.text-right {
    text-align: right;
}

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

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

.mt-1 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 1rem;
}

.hidden {
    display: none;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.form-right {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* Mobile-First Responsive Design */
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }

    .container {
        padding: 0 10px;
    }

    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
        gap: 0.5rem;
        flex-wrap: nowrap;
    }

    .menu-toggle {
        display: flex;
        order: -1;
        flex-shrink: 0;
    }

    .logo {
        flex: 1;
        font-size: 1rem;
        white-space: normal;
        line-height: 1.2;
        text-align: left;
    }

    .user-info {
        justify-content: flex-end;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    .user-info span {
        display: none; /* Hide "Welcome, username" on small screens */
    }

    /* Off-canvas sidebar */
   nav {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        max-width: 80vw;
        padding-top: 1rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }

    nav.open {
        transform: translateX(0);
    }

    .nav-menu {
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .nav-menu li {
        flex: none;
        width: 100%;
        min-width: 0;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        border-left: 3px solid transparent;
        transition: border-color 0.3s, background-color 0.3s;
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }

    .nav-menu li:hover,
    .nav-menu li:has(a.active) {
        border-bottom-color: rgba(255,255,255,0.1);
        border-left-color: white;
    }

    .nav-menu a {
        padding: 1rem 1.25rem;
        text-align: left;
    }
}

    main {
        padding: 1rem 0;
    }

    .section {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 6px;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .section-header-actions {
        justify-content: stretch;
    }

    .section-header-actions .btn {
        flex: 1;
        min-width: 120px;
    }

    .stats-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .modal-content {
        margin: 1rem;
        padding: 1.25rem;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn {
        min-width: 80px;
    }

    table {
        font-size: 0.875rem;
    }

    th, td {
        padding: 0.5rem;
    }

    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }

    .form-right {
        flex-direction: column;
    }

    .form-right .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-form {
        padding: 1.5rem;
    }

    .login-header {
        padding: 1.5rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    .section-header h2 {
        font-size: 1.25rem;
    }

    .search-bar {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    input, select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Print Styles */
@media print {
    header, nav, footer, .section-header-actions, .actions, .nav-overlay, .menu-toggle {
        display: none !important;
    }

    .section {
        display: block !important;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    body {
        background: white;
        font-size: 12pt;
    }

    .container {
        max-width: none;
        padding: 0;
    }
}

/* Badge styles */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.badge-warning {
    background-color: var(--warning);
    color: white;
}

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

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

.badge-success {
    background-color: var(--success);
    color: white;
}

/* Button sizes */
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

/* Enhanced table styles */
.table-responsive {
    overflow-x: auto;
    margin-top: 1rem;
}

/* Adjustment specific styles */
.adjustment-pending {
    background-color: #fff3cd;
}

.adjustment-deducted {
    background-color: #d1ecf1;
}

/* Payroll calculation styles */
.payroll-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    border-left: 4px solid var(--primary);
}

.calculation-row {
    display: flex;
    justify-content: space-between;
    margin: 0.5rem 0;
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
}

.calculation-label {
    font-weight: 500;
}

.calculation-amount {
    font-weight: bold;
}

.deduction-amount {
    color: var(--danger);
}

.net-pay-amount {
    color: var(--success);
    font-size: 1.1em;
}

/* Loading state for payroll form */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}