/* ========================================
   MOBILE RESPONSIVE GLOBAL
   Barber CashFlow - Correções de Responsividade
   Data: 2025-11-19
   ======================================== */

/* =============================================
   1. NAVBAR E HEADER FIXES
   ============================================= */
@media (max-width: 480px) {
    /* Navbar brand: evitar overflow em telas muito pequenas */
    .top-navbar .navbar-brand {
        font-size: 0.85rem !important;
        max-width: 65vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        letter-spacing: 0;
    }

    /* User info no header */
    .top-navbar .text-white {
        font-size: 0.8rem;
        max-width: 25vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 768px) {
    .top-navbar .navbar-brand {
        font-size: 0.95rem !important;
        max-width: 70vw;
    }
}

/* =============================================
   2. HEADINGS RESPONSIVOS
   ============================================= */
@media (max-width: 768px) {
    /* H1 - Títulos principais */
    h1 {
        font-size: 1.75rem !important;
        margin-bottom: 1rem !important;
        line-height: 1.3;
    }

    /* H2 - Subtítulos */
    h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.875rem !important;
    }

    /* H3 */
    h3 {
        font-size: 1.35rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* H4 */
    h4 {
        font-size: 1.2rem !important;
        margin-bottom: 0.625rem !important;
    }

    /* H5 e H6 */
    h5 {
        font-size: 1.1rem !important;
    }

    h6 {
        font-size: 0.95rem !important;
    }
}

@media (max-width: 480px) {
    /* Telas muito pequenas: reduzir ainda mais */
    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.35rem !important;
    }
}

/* =============================================
   3. TABELAS RESPONSIVAS (PADRÃO GLOBAL)
   ============================================= */
@media (max-width: 768px) {
    /* Esconder thead da tabela */
    .table-responsive .table thead {
        display: none;
    }

    /* Transformar tabela em layout de cards */
    .table-responsive .table,
    .table-responsive .table tbody,
    .table-responsive .table tr,
    .table-responsive .table td {
        display: block;
        width: 100%;
    }

    /* Estilizar cada linha como um card */
    .table-responsive .table tr {
        margin-bottom: 1rem;
        border: 2px solid #dee2e6;
        border-radius: 8px;
        padding: 1rem;
        background: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        position: relative;
    }

    .table-responsive .table tr:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        transform: translateY(-2px);
        transition: all 0.2s ease;
    }

    /* Estilizar células da tabela */
    .table-responsive .table td {
        text-align: left !important;
        padding: 0.75rem 0;
        padding-left: 50%;
        border: none;
        position: relative;
        min-height: 44px; /* Touch target mínimo */
        display: flex;
        align-items: center;
        border-bottom: 1px solid #f0f0f0;
    }

    .table-responsive .table td:last-child {
        border-bottom: none;
    }

    /* Labels antes de cada célula (via data-label) */
    .table-responsive .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 48%;
        padding-right: 10px;
        font-weight: 700;
        color: #495057;
        word-wrap: break-word;
        text-align: left;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    /* Ajustar badges e botões dentro das células */
    .table-responsive .table td .badge {
        font-size: 0.85rem;
        padding: 0.35rem 0.65rem;
    }

    /* Botões de ação: transformar em coluna */
    .table-responsive .btn-group {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        width: 100%;
    }

    .table-responsive .btn-group .btn {
        width: 100% !important;
        margin: 0 !important;
    }

    /* Ajuste para coluna de ações (geralmente última) */
    .table-responsive .table td:has(.btn-group) {
        padding-left: 0;
        padding-top: 1rem;
        margin-top: 0.5rem;
        border-top: 2px solid #dee2e6;
    }

    .table-responsive .table td:has(.btn-group)::before {
        position: static;
        width: 100%;
        display: block;
        margin-bottom: 0.5rem;
    }
}

/* =============================================
   4. BOTÕES RESPONSIVOS
   ============================================= */
@media (max-width: 768px) {
    /* Botões grandes: reduzir tamanho */
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }

    /* Botões em headers: full width em mobile */
    .d-flex.justify-content-between .btn,
    .d-flex.justify-content-end .btn {
        width: 100%;
        margin-top: 0.5rem;
    }

    /* Grupos de botões inline: empilhar */
    .btn-group.d-inline-flex {
        display: flex !important;
        flex-direction: column !important;
        width: 100%;
    }
}

@media (max-width: 576px) {
    /* Mobile muito pequeno: botões sempre full width */
    .btn:not(.btn-sm):not(.btn-xs) {
        width: 100%;
        display: block;
    }
}

/* =============================================
   5. CARDS E CONTAINERS
   ============================================= */
@media (max-width: 768px) {
    /* Reduzir padding dos cards */
    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
    }

    /* Cards em grids: ajustar margins */
    .row .card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 576px) {
    /* Mobile pequeno: padding ainda menor */
    .card-body {
        padding: 0.75rem !important;
    }

    .container,
    .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* =============================================
   6. FORMS E INPUTS
   ============================================= */
@media (max-width: 768px) {
    /* Inputs e selects: tamanho de fonte para evitar zoom no iOS */
    .form-control,
    .form-select,
    .form-control-lg,
    .input-group-text {
        font-size: 16px !important;
    }

    /* Input groups: empilhar quando necessário */
    .input-group > * {
        font-size: 16px !important;
    }

    /* Garantir espaçamento entre campos em grids */
    .row > [class*="col-"] {
        margin-bottom: 1rem;
    }

    /* Labels: garantir contraste */
    .form-label {
        font-weight: 600;
        font-size: 0.95rem;
    }
}

@media (max-width: 576px) {
    /* Selects e inputs: full width forçado */
    .form-select,
    .form-control {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* =============================================
   7. TOUCH TARGETS (WCAG Compliance)
   ============================================= */
@media (max-width: 768px) {
    /* Garantir touch targets de no mínimo 44x44px */
    .btn,
    .form-control,
    .form-select,
    a.badge,
    .nav-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 1rem;
    }

    .btn-sm,
    .btn-group-sm .btn {
        min-height: 44px;
        padding: 0.5rem 0.85rem;
    }

    /* FullCalendar buttons */
    .fc-button {
        min-height: 44px !important;
        padding: 0.5rem 0.75rem !important;
    }

    /* Links de navegação da sidebar */
    .sidebar .nav-link {
        min-height: 48px;
        padding: 0.75rem 1rem;
    }
}

/* =============================================
   8. OVERFLOW PREVENTION
   ============================================= */
@media (max-width: 768px) {
    /* Prevenir scroll horizontal no body */
    body {
        overflow-x: hidden !important;
    }

    /* Containers: garantir que não estourem */
    .container-fluid,
    .container,
    .row {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Tabelas com scroll: smooth scrolling */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }

    /* Textos longos: quebrar palavras se necessário */
    .card-body,
    .table td,
    p {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* =============================================
   9. GRIDS E LAYOUTS ESPECÍFICOS
   ============================================= */
@media (max-width: 768px) {
    /* Headers com título + botão: empilhar */
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem;
    }

    /* Manter alguns flex em linha quando apropriado */
    .d-flex.gap-2:not(.justify-content-between) {
        flex-wrap: wrap;
    }
}

@media (max-width: 576px) {
    /* Mobile muito pequeno: forçar coluna */
    .d-flex:not(.flex-column) {
        flex-wrap: wrap;
    }
}

/* =============================================
   10. ALERTS E MENSAGENS
   ============================================= */
@media (max-width: 768px) {
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .alert .btn-close {
        padding: 0.5rem;
    }
}

/* =============================================
   11. PAGINAÇÃO
   ============================================= */
@media (max-width: 576px) {
    .pagination {
        font-size: 0.85rem;
    }

    .pagination .page-link {
        padding: 0.4rem 0.6rem;
        min-width: 38px;
    }
}

/* =============================================
   12. BADGES E TAGS
   ============================================= */
@media (max-width: 768px) {
    .badge {
        font-size: 0.8rem !important;
        padding: 0.35rem 0.65rem !important;
    }

    .badge.fs-6 {
        font-size: 0.85rem !important;
    }
}

/* =============================================
   13. MODAIS E OVERLAYS
   ============================================= */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-header,
    .modal-footer {
        padding: 0.75rem 1rem;
    }
}

/* =============================================
   14. SIDEBAR MOBILE (específico do projeto)
   ============================================= */
@media (max-width: 768px) {
    /* Garantir toque suave no sidebar */
    .sidebar {
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }

    /* Overlay: cobrir toda a tela */
    .sidebar-overlay.show {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1010;
    }
}

/* =============================================
   15. PERFORMANCE E ANIMAÇÕES MOBILE
   ============================================= */
@media (max-width: 768px) {
    /* Reduzir animações em mobile para melhor performance */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    /* Otimizar rendering */
    .card,
    .btn,
    .table tr {
        will-change: transform;
        transform: translateZ(0);
    }
}

/* =============================================
   16. UTILITÁRIOS MOBILE
   ============================================= */
@media (max-width: 768px) {
    /* Espaçamentos reduzidos */
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }

    .mb-3 {
        margin-bottom: 1rem !important;
    }

    .mt-4 {
        margin-top: 1.5rem !important;
    }

    /* Textos: ajustar tamanhos */
    .text-muted,
    small {
        font-size: 0.85rem;
    }

    /* Display utilities mobile */
    .d-md-none {
        display: none !important;
    }

    .d-md-block {
        display: block !important;
    }
}

/* =============================================
   17. FIXES ESPECÍFICOS PARA TELAS MUITO PEQUENAS (320px)
   ============================================= */
@media (max-width: 360px) {
    /* iPhone SE e dispositivos similares */
    body {
        font-size: 14px;
    }

    .navbar-brand {
        font-size: 0.8rem !important;
    }

    h1 {
        font-size: 1.35rem !important;
    }

    h2 {
        font-size: 1.2rem !important;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .card-body {
        padding: 0.625rem !important;
    }
}

/* =============================================
   18. PRINT STYLES (Bonus)
   ============================================= */
@media print {
    /* Esconder elementos não necessários na impressão */
    .sidebar,
    .top-navbar,
    .btn,
    .alert,
    footer {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        margin-top: 0 !important;
    }

    .table {
        font-size: 0.85rem;
    }
}

/* =============================================
   19. ACESSIBILIDADE (Focus States)
   ============================================= */
@media (max-width: 768px) {
    /* Melhorar indicadores de foco para navegação por teclado */
    .btn:focus,
    .form-control:focus,
    .form-select:focus,
    .nav-link:focus {
        outline: 3px solid var(--gold-accent, #C9A66B) !important;
        outline-offset: 2px;
    }
}

/* =============================================
   FIM DO ARQUIVO
   ============================================= */
