/* ========================================
   MOBILE.CSS — Mobile-First Overrides
   Carregado APÓS responsive.css para
   sobrescrever regras desktop-first
   ======================================== */

/* ========================================
   BASE STYLES (< 640px — Mobile)
   ======================================== */

/* --- Grid e Cards: tudo em coluna única --- */
.project-grid,
.demands-list,
.team-grid,
.home-shortcuts,
.home-demands-grid,
.member-metrics-grid,
.overall-stats-grid,
.kpi-cards,
.charts-grid,
.insights-grid,
.crm-metrics {
    grid-template-columns: 1fr !important;
    gap: 12px;
}

.project-card {
    min-height: auto !important;
    height: auto !important;
}

/* --- Formulários vertical --- */
.filter-row,
.demands-filters,
.crm-filters,
.crm-form-grid {
    flex-direction: column;
    gap: 12px;
}

.crm-form-grid {
    grid-template-columns: 1fr !important;
}

/* --- Tabs scrolláveis --- */
.demands-tabs,
.nav-menu {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.demands-tabs::-webkit-scrollbar,
.nav-menu::-webkit-scrollbar {
    display: none;
}

/* --- Botões full-width --- */
.auth-btn,
.filter-btn {
    width: 100%;
    min-height: 48px;
}

/* --- Alvos de toque mínimos (44×44px) --- */
.crm-action-btn,
.demand-action-btn,
.project-card-action,
.modal-close,
.btn {
    min-width: 44px;
    min-height: 44px;
}

/* --- Inputs: font-size 16px para evitar zoom iOS --- */
input,
select,
textarea {
    font-size: 16px !important;
}

/* --- Kanban horizontal scrollável --- */
.crm-kanban {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.crm-kanban::-webkit-scrollbar {
    display: none;
}

.crm-kanban-column {
    min-width: 280px;
    scroll-snap-align: start;
}

/* --- Auth card mobile-first --- */
.auth-card-wizard {
    max-width: 100%;
    margin: 0 auto;
    border-radius: 0;
}

.wizard-steps {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.wizard-step {
    font-size: 0.75rem;
}

/* --- Billing: tabelas scrolláveis --- */
.billing-table-wrapper,
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Billing cards coluna única --- */
.billing-cards-grid,
.plan-cards-grid,
.billing-stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
}

/* --- Media Plan: coluna única --- */
.media-plan-grid,
.media-plan-cards,
.pmi-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
}

.media-plan-form-grid {
    grid-template-columns: 1fr !important;
}

/* --- Chat: full-width --- */
.chat-container {
    width: 100% !important;
    max-width: 100% !important;
}

.chat-input-container {
    position: sticky;
    bottom: 0;
}

/* --- SEO Analyzer: resultados coluna única --- */
.seo-results-grid,
.seo-metrics-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
}

/* --- Social Analyzer: métricas empilhadas --- */
.social-metrics-grid,
.social-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
}

/* --- Tech Detector: coluna única --- */
.tech-results-grid,
.tech-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
}

/* --- Extensions: coluna única --- */
.extensions-grid,
.extensions-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
}

/* --- Modais full-screen no mobile --- */
.modal-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
}

.modal-close {
    min-width: 44px;
    min-height: 44px;
}

/* --- Dashboard --- */
.dashboard-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
}

.dashboard-controls {
    justify-content: center;
    flex-wrap: wrap;
}

.status-bar {
    flex-direction: column;
    gap: 10px;
}

.chart-wrapper {
    height: clamp(200px, 40vw, 400px);
}

/* --- Demands --- */
.demands-tabs {
    scroll-snap-type: x mandatory;
}

.demands-tabs > * {
    scroll-snap-align: start;
}

.demand-card-actions {
    flex-wrap: wrap;
    gap: 8px;
}

.demand-card-actions .btn,
.demand-card-actions button {
    min-height: 44px;
    min-width: 44px;
}

/* --- Hover: desabilitar em touch devices --- */
@media (hover: none) {
    .project-card:hover {
        transform: none;
        box-shadow: var(--shadow);
    }

    .btn:hover {
        transform: none;
    }

    .btn:hover::before {
        width: 0;
        height: 0;
    }

    .category-tag:hover {
        background: var(--gray-100);
        color: var(--gray-700);
    }

    .project-card-actions {
        opacity: 1;
    }

    /* Active state para feedback tátil */
    .btn:active,
    .project-card:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    .sidebar-nav-link:active,
    .sidebar-dropdown-item:active {
        transform: scale(0.97);
    }
}

/* ========================================
   TABLET (≥ 640px)
   ======================================== */
@media (min-width: 640px) {
    .kpi-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .home-shortcuts {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .crm-metrics {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .crm-form-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .auth-card-wizard {
        max-width: 520px;
        border-radius: 16px;
    }

    .billing-cards-grid,
    .plan-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Modais: não full-screen a partir de tablet */
    .modal-content {
        width: 90% !important;
        max-width: 600px !important;
        height: auto;
        max-height: 90vh;
        margin: 5vh auto;
        border-radius: 16px;
    }

    .wizard-steps {
        display: flex;
        gap: 0;
    }
}

/* ========================================
   DESKTOP SMALL (≥ 768px)
   ======================================== */
@media (min-width: 768px) {
    .project-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .demands-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Filtros do Organizador de Demandas: horizontal no desktop */
    .demands-filters {
        flex-direction: row !important;
        align-items: center;
        gap: 0.75rem;
    }

    .demands-filters .filter-group {
        flex-direction: row !important;
        width: auto;
        flex-shrink: 0;
    }

    .demands-filters .filter-select {
        min-width: 160px;
        width: auto;
    }

    .demands-filters .search-box {
        flex: 1;
        min-width: 180px;
    }

    .charts-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .kpi-cards {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .social-metrics-grid,
    .social-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .seo-results-grid,
    .seo-metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .modal-content {
        max-width: 700px !important;
    }
}

/* ========================================
   DESKTOP (≥ 1024px)
   ======================================== */
@media (min-width: 1024px) {
    .project-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .kpi-cards {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .charts-grid {
        grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)) !important;
    }

    .extensions-grid,
    .extensions-cards-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .tech-results-grid,
    .tech-cards-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Reset font-size for desktop */
    input,
    select,
    textarea {
        font-size: inherit !important;
    }

    .modal-content {
        max-width: 800px !important;
    }
}

/* ========================================
   LARGE DESKTOP (≥ 1440px)
   ======================================== */
@media (min-width: 1440px) {
    .project-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ========================================
   SAFE AREA (notch devices)
   ======================================== */
@supports (padding: env(safe-area-inset-bottom)) {
    #topbar {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    #sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }

    #main-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
