/**
 * NegocioGo — Sistema mobile global (≤768px)
 * Layouts nativos: no comprimir desktop.
 */

@media (max-width: 768px) {
    :root {
        --mobile-header-height: 56px;
        --mobile-bottom-nav-height: 56px;
        --mobile-page-padding: 16px;
        --mobile-card-radius: 18px;
        --mobile-clearance: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    }

    html {
        max-width: 100%;
    }

    body {
        max-width: 100%;
        overflow-x: clip;
    }

    /* —— Tipografía mobile —— */
    h1,
    .stats-header__intro h1,
    .qr-header h1,
    .qr-detail-header h1,
    .invoice-detail-header h1 {
        font-size: clamp(1.5rem, 7vw, 1.75rem) !important;
        line-height: 1.1 !important;
        letter-spacing: -0.02em;
    }

    h2 {
        font-size: 1.25rem;
        line-height: 1.15;
    }

    h3 {
        font-size: 1.0625rem;
        line-height: 1.25;
    }

    body,
    .creator-main,
    .qr-page,
    .stats-page {
        font-size: 0.9375rem;
        line-height: 1.45;
    }

    /* —— Shell vendedor / páginas app —— */
    body.creator-app .creator-main,
    body.seller-app .creator-main {
        padding-left: var(--mobile-page-padding);
        padding-right: var(--mobile-page-padding);
        padding-bottom: var(--mobile-clearance);
        max-width: 100%;
        box-sizing: border-box;
    }

    body.creator-app.ng-has-bottom-nav .creator-main,
    body.seller-app.ng-has-bottom-nav .creator-main {
        padding-bottom: var(--mobile-clearance);
    }

    /* —— Cards universales —— */
    .card,
    .dashboard-card,
    .qr-detail-card,
    .qr-card,
    .order-actions-card,
    .invoice-summary-card,
    .stats-kpi,
    .stats-panel,
    .stats-reco-card,
    .seller-product-card,
    .seller-service-card,
    .store-profile-section,
    .account-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        border-radius: var(--mobile-card-radius);
    }

    /* —— Formularios: una columna —— */
    .form-grid,
    .settings-grid,
    .two-column-grid,
    .three-column-grid,
    .store-profile-grid,
    .qr-detail-grid,
    .invoice-detail-grid,
    .studio-form-grid,
    [class*="grid-cols-2"],
    [class*="grid-cols-3"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea,
    .form-control {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        font-size: 16px;
        min-height: 48px;
    }

    /* —— Montos: no cortar de forma rara —— */
    .money,
    .invoice-money,
    .qr-total-big,
    .stats-kpi__value,
    .amount,
    .total-value {
        max-width: 100%;
        font-size: clamp(1.125rem, 5.5vw, 1.5rem);
        line-height: 1.15;
        word-break: break-word;
    }

    .qr-detail-header,
    .invoice-detail-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .qr-detail-header__total,
    .invoice-detail-header__total {
        text-align: left;
        width: 100%;
    }

    /* —— Acciones: stack full width —— */
    .mobile-actions,
    .order-actions-primary,
    .order-actions-secondary,
    .order-actions-header,
    .qr-actions,
    .stats-empty-actions {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 10px;
        width: 100%;
    }

    .order-actions-btn,
    .order-actions-header .order-actions-btn--primary,
    .qr-actions .btn,
    .stats-btn {
        width: 100%;
        min-height: 38px;
        justify-content: center;
        box-sizing: border-box;
    }

    .order-actions-header .order-actions-btn--primary {
        margin-top: 0.5rem;
    }

    /* —— Tablas → cards (seller detail) —— */
    .qr-detail-table-wrap--desktop,
    .invoice-table-wrap--desktop {
        display: none !important;
    }

    .mobile-line-cards {
        display: grid;
        gap: 12px;
        width: 100%;
    }

    .mobile-line-card {
        padding: 14px 16px;
        border: 1px solid #e4e4e7;
        border-radius: 14px;
        background: #fff;
        box-sizing: border-box;
    }

    .mobile-line-card__title {
        margin: 0 0 0.65rem;
        font-size: 0.9375rem;
        font-weight: 700;
        color: #18181b;
        line-height: 1.35;
        word-break: break-word;
    }

    .mobile-line-card__row {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 0.75rem;
        padding: 0.28rem 0;
        font-size: 0.8125rem;
    }

    .mobile-line-card__row dt {
        margin: 0;
        color: #71717a;
        font-weight: 600;
    }

    .mobile-line-card__row dd {
        margin: 0;
        color: #18181b;
        font-weight: 600;
        text-align: right;
    }

    .mobile-line-card__total {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px dashed #e4e4e7;
        font-weight: 700;
        color: #068C61;
    }

    /* —— Listas pedidos/facturas —— */
    .qr-card {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .qr-card-side {
        text-align: left;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.35rem;
    }

    .qr-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
    }

    .qr-filters a {
        flex-shrink: 0;
    }

    /* —— Gráficos —— */
    .chart-container,
    .stats-chart-wrap,
    .stats-chart-panel,
    [data-stats-chart] {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    .stats-chart-wrap svg,
    .stats-chart-panel svg,
    [data-stats-chart] svg,
    [data-stats-chart] canvas {
        max-width: 100%;
        height: auto;
    }

    [data-stats-chart] {
        min-height: 200px;
        max-height: 220px;
    }

    /* —— Tablas stats → cards —— */
    .stats-table-wrap {
        width: 100%;
        max-width: 100%;
        overflow: visible;
    }

    .stats-table {
        display: block;
        width: 100%;
        min-width: 0;
        font-size: 0.8125rem;
        border: none;
    }

    .stats-table thead {
        display: none;
    }

    .stats-table tbody {
        display: grid;
        gap: 12px;
    }

    .stats-table tbody tr {
        display: block;
        padding: 14px 16px;
        border: 1px solid #e4e4e7;
        border-radius: 14px;
        background: #fff;
        box-sizing: border-box;
    }

    .stats-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 0.75rem;
        padding: 0.28rem 0;
        border: none;
        text-align: right;
    }

    .stats-table tbody td::before {
        content: attr(data-label);
        flex: 1;
        text-align: left;
        color: #71717a;
        font-weight: 600;
        font-size: 0.75rem;
    }

    .stats-table tbody td.stats-table__item,
    .stats-table tbody td.stats-table__name {
        display: block;
        padding: 0 0 0.5rem;
        margin-bottom: 0.35rem;
        border-bottom: 1px dashed #e4e4e7;
        font-weight: 700;
        color: #18181b;
        text-align: left;
    }

    .stats-table tbody td.stats-table__item::before,
    .stats-table tbody td.stats-table__name::before {
        display: none;
    }

    .stats-table__item {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .stats-chart--bars {
        max-height: 200px;
        overflow: hidden;
        margin-bottom: 1rem;
    }

    /* —— Header vendedor compacto —— */
    .creator-topbar {
        backdrop-filter: none !important;
        box-shadow: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .creator-topbar-inner {
        height: var(--mobile-header-height);
        min-height: var(--mobile-header-height);
        max-height: var(--mobile-header-height);
        padding: 0 var(--mobile-page-padding);
    }

    .creator-logo {
        font-size: 1rem;
    }

    .creator-store-select {
        max-width: 7.5rem;
        font-size: 0.6875rem;
    }

    /* —— Cuenta / seguridad compacta —— */
    .account-card,
    .account-security-card {
        padding: 1rem;
    }

    .account-card__actions,
    .account-security-actions {
        margin-top: 0.75rem;
        display: grid;
        gap: 0.5rem;
    }

    /* —— Ocultar asistente en pantallas críticas —— */
    body:has([data-order-detail]) .vendly-assistant-root,
    body:has([data-invoice-detail]) .vendly-assistant-root,
    body:has(.map-page) .vendly-assistant-root,
    body:has(.store-profile-form) .vendly-assistant-root,
    body:has([data-store-edit]) .vendly-assistant-root {
        display: none !important;
    }

    /* —— Map bottom sheet botones visibles —— */
    .ng-map-store-sheet .map-store-card__actions,
    .ng-map-store-sheet .map-popup__actions {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        width: 100%;
        padding-bottom: 0.5rem;
    }

    .ng-map-store-sheet .map-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .ng-map-store-sheet .map-btn--primary,
    .ng-map-store-sheet .map-btn--whatsapp {
        background: #068C61 !important;
        color: #fff !important;
        border-color: #068C61 !important;
    }

    .ng-map-store-sheet .map-btn--ghost {
        background: #fff;
        border: 1px solid #e2e8f0;
        color: #0f172a;
    }

    .ng-bottom-sheet__body {
        max-height: 72vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* —— Efectos pesados off —— */
    .glass-effect,
    .blur-effect,
    .animated-gradient,
    .blend-effect {
        backdrop-filter: none !important;
        filter: none !important;
        mix-blend-mode: normal !important;
    }
}

@media (min-width: 769px) {
    .mobile-line-cards {
        display: none !important;
    }

    .qr-detail-table-wrap--desktop,
    .invoice-table-wrap--desktop {
        display: block;
    }
}

@media (max-width: 430px) {
    .stats-kpi-grid {
        grid-template-columns: 1fr !important;
    }

    .stats-kpi__value {
        font-size: clamp(1.25rem, 6vw, 1.5rem);
    }
}

@media (min-width: 431px) and (max-width: 768px) {
    .stats-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
