/* =========================================
   SGVP CONNECT - FIXED MOBILE LAYOUT
   ========================================= */
:root {
    --primary: #4f46e5;       
    --bg-body: #f3f4f6;       
    --text-main: #111827;     
    --text-muted: #6b7280;    
    --border: #e5e7eb;        
    --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; -webkit-tap-highlight-color: transparent; }

/* --- CRITICAL FIX: PREVENT HORIZONTAL SCROLL --- */
html, body { 
    height: 100%; 
    width: 100%; 
    background: var(--bg-body); 
    color: var(--text-main); 
    overflow-x: hidden; /* Forces no horizontal scrollbar */
    position: relative;
}

/* --- LOGIN --- */
.login-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
}
.login-card {
    background: white; padding: 30px; border-radius: 16px; 
    width: 90%; max-width: 380px; text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.dot { width: 12px; height: 12px; background: #e5e7eb; border-radius: 50%; transition: 0.2s; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.pin-pad button {
    padding: 15px; border-radius: 12px; border: 1px solid #e5e7eb; background: #f9fafb;
    font-size: 1.25rem; font-weight: 600; cursor: pointer;
}
.pin-pad button:active { background: #e5e7eb; transform: scale(0.95); }

/* --- APP LAYOUT --- */
.app-container { display: flex; height: 100%; width: 100%; }
.sidebar {
    width: var(--sidebar-width); background: white; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 20px;
}
.main-content { flex: 1; padding: 20px; overflow-y: auto; position: relative; width: 100%; }

/* Volunteer Mode: Hide Sidebar & Checkboxes */
body.volunteer-mode .sidebar { display: none !important; }
body.volunteer-mode .main-content { width: 100%; padding: 15px; margin: 0; }
body.volunteer-mode .col-checkbox { display: none !important; } /* HIDES CHECKBOXES FOR VOLUNTEERS */

/* --- COMPONENTS --- */
.brand { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: 30px; }
.user-profile { display: flex; align-items: center; padding: 15px; background: #f3f4f6; border-radius: 12px; margin-bottom: 20px; }
.nav-menu { display: flex; flex-direction: column; gap: 5px; }
.nav-item {
    padding: 12px; border-radius: 8px; color: var(--text-muted); text-decoration: none;
    font-weight: 500; display: flex; align-items: center; gap: 10px; transition: 0.2s; cursor: pointer;
}
.nav-item:hover { background: #f3f4f6; color: var(--text-main); }
.nav-item.active { background: #e0e7ff; color: var(--primary); }

.card { background: white; border-radius: 12px; padding: 20px; border: 1px solid var(--border); margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); width: 100%; }
.btn-primary { background: var(--primary); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.btn-secondary { background: white; border: 1px solid var(--border); color: var(--text-main); padding: 8px 16px; border-radius: 8px; cursor: pointer; }
.std-input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; outline: none; transition: 0.2s; background: #fff; }

/* --- STATS OVERVIEW --- */
.stats-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat-card { background: white; padding: 15px; border-radius: 12px; border: 1px solid var(--border); text-align: center; }
.stat-card h3 { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 5px; }
.stat-card .val { font-size: 1.5rem; font-weight: 800; color: var(--text-main); }

/* --- TABLE STYLES --- */
.table-container { overflow-x: auto; width: 100%; }
.data-table { width: 100%; border-collapse: collapse; min-width: 600px; /* Default desktop width */ }
.data-table th, .data-table td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { background: #f9fafb; font-weight: 600; color: var(--text-muted); font-size: 0.85rem; }
.col-checkbox { width: 40px; text-align: center; }

/* Badge Colors */
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; display: inline-block; }
.badge-pending { background: #eff6ff; color: #1d4ed8; }
.badge-confirmed { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-callback { background: #fef3c7; color: #92400e; }
.badge-noans { background: #f3f4f6; color: #374151; }
.badge-unassigned { background: #f3f4f6; color: #6b7280; border: 1px dashed #cbd5e1; }

/* --- ICONS --- */
.action-btn-group { display: flex; gap: 8px; }
.icon-btn { width: 32px; height: 32px; border-radius: 6px; border: 1px solid transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; background: white; }
.icon-btn.active-state { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.icon-btn.inactive-state { color: #9ca3af; border-color: #e5e7eb; background: #f9fafb; }
.icon-btn.delete { color: #ef4444; border-color: #fee2e2; background: #fef2f2; }

/* --- FILTER BUTTONS (Desktop) --- */
.filter-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 5px; margin-bottom: 15px; }
.filter-btn {
    padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border);
    background: white; color: var(--text-muted); font-weight: 600; font-size: 0.85rem;
    cursor: pointer; white-space: nowrap; transition: 0.2s; display: flex; align-items: center; gap: 6px;
}
.filter-btn:hover { background: #f9fafb; }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.filter-btn.active .f-count { background: rgba(255,255,255,0.2); color: white; }
.f-count { background: #f3f4f6; color: var(--text-muted); padding: 2px 6px; border-radius: 10px; font-size: 0.75rem; }

/* --- DESKTOP ACTION GRID --- */
.action-grid-2x2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-width: 160px; }
.action-grid-2x2 button { padding: 6px; border: none; border-radius: 6px; font-size: 0.75rem; font-weight: 600; color: white; cursor: pointer; }
.btn-confirm { background: #10b981; }
.btn-reject { background: #ef4444; }
.btn-callback { background: #f59e0b; }
.btn-noans { background: #6b7280; }

.hidden { display: none !important; }
.toast { background: #333; color: white; padding: 12px 24px; border-radius: 8px; margin-top: 10px; }
.toast.error { background: #ef4444; }

/* =========================================
   MOBILE RESPONSIVENESS (320px - 768px)
   ========================================= */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { display: none; }
    .main-content { padding: 10px; width: 100vw; overflow-x: hidden; }

    /* RESET TABLE CONSTRAINTS (Crucial for fixing scroll) */
    .data-table { min-width: 0 !important; width: 100% !important; display: block; }
    
    .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table thead { display: none; }
    
    .data-table tr { 
        background: white; margin-bottom: 12px; border-radius: 12px; 
        border: 1px solid var(--border); padding: 12px; position: relative; 
        box-sizing: border-box; /* Ensures padding is inside width */
    }
    
    .data-table td { 
        padding: 4px 0; border: none; 
        display: flex; justify-content: space-between; align-items: center; 
    }
    
    .data-table td.col-checkbox { position: absolute; top: 12px; right: 12px; width: auto; }
    
    /* Make actions row full width container */
    .data-table td:last-child { 
        margin-top: 12px; padding-top: 12px; border-top: 1px solid #f3f4f6; 
        display: block; width: 100%; 
    }

    /* --- FILTER GRID (3x2 Layout) --- */
    .filter-scroll {
        display: grid;
        grid-template-columns: repeat(3, 1fr); /* Force 3 columns */
        gap: 8px;
        overflow-x: hidden; /* Disable horizontal scroll */
        padding-bottom: 0;
        width: 100%;
    }
    
    .filter-btn {
        width: 100%;
        justify-content: center;
        flex-direction: column; /* Stack Label & Count */
        padding: 10px 4px;
        font-size: 0.75rem; /* Slightly smaller text */
        gap: 4px;
        border-radius: 8px;
        text-align: center;
    }

    /* --- ACTION GRID (No Scroll Fix) --- */
    .action-grid-2x2 {
        display: grid;
        /* minmax(0, 1fr) is the magic fix that prevents overflow */
        grid-template-columns: repeat(2, minmax(0, 1fr)); 
        gap: 8px;
        width: 100%;
        min-width: 0 !important; /* Override desktop min-width */
        margin-top: 5px;
    }
    
    .action-grid-2x2 button {
        width: 100%;
        justify-content: center;
        padding: 10px 0;
        font-size: 0.8rem;
        white-space: nowrap;      /* Keep on one line */
        overflow: hidden;         /* Hide spillover */
        text-overflow: ellipsis;  /* Add ... if too long */
    }
}
