/* ===== MOBILE FIRST - OTIMIZAÇÃO PREMIUM ===== */

/* Menu Hamburger Moderno */
.mobile-menu-toggle {
    display: none;
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px;
    position: relative;
    z-index: 1001;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
    position: absolute;
    left: 12px;
}

.mobile-menu-toggle span:nth-child(1) {
    top: 16px;
}

.mobile-menu-toggle span:nth-child(2) {
    top: 23px;
}

.mobile-menu-toggle span:nth-child(3) {
    top: 30px;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg);
    top: 23px;
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg);
    top: 23px;
}

/* Overlay Mobile Menu */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 400px;
    height: 100vh;
    background: white;
    z-index: 1000;
    padding: 80px 24px 24px;
    overflow-y: auto;
    transition: var(--transition-slow);
    box-shadow: var(--shadow-2xl);
}

.mobile-nav.active {
    right: 0;
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
    background: var(--primary-gradient);
    color: white;
    transform: translateX(8px);
}

/* Bottom Navigation Mobile */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--background-alt);
    padding: 8px;
    z-index: var(--z-sticky);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

.bottom-nav-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 600;
    transition: var(--transition);
    min-height: 64px;
    justify-content: center;
}

.bottom-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.bottom-nav-icon {
    font-size: 24px;
}

/* Touch Targets Maiores */
@media (max-width: 768px) {
    /* Header Mobile */
    .header-content {
        padding: 12px 16px;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav {
        display: none;
    }
    
    .bottom-nav {
        display: block;
    }
    
    /* Container Mobile */
    .container {
        padding: 16px;
        padding-bottom: 88px; /* Espaço para bottom nav */
    }
    
    /* Botões Mobile - Touch Targets 48px+ */
    .btn {
        min-height: 48px;
        padding: 12px 24px;
        font-size: 1rem;
        font-weight: 600;
    }
    
    .btn-sm {
        min-height: 40px;
        padding: 8px 16px;
        font-size: 0.9375rem;
    }
    
    .btn-lg {
        min-height: 56px;
        padding: 16px 32px;
        font-size: 1.125rem;
    }
    
    /* Cards Mobile */
    .card {
        padding: 20px;
        border-radius: var(--radius-xl);
    }
    
    /* Formulários Mobile */
    .form-input,
    .form-select,
    .form-textarea {
        min-height: 48px;
        font-size: 16px; /* Evita zoom no iOS */
        padding: 12px 16px;
    }
    
    .form-label {
        font-size: 0.9375rem;
        margin-bottom: 8px;
    }
    
    /* Tipografia Mobile */
    h1 {
        font-size: 2rem;
        line-height: 1.1;
        margin-bottom: 16px;
    }
    
    h2 {
        font-size: 1.75rem;
        line-height: 1.2;
        margin-bottom: 12px;
    }
    
    h3 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    p {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    /* Grid Mobile */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    /* Stats Mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .stat-card {
        padding: 24px;
    }
    
    .stat-value {
        font-size: 2.5rem;
    }
    
    /* Tabelas Mobile - Transformar em Cards */
    .table-container {
        border-radius: var(--radius-lg);
        overflow: visible;
    }
    
    .table {
        display: block;
    }
    
    .table thead {
        display: none;
    }
    
    .table tbody {
        display: block;
    }
    
    .table tr {
        display: block;
        margin-bottom: 16px;
        background: white;
        border-radius: var(--radius-lg);
        padding: 16px;
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--background-alt);
    }
    
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border: none;
    }
    
    .table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-tertiary);
        font-size: 0.875rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    
    .table td:first-child {
        padding-top: 0;
        font-size: 1.125rem;
        font-weight: 700;
    }
    
    .table td:last-child {
        padding-bottom: 0;
        border-bottom: none;
    }
    
    /* Modal Mobile */
    .modal {
        width: 100%;
        max-height: 95vh;
        margin: 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        position: fixed;
        bottom: 0;
        top: auto;
    }
    
    .modal-overlay {
        align-items: flex-end;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-body {
        padding: 20px;
        max-height: calc(95vh - 140px);
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 20px;
        gap: 12px;
        flex-direction: column-reverse;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    /* Calendário Mobile */
    .calendar {
        padding: 16px;
    }
    
    .calendar-day {
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    .calendar-day-header {
        font-size: 0.75rem;
        padding: 8px 4px;
    }
    
    /* Badges Mobile */
    .badge {
        padding: 4px 12px;
        font-size: 0.75rem;
    }
    
    /* Espaçamento Mobile */
    .mb-md {
        margin-bottom: 20px;
    }
    
    .mb-lg {
        margin-bottom: 32px;
    }
    
    .mt-md {
        margin-top: 20px;
    }
    
    .mt-lg {
        margin-top: 32px;
    }
    
    /* Flex Mobile */
    .flex-between {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .flex-between > * {
        width: 100%;
    }
    
    /* Empty State Mobile */
    .empty-state {
        padding: 48px 24px;
    }
    
    .empty-state-icon {
        font-size: 3rem;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        padding-bottom: 24px;
    }
    
    .bottom-nav {
        display: none;
    }
    
    .mobile-nav {
        width: 60%;
    }
}

/* Small Mobile (< 380px) */
@media (max-width: 380px) {
    .container {
        padding: 12px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .btn {
        font-size: 0.9375rem;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .modal {
        max-height: 100vh;
    }
}

/* iOS Safe Area */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
    
    .container {
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }
}

/* Pull to Refresh Styling */
body {
    overscroll-behavior-y: contain;
}

/* Smooth Scrolling Mobile */
html {
    -webkit-overflow-scrolling: touch;
}

/* Prevent Double Tap Zoom */
button,
a {
    touch-action: manipulation;
}

/* Better Focus States Mobile */
@media (max-width: 768px) {
    *:focus {
        outline: 3px solid var(--primary);
        outline-offset: 2px;
    }
    
    button:focus,
    a:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid var(--primary);
        outline-offset: 2px;
    }
}
