/* ============================================
   ESTILOS GLOBALES - SISTEMA DE FACTURACIÓN
   ============================================ */

:root {
    --mint: #39bda7;
    --mint-hover: #2da896;
    --mint-light: #e8f8f5;
    --mint-dark: #2c9580;
    --text: #16303b;
    --text-muted: #8aa4ad;
    --border: #e7eff2;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f7fbfc 0%, #e8f8f5 100%);
    color: var(--text);
    min-height: 100vh;
}

/* ===== NAVBAR MINT ===== */
.navbar-mint {
    background: linear-gradient(135deg, var(--mint) 0%, #5ed0be 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.navbar-mint .navbar-brand,
.navbar-mint .nav-link,
.navbar-mint .navbar-text {
    color: #fff !important;
}

.navbar-mint .navbar-brand {
    font-weight: 700;
    letter-spacing: .5px;
}

.navbar-mint .nav-link:hover {
    color: #f5fffd !important;
    text-decoration: underline;
    text-underline-offset: .25rem;
}

.navbar-mint .btn-outline-light {
    border: 1px solid #fff;
    color: #fff;
    border-radius: 20px;
    padding: .5rem 1.25rem;
    font-weight: 500;
}

.navbar-mint .btn-outline-light:hover {
    background: rgba(255,255,255,.2);
    border-color: #fff;
}

.badge-ghost {
    background: rgba(255,255,255,.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 20px;
    padding: .5rem 1rem;
    font-size: .875rem;
    font-weight: 500;
}

/* ===== CARDS ===== */
.card {
    border: 0;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(57, 189, 167, .08);
    transition: all .3s;
    margin-bottom: 1.5rem;
}

.card:hover {
    box-shadow: 0 12px 32px rgba(57, 189, 167, .15);
}

.card-header {
    background: linear-gradient(135deg, var(--mint) 0%, #5ed0be 100%);
    color: #fff;
    border: 0;
    padding: 0.4rem 0.75rem;
    border-radius: 16px 16px 0 0 !important;
    font-weight: 600;
}

.section-title {
    background: linear-gradient(135deg, var(--mint) 0%, #5ed0be 100%);
    color: #fff;
    font-weight: 600;
    border-radius: 16px 16px 0 0 !important;
}

.section-title h5 {
    margin: 0;
    color: #fff;
}

/* ===== FORMS ===== */
.form-control, .form-select {
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: .75rem 1rem;
    transition: all .3s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--mint);
    box-shadow: 0 0 0 .25rem rgba(57, 189, 167, .15);
    outline: 0;
}

.form-label {
    font-weight: 500;
    color: var(--text);
    margin-bottom: .5rem;
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--mint) !important;
    border: 0;
    border-radius: 10px;
    padding: .75rem 1.5rem;
    font-weight: 600;
    transition: all .3s;
}

.btn-primary:hover {
    background: var(--mint-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(57, 189, 167, .3);
}

.btn-success {
    background: var(--mint) !important;
    border: 0;
}

.btn-success:hover {
    background: var(--mint-hover) !important;
}

.btn-secondary {
    border-radius: 10px;
    padding: .75rem 1.5rem;
    font-weight: 600;
}

.btn-danger {
    border-radius: 8px;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* ===== ITEMS DE FACTURA ===== */
.item-row {
    position: relative;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all .3s;
}

.item-row:hover {
    border-color: var(--mint);
    box-shadow: 0 4px 12px rgba(57, 189, 167, .1);
}

.remove-item {
    font-size: 1rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity .2s;
}

.remove-item:hover {
    opacity: 1;
}

/* ===== RESUMEN DE TOTALES ===== */
#resumen-totales {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 12px;
}

#resumen-totales .card {
    border-radius: 12px;
    border: 0;
}

#resumen-totales .bg-light {
    background: var(--mint-light) !important;
    border: 1px solid rgba(57, 189, 167, .1);
}

#resumen-totales .bg-primary {
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%) !important;
}

/* ===== PAGE HEADER (barra superior de formularios) ===== */
.page-header {
    background: linear-gradient(135deg, #2e7d62 0%, #39bda7 100%);
    color: #fff;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.page-header h4 {
    margin: 0;
    font-weight: 600;
    font-size: 1.3rem;
}
.page-header small {
    opacity: .85;
    font-size: .85rem;
}
.page-header .ph-icon {
    font-size: 2rem;
    opacity: .9;
}

/* ===== LOADER ===== */
.loader-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, .95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loader-overlay .spinner-border {
    color: var(--mint);
    width: 4rem;
    height: 4rem;
}

/* ===== ALERTS ===== */
.alert {
    border: 0;
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #dc2626;
}

.alert-success {
    background: var(--mint-light);
    color: var(--mint-dark);
    border-left: 4px solid var(--mint);
}

/* ===== VALIDACIÓN ===== */
.invalid-feedback {
    font-size: .875rem;
    color: #dc3545;
}

.was-validated .form-control:invalid {
    border-color: #dc3545;
}

.was-validated .form-control:valid {
    border-color: var(--mint);
}

/* ===== TÍTULOS Y TEXTOS ===== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-weight: 600;
}

.text-center {
    text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .card-body {
        padding: 1.25rem;
    }
    
    .item-row {
        padding: 1rem;
    }
    
    .navbar-mint .navbar-brand {
        font-size: 1rem;
    }
    
    .badge-ghost {
        font-size: .75rem;
        padding: .4rem .8rem;
    }
}

/* ===== UTILITIES ===== */
.text-mint {
    color: var(--mint);
}

.bg-mint {
    background-color: var(--mint);
}

.border-mint {
    border-color: var(--mint);
}

.text-danger {
    color: #dc2626 !important;
}

.fw-bold {
    font-weight: 600 !important;
}

/* ===== COMPATIBILIDAD CON BOOTSTRAP ICONS ===== */
.bi {
    vertical-align: -.125em;
}

/* ===== FIX PARA SELECT DE TRIBUTOS ===== */
.codigo-tributo {
    max-width: 100%;
}

/* ===== MEJORAS VISUALES ADICIONALES ===== */
.container {
    max-width: 1200px;
}

.row {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.col, .col-md-2, .col-md-3, .col-md-5, .col-md-6, .col-md-12 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* ===== ANIMACIONES SUAVES ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease-in-out;
}

/* ===== MEJORA DE ACCESIBILIDAD ===== */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--mint);
    outline-offset: 2px;
}

/* ===== SCROLL SUAVE ===== */
html {
    scroll-behavior: smooth;
}
/* ===== FORMULARIOS COMPACTOS ===== */
.form-control-sm,
.form-select-sm {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    min-height: unset;
}

textarea.form-control-sm {
    padding: 0.25rem 0.5rem;
}

.form-label.small {
    font-size: 0.75rem;
    margin-bottom: 0.15rem !important;
}

.card-header.section-title h5 {
    font-size: 0.95rem;
    margin-bottom: 0;
}

.card-body.p-2 {
    padding: 1rem 1.25rem !important;
}

.card-body.pb-2 {
    padding: 1rem 1.25rem 0.75rem !important;
}

.card-body {
    padding: 1rem 1.25rem !important;
}

.invalid-feedback {
    font-size: 0.7rem;
}

.table-sm thead th {
    font-size: 0.75rem;
    padding: 0.25rem 0.4rem;
    font-weight: 600;
}

.table-sm tbody td {
    padding: 0.2rem 0.3rem;
    vertical-align: middle;
}

.table-sm tbody td .form-control-sm,
.table-sm tbody td .form-select-sm {
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
    font-size: 0.78rem;
    height: auto;
    line-height: 1.3;
}

/* ============================================================
   RESPONSIVE GLOBAL — tabletas, iPad, móvil
   Breakpoints:
     ≥1200px  desktop                (sin cambios)
     992-1199 laptop pequeña          (sin cambios)
     768-991  iPad landscape          (.responsive-tablet)
     576-767  iPad portrait / móvil L (.responsive-mobile-lg)
     <576px   móvil                   (.responsive-mobile)
   ============================================================ */

/* TODOS los tamaños — evitar overflow horizontal de la página */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* TODA tabla recibe contenedor scroll horizontal en pantallas chicas
   sin tener que modificar cada plantilla. */
@media (max-width: 991.98px) {
    table.table {
        font-size: .82rem;
    }
    table.table th, table.table td {
        white-space: nowrap;
    }
    /* Si la tabla no tiene wrapper .table-responsive, simulamos uno con scroll */
    .card-body > table.table,
    .container > table.table,
    .container-fluid > table.table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* TABLET LANDSCAPE / iPad (≤991px) */
@media (max-width: 991.98px) {
    .container, .container-fluid {
        padding-left: .75rem;
        padding-right: .75rem;
    }
    .card-body { padding: 0.9rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.05rem; }
    h5 { font-size: .95rem; }

    /* Formularios DTE: reducir paddings y permitir que el row haga wrap */
    .form-card, .config-card {
        padding: 1rem !important;
        max-width: 100% !important;
        margin: 1rem auto !important;
    }

    /* Sidebar más estrecho */
    .sidebar { width: 220px !important; }
    .main-area { padding: 1rem .75rem !important; }
}

/* MÓVIL / TABLET PORTRAIT (≤767px) */
@media (max-width: 767.98px) {
    body { font-size: .95rem; }
    .container, .container-fluid { padding-left: .5rem; padding-right: .5rem; }
    .card { border-radius: 10px; }
    .card-body { padding: 0.75rem; }

    /* Navbar: botones más pequeños, dropdown país compacto */
    .navbar-mint .navbar-brand { font-size: .95rem; }
    .navbar-mint .btn-sm { padding: .2rem .45rem; font-size: .78rem; }

    /* Formularios — apilar columnas */
    .row > [class*="col-"] { margin-bottom: .5rem; }
    .form-label.small { font-size: .78rem; margin-bottom: .15rem; }
    .form-control-sm, .form-select-sm { font-size: .85rem; }

    /* Botones grandes apilados */
    .btn-lg { padding: .6rem 1rem; font-size: .95rem; }
    .d-flex.justify-content-end.gap-2 { flex-wrap: wrap; }
    .d-flex.justify-content-end.gap-2 .btn { flex: 1 1 auto; }

    /* Encabezados de columna de tablas: ocultar columnas auxiliares en móvil */
    table.table th, table.table td { padding: .35rem .4rem; font-size: .78rem; }

    /* Cards de KPI en una columna */
    .kpi-card, .kpi { margin-bottom: .5rem; }

    /* Hacer iframe contenedor que se adapte */
    iframe { width: 100% !important; min-height: 70vh; }

    /* Modal mobile-friendly */
    .modal-dialog { margin: .5rem; max-width: calc(100% - 1rem); }

    /* Sidebar: en móvil convertir a drawer (over-content) */
    .sidebar {
        position: fixed !important;
        top: 56px;
        left: 0;
        bottom: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .25s ease;
        width: 75vw !important;
        max-width: 280px;
        box-shadow: 4px 0 12px rgba(0,0,0,.15);
    }
    .sidebar.sidebar-open { transform: translateX(0); }
    .page-wrapper .main-area { margin-left: 0 !important; width: 100% !important; }

    /* Botón hamburguesa visible en móvil */
    .mobile-menu-btn { display: inline-flex !important; }

    /* Galería de imágenes 2 columnas en móvil */
    .col-6.col-md-3 { flex: 0 0 50%; max-width: 50%; }
}

/* MÓVIL PEQUEÑO (≤575px) */
@media (max-width: 575.98px) {
    h2 { font-size: 1.05rem; }
    .card-header.section-title h5 { font-size: .9rem; }

    /* Resúmenes de totales — apilar */
    .row.g-2 > .col-md-3,
    .row.g-2 > .col-md-6 { flex: 0 0 100%; max-width: 100%; }

    /* Selector país en navbar: ocultar texto, solo bandera */
    .navbar-mint .dropdown .d-none.d-md-inline { display: none !important; }
}

/* Botón hamburguesa solo en pantallas chicas */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 1.4rem;
    padding: .25rem .5rem;
}

/* Backdrop cuando el sidebar móvil está abierto */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1030;
}
.sidebar-backdrop.show { display: block; }

