/* ===================================
   RESPONSIVE DESIGN - MOBILE FIRST
   =================================== */

/* Viewport configuration */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* ===================================
   GLOBAL MOBILE IMPROVEMENTS
   =================================== */

/* Base responsive typography */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    body {
        overflow-x: hidden;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    
    /* Improve touch targets */
    button, a, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better form controls */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 12px;
    }
}

/* ===================================
   HOME PAGE / PORTAL SELECTION
   =================================== */

@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1rem !important;
        min-height: auto !important;
    }
    
    .hero-content h1 {
        font-size: 1.75rem !important;
    }
    
    .hero-content p {
        font-size: 1rem !important;
    }
    
    .portals-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }
    
    .portal-card {
        padding: 1.5rem !important;
    }
    
    .portal-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.75rem !important;
    }
    
    .portal-title {
        font-size: 1.25rem !important;
    }
}

/* ===================================
   LOGIN PAGE
   =================================== */

@media (max-width: 768px) {
    .login-container {
        padding: 1rem !important;
        min-height: 100vh;
    }
    
    .login-card {
        margin: 1rem auto !important;
        padding: 1.5rem !important;
        max-width: 100% !important;
        border-radius: 8px;
    }
    
    .login-header h2 {
        font-size: 1.5rem !important;
    }
    
    .login-logo {
        max-width: 120px !important;
    }
}

/* ===================================
   SOPORTE PAGE (PUBLIC)
   =================================== */

@media (max-width: 768px) {
    .public-header {
        padding: 1rem !important;
    }
    
    .public-header h1 {
        font-size: 1.5rem !important;
    }
    
    .tabs-container {
        padding: 0.5rem !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-button {
        font-size: 0.9rem !important;
        padding: 0.75rem 1rem !important;
        white-space: nowrap;
    }
    
    .ticket-form {
        padding: 1rem !important;
    }
    
    .form-group {
        margin-bottom: 1rem !important;
    }
    
    .btn {
        width: 100%;
        padding: 0.875rem !important;
        font-size: 1rem !important;
    }
}

/* ===================================
   DENUNCIAS PAGE
   =================================== */

@media (max-width: 768px) {
    .denuncias-container {
        padding: 1rem !important;
    }
    
    .denuncias-card {
        padding: 1.5rem !important;
        margin: 1rem 0 !important;
    }
    
    .denuncias-header h1 {
        font-size: 1.5rem !important;
    }
    
    .alert {
        padding: 1rem !important;
        font-size: 0.9rem !important;
    }
    
    .form-section {
        padding: 1rem !important;
    }
    
    .section-title {
        font-size: 1.1rem !important;
    }
}

/* ===================================
   ADMIN DASHBOARD - MOBILE
   =================================== */

@media (max-width: 1024px) {
    .dashboard-wrapper {
        display: flex;
        flex-direction: column;
    }
    
    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    
    .sidebar.active {
        left: 0;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    /* Mobile header */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    .content-header {
        padding: 1rem !important;
        flex-wrap: wrap;
    }
    
    .header-actions {
        margin-top: 0.5rem;
        width: 100%;
    }
    
    /* Stats cards responsive */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .stat-card {
        padding: 1.25rem !important;
    }
    
    /* Charts responsive */
    .row {
        flex-direction: column !important;
    }
    
    .col-8, .col-4, .col-6, .col-3 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding: 0.5rem !important;
    }
    
    .chart-card {
        margin-bottom: 1rem;
    }
    
    /* Quick actions */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .quick-action-card {
        padding: 1rem !important;
    }
    
    .quick-action-icon {
        width: 45px !important;
        height: 45px !important;
        font-size: 1.25rem !important;
    }
    
    /* Tables responsive */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    .table td, .table th {
        padding: 0.75rem 0.5rem !important;
        font-size: 0.875rem !important;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .quick-actions {
        grid-template-columns: 1fr !important;
    }
    
    /* User info compact */
    .user-info {
        padding: 0.75rem !important;
    }
    
    .user-name {
        font-size: 0.9rem !important;
    }
    
    .user-role {
        font-size: 0.75rem !important;
    }
    
    /* Modal responsive */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 1rem auto !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
    
    .modal-header h3 {
        font-size: 1.25rem !important;
    }
    
    .modal-body {
        padding: 1rem !important;
    }
}

/* ===================================
   MOBILE MENU TOGGLE BUTTON
   =================================== */

/* Add this button via JavaScript or PHP */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary, #3498db);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    width: 44px;
    height: 44px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Overlay para cerrar sidebar en mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

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

/* ===================================
   UTILITY CLASSES - MOBILE
   =================================== */

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    .text-center-mobile {
        text-align: center !important;
    }
    
    .full-width-mobile {
        width: 100% !important;
    }
    
    /* Spacing utilities */
    .p-mobile-1 { padding: 0.5rem !important; }
    .p-mobile-2 { padding: 1rem !important; }
    .p-mobile-3 { padding: 1.5rem !important; }
    
    .m-mobile-1 { margin: 0.5rem !important; }
    .m-mobile-2 { margin: 1rem !important; }
    .m-mobile-3 { margin: 1.5rem !important; }
}

/* ===================================
   TOUCH IMPROVEMENTS
   =================================== */

@media (hover: none) {
    /* Remove hover effects on touch devices */
    .portal-card:hover {
        transform: none !important;
    }
    
    .menu-item:hover {
        background: transparent !important;
    }
    
    /* Add active states instead */
    .portal-card:active {
        transform: scale(0.98) !important;
        opacity: 0.9;
    }
    
    .menu-item:active,
    .btn:active {
        opacity: 0.8;
    }
}

/* ===================================
   LANDSCAPE MODE ON PHONES
   =================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding: 1rem !important;
    }
    
    .login-card {
        padding: 1rem !important;
    }
    
    .sidebar {
        padding-top: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem !important;
    }
}

/* ===================================
   SAFE AREA FOR NOTCHED DEVICES
   =================================== */

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .sidebar {
        padding-left: max(1rem, env(safe-area-inset-left));
    }
    
    .mobile-menu-toggle {
        left: max(1rem, env(safe-area-inset-left));
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    .sidebar,
    .mobile-menu-toggle,
    .header-actions,
    .btn,
    .quick-actions {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .table {
        font-size: 10pt;
    }
}
