/* =========================================
   MOBILE RESPONSIVE STYLES (App View)
   ========================================= */

@media (max-width: 640px) {
    .manage-table {
        font-size: 13px;
    }

    .action-row {
        flex-direction: column;
    }

    .btn-present,
    .btn-absent {
        width: 100%;
    }
}

@media screen and (max-width: 768px) {

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        max-width: 85vw;
        transform: translateX(-110%);
        transition: transform 0.25s ease;
        z-index: 1001;
    }

    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }

    .sidebar-header h2 { font-size: 1.1rem; }

    /* 2. MAIN CONTENT FIXES */
    .main-content {
        margin-left: 0 !important; /* Override desktop margin */
        width: 100%;
        padding: 15px;
        padding-bottom: 80px; /* Extra space at bottom */
    }

    /* 3. FORM STACKING */
    .split-form {
        display: grid;
        grid-template-columns: 1fr !important; /* Force single column */
        gap: 15px;
    }
    
    .tool-row {
        flex-direction: column; /* Stack inputs in Salary Tools */
    }

    /* 4. LARGER TOUCH TARGETS */
    .input-style, select.input-style, .btn-login {
        height: 45px; /* Taller for thumbs */
        font-size: 16px; /* Prevents iOS zooming */
    }
    
    button {
        width: 100%; /* Full width buttons */
        margin-top: 10px;
    }

    /* 5. TABLE SCROLLING */
    /* Ensure tables inside cards can scroll horizontally */
    .card {
        overflow-x: auto; 
    }
    
    table {
        min-width: 600px; /* Force table to keep its width so it scrolls */
    }
    
    /* 6. TAB NAVIGATION (From emp.css) */
    .tab-container {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .tab {
        flex: 1 1 auto; /* Grow to fill space */
        text-align: center;
        padding: 10px 5px;
        font-size: 13px;
    }
    
    /* 7. HIDE/ADJUST HEADER ELEMENTS */
    h1 {
        font-size: 20px;
        margin-top: 5px;
    }
    
    /* Bank Grid in Employee Form */
    .bank-grid {
        grid-template-columns: 1fr !important;
    }

    /* Attendance Logs */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .compact-form-group,
    .compact-form-group .input-style,
    .min-width-220,
    .logs-search-btn,
    .logs-reset-link {
        width: 100%;
    }

    .logs-reset-link {
        text-align: center;
        display: inline-block;
        padding: 12px 10px;
    }

    .card-no-pad-overflow-hidden {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .manage-table {
        min-width: 760px;
    }

    /* Detailed Report */
    .detailed-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .detailed-toolbar {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .detailed-toolbar .btn-export,
    .detailed-toolbar form,
    .detailed-toolbar .input-style {
        width: 100%;
    }

    .detailed-legend {
        gap: 8px;
    }

    .report-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table.matrix-table {
        min-width: 1100px;
    }

    /* Holiday Calendar */
    .holiday-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .holiday-topbar h1 {
        margin: 0;
    }

    .holiday-filter-form {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 12px;
    }

    .holiday-month-input,
    .holiday-filter-btn,
    .holiday-clear-link {
        width: 100%;
    }

    .holiday-clear-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        border: 1px solid #fecaca;
        border-radius: 10px;
        background: #fff1f2;
        color: #b91c1c;
        font-weight: 700;
        text-decoration: none;
    }

    .layout-grid-admin,
    .layout-grid-user {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    .holiday-admin-card {
        position: static;
        top: auto;
    }

    .holiday-card {
        position: relative;
        padding: 12px 46px 12px 12px;
        border-radius: 12px;
        margin-bottom: 10px;
        align-items: flex-start;
    }

    .holiday-card-left {
        width: 100%;
        align-items: flex-start;
    }

    .holiday-event-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .holiday-delete-btn {
        position: absolute;
        right: 10px;
        top: 10px;
        width: 32px;
        height: 32px;
        align-self: auto;
    }

    .holiday-upcoming-title {
        margin-bottom: 12px;
    }

    .holiday-empty-upcoming {
        padding: 20px 14px;
    }

    .holiday-past-title {
        margin-top: 24px;
    }

    /* Leave Request Page */
    .split-layout {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    .balance-card {
        margin-bottom: 14px;
    }

    .bal-count {
        font-size: 30px;
    }

    #leaveForm .form-group {
        margin-bottom: 10px;
    }

    .request-card {
        padding: 12px;
    }

    .request-action-row {
        flex-direction: column;
        gap: 8px;
    }

    .request-action-row .action-link {
        width: 100%;
        text-align: center;
    }

    .approved-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .approved-filters {
        margin-left: 0;
        width: 100%;
        flex-wrap: wrap;
        white-space: normal;
        gap: 8px;
    }

    .approved-filters .input-style,
    .approved-filters .action-link {
        width: 100%;
        min-width: 0;
    }

    #approved-results,
    .approved-load-more-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .compact-table {
        min-width: 760px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 12px;
        padding-bottom: 74px;
    }

    h1 {
        font-size: 18px;
        line-height: 1.3;
    }

    .manage-table {
        min-width: 700px;
    }

    table.matrix-table {
        min-width: 980px;
    }

    .date-box {
        min-width: 52px;
        margin-right: 10px;
    }

    .date-day {
        font-size: 20px;
    }

    .date-month {
        font-size: 10px;
    }

    .holiday-event-name {
        font-size: 15px;
    }

    .badge-manual,
    .badge-sunday {
        font-size: 9px;
        padding: 2px 7px;
    }

    .bal-label {
        font-size: 12px;
        letter-spacing: 0.6px;
    }

    .bal-count {
        font-size: 26px;
    }

    .request-date-line,
    .request-applied-line,
    .reason-box {
        font-size: 12px;
    }

    .compact-table {
        min-width: 700px;
    }
}
