/* responsive.css */

/* --- Mobile Header --- */
.mobile-header {
    display: none;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.mobile-header .brand {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 0;
    background: linear-gradient(45deg, var(--text-main), var(--text-muted));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mobile-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.mobile-menu-btn:hover {
    color: var(--accent-primary);
}

/* --- Sidebar Overlay --- */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* --- Responsive Layout (Max Width: 991px) --- */
@media (max-width: 991px) {
    body {
        height: auto;
        overflow: visible;
    }

    /* Container changes to block to stack naturally */
    .dashboard-container {
        display: flex !important;
        flex-direction: column !important;
        height: 100vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 9999 !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
        overflow-y: auto;
        padding-top: 1.5rem;
    }

    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar .brand {
        display: none; /* Hide brand inside sidebar since it's on header */
    }

    .sidebar .theme-toggle {
        display: none; /* Can be moved to header or let users toggle in header */
    }

    /* Main Content adjustments */
    .main-content {
        flex: 1;
        padding: 1rem;
        overflow-y: visible !important;
        height: auto !important;
    }

    /* Right Panel adjustments */
    .right-panel {
        height: auto;
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding: 1rem;
        overflow-y: visible !important;
    }

    /* Data Visualization / Charts */
    .stats-row {
        grid-template-columns: 1fr 1fr !important; /* 2 columns for tablets */
        gap: 1rem !important;
    }
    
    .chart-section {
        grid-template-columns: 1fr !important; /* 1 column for charts */
    }

    /* Global Forms & Inputs */
    .form-row, 
    .filtros-container {
        grid-template-columns: 1fr !important;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    /* Tables */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
        margin-bottom: 1rem;
    }
    
    table.op-table,
    table.custom-table {
        min-width: 600px;
    }
    
    .content-card {
        padding: 1rem;
        overflow-x: auto;
    }

    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Votante detail fixes */
    .detail-wrapper {
        grid-template-columns: 1fr !important;
    }
    .info-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.25rem;
    }
    .info-value {
        width: 100%;
        text-align: left !important;
        word-break: break-word;
    }

    /* Votantes list fix */
    table.dataTable.table tbody td {
        white-space: nowrap;
        font-size: 0.85rem;
    }

    /* Lideres list fix */
    .summary-cards {
        grid-template-columns: 1fr !important;
    }
    .leader-node {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }
    .leader-stats {
        width: 100%;
        justify-content: flex-start;
        gap: 2rem !important;
    }

    /* Consulta votante fix */
    .search-input-group {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    .search-input-group button, .search-input-group input {
        width: 100%;
    }
    .wizard-card {
        padding: 1.5rem !important;
    }
    .estado-buttons .btn-estado {
        padding: 1rem !important;
    }
}

/* --- Smart Phones (Max Width: 576px) --- */
@media (max-width: 576px) {
    .stats-row {
        grid-template-columns: 1fr !important; /* 1 column for phones */
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .action-btn, 
    .btn-action, 
    .btn-add {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    .login-card {
        padding: 1.5rem;
    }
    
    .chart-card {
        padding: 1rem;
    }
}
