/* Marco/Saulo - 07/04/2026 */
/* SENA - Responsividade Mobile-First */

/* ========================================
   Base (320px+) - Mobile First
   ======================================== */
.desktop-table {
    display: none;
}

.mobile-cards {
    display: block;
}

/* Marco/Saulo - 07/04/2026 - Correcoes responsividade mobile */

/* Forcar layouts seguros em telas estreitas */
@media (max-width: 479px) {
    .stat-cards,
    .stat-cards[style] {
        grid-template-columns: 1fr !important;
    }

    /* Navbar: reduzir gaps e padding para caber */
    .navbar {
        padding: 0 10px;
    }

    .navbar-brand {
        gap: 8px;
    }

    .navbar-actions {
        gap: 4px;
    }

    .navbar-actions .btn-icon {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    /* Page content: garantir que nao extrapole */
    .page-content {
        padding: 16px 12px;
    }

    /* Page header menor */
    .page-header h1 {
        font-size: 1.25rem;
    }

    /* Cards: ajustar padding */
    .card {
        padding: 16px 12px;
    }

    .stat-card {
        padding: 16px 12px;
    }

    .stat-card .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .stat-card .stat-info h3 {
        font-size: 1.3rem;
    }

    .stat-card .stat-info p {
        font-size: 0.8rem;
    }

    /* Modal: padding reduzido */
    .modal-overlay {
        padding: 8px;
    }

    .modal-body {
        padding: 16px 12px;
    }

    .modal-header {
        padding: 12px 14px;
    }

    .modal-footer {
        padding: 12px 14px;
    }

    /* Modal alto (busca/lista): ocupa toda a altura disponível */
    .modal-tall {
        height: calc(100vh - 16px);
        max-height: none !important;
        display: flex;
        flex-direction: column;
    }

    .modal-tall .modal-body {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding-bottom: 0;
    }

    .modal-tall .modal-body .table-container,
    .modal-tall .modal-body .mobile-cards {
        flex: 1;
        min-height: 0;
        max-height: none !important;
        overflow-y: auto;
    }

    /* Footer fixo: texto menor */
    .app-footer {
        font-size: 0.7rem;
        padding: 0 10px;
    }
}

/* page-header: empilhar titulo + botoes */
.page-header {
    display: block;
}

.page-header .page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.page-header .page-actions .btn {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    padding: 8px 12px;
}

/* Search bar: stack vertical em mobile */
.search-bar {
    flex-direction: column;
}

.search-bar select.form-control {
    width: 100% !important;
    min-width: 0 !important;
}

/* Modal footer: stack vertical com botoes full-width */
.modal-footer .btn {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
}

/* Items-table: overflow scroll controlado */
.items-table {
    min-width: 500px;
}

/* os-item: wrap em mobile */
.os-item .os-number {
    min-width: auto;
}

.os-item .os-client {
    min-width: 0;
    word-break: break-word;
}

/* financial-summary responsivo */
.financial-summary {
    padding: 16px;
}

.financial-summary .summary-item .summary-value {
    font-size: 1rem;
}

/* Navbar brand truncate */
.navbar-brand .logo-sub {
    display: none;
}

/* chart-bar ajuste mobile */
.chart-bar-group {
    overflow-x: auto;
    padding-bottom: 8px;
}

.chart-bar {
    min-width: 24px !important;
}

/* ========================================
   480px+ - Smartphones maiores
   ======================================== */
@media (min-width: 480px) {
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-access {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

    .financial-summary .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .financial-summary .summary-item .summary-value {
        font-size: 1.2rem;
    }

    .search-bar {
        flex-direction: row;
    }

    .search-bar select.form-control {
        width: auto !important;
        min-width: 140px !important;
    }

    .navbar-brand .logo-sub {
        display: block;
    }

    .modal-footer .btn {
        flex: 0 1 auto;
    }
}

/* ========================================
   768px+ - Tablets
   ======================================== */
@media (min-width: 768px) {
    .page-content {
        padding: 24px;
    }

    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-access {
        grid-template-columns: repeat(4, 1fr);
    }

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

    .form-row.cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .form-row.cols-5 {
        grid-template-columns: repeat(3, 1fr);
    }

    .detail-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .financial-summary .summary-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .modal {
        max-width: 700px;
    }

    .page-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .page-header .page-actions {
        margin-top: 0;
    }

    .page-header .page-actions .btn {
        flex: 0 1 auto;
        font-size: 0.9rem;
        padding: 10px 20px;
    }

    .chart-container {
        height: 300px;
    }

}

/* ========================================
   1024px+ - Desktop
   ======================================== */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
        box-shadow: none;
        border-right: 1px solid var(--color-border);
    }

    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: var(--sidebar-width);
    }

    .navbar {
        left: 0;
    }

    .navbar-brand {
        width: var(--sidebar-width);
        justify-content: center;
        flex-shrink: 0;
    }

    .app-footer {
        left: var(--sidebar-width);
    }

    .btn-menu-toggle {
        display: none;
    }

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

    .desktop-table {
        display: block;
    }

    .mobile-cards {
        display: none;
    }

    .page-content {
        padding: 28px 32px;
    }

    .form-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .form-row.cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }

    .form-row.cols-5 {
        grid-template-columns: repeat(5, 1fr);
    }

    .detail-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Sidebar collapsed state */
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0;
    }

    body.sidebar-collapsed .navbar-brand {
        width: auto;
    }

    body.sidebar-collapsed .app-footer {
        left: 0;
    }
}

/* ========================================
   1440px+ - Wide Desktop
   ======================================== */
@media (min-width: 1440px) {
    .page-content {
        padding: 32px 40px;
        max-width: 1600px;
    }

    .stat-cards {
        grid-template-columns: repeat(5, 1fr);
    }

    .form-row.cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }

    .detail-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .chart-container {
        height: 350px;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .sidebar,
    .navbar,
    .btn-menu-toggle,
    .sidebar-overlay,
    .app-footer,
    .btn,
    .search-bar,
    .pagination {
        display: none !important;
    }

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

    .card {
        box-shadow: none;
        border: 1px solid #DDD;
    }

    body {
        background: #FFF;
    }
}
