/**
 * SITEBUILDER - Estilos Globales
 * 
 * Variables, reset CSS y estilos compartidos
 */

/* ============================================================
   VARIABLES
   ============================================================ */
:root {
    /* Colores */
    --primary: #007bff;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    
    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-light: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    
    /* Tipografía */
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-sm: 14px;
    --font-size-xs: 12px;
    
    /* Espaciado */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Sombras */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
    
    /* Transiciones */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* ============================================================
   RESET
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    line-height: 1.6;
    color: #333;
    background-color: white;
}

/* Ancla real de cada sección (ver includes/sitebuilder/page-renderer.php,
   id="sb-seccion-{sbps_id}"): varios Headers son sticky/fixed (ver
   header-option01/03/04/05), así que sin este margen un salto por enlace
   dejaría el destino tapado debajo del header en vez de a la vista. */
.sb-seccion-ancla {
    scroll-margin-top: 90px;
}

/* ============================================================
   SELECCIÓN Y ARRASTRE — sitio público
   Por defecto (fuera del modo edición: ver body.sb-edit-mode más abajo,
   la única excepción, emitida sólo por admin/pagina/pagina_preview.php
   cuando $editMode es true) el visitante no puede seleccionar texto ni
   arrastrar imágenes/videos como objeto del navegador. No usa
   touch-action ni bloquea eventos (click/contextmenu/keydown/copiar):
   sólo afecta selección/arrastre, enlaces/botones/inputs/sliders/
   controles de video siguen funcionando igual.
   ============================================================ */
body:not(.sb-edit-mode) {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Los campos de formulario públicos (ej. contacto) deben seguir
   permitiendo escribir/seleccionar/corregir texto con normalidad. */
body:not(.sb-edit-mode) input,
body:not(.sb-edit-mode) textarea,
body:not(.sb-edit-mode) [contenteditable="true"] {
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

body:not(.sb-edit-mode) img,
body:not(.sb-edit-mode) video {
    -webkit-user-drag: none;
    user-drag: none;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: all var(--transition-base);
}

a:hover {
    color: darken(var(--primary), 10%);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--spacing-md);
}

/* ============================================================
   UTILIDADES
   ============================================================ */

/* Display */
.d-flex {
    display: flex;
}

.d-inline-flex {
    display: inline-flex;
}

.d-block {
    display: block;
}

.d-inline {
    display: inline;
}

.d-inline-block {
    display: inline-block;
}

.d-grid {
    display: grid;
}

/* Flexbox */
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-center { justify-content: center; align-items: center; }
.flex-between { justify-content: space-between; }
.flex-around { justify-content: space-around; }
.flex-gap-md { gap: var(--spacing-md); }
.flex-gap-lg { gap: var(--spacing-lg); }

/* Spacing */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mt-5 { margin-top: var(--spacing-xl); }
.mt-6 { margin-top: var(--spacing-xxl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mb-5 { margin-bottom: var(--spacing-xl); }
.mb-6 { margin-bottom: var(--spacing-xxl); }

.p-2 { padding: var(--spacing-sm); }
.p-3 { padding: var(--spacing-md); }
.p-4 { padding: var(--spacing-lg); }
.p-5 { padding: var(--spacing-xl); }

/* Text */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: #999; }

.text-bold { font-weight: 700; }
.text-medium { font-weight: 500; }
.text-light { font-weight: 300; }

.text-uppercase { text-transform: uppercase; }
.text-lowercase { text-transform: lowercase; }
.text-capitalize { text-transform: capitalize; }

.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.text-lg { font-size: var(--font-size-lg); }

.line-height-tight { line-height: 1.2; }
.line-height-normal { line-height: 1.5; }
.line-height-loose { line-height: 1.8; }

/* Background */
.bg-primary { background-color: var(--primary); }
.bg-secondary { background-color: var(--secondary); }
.bg-light { background-color: var(--light); }
.bg-dark { background-color: var(--dark); }
.bg-gradient-primary { background: var(--gradient-primary); }

/* Border */
.border { border: 1px solid #ddd; }
.border-top { border-top: 1px solid #ddd; }
.border-bottom { border-bottom: 1px solid #ddd; }
.border-left { border-left: 1px solid #ddd; }
.border-right { border-right: 1px solid #ddd; }
.border-primary { border-color: var(--primary); }
.border-0 { border: 0 !important; }

.rounded { border-radius: var(--radius-md); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadow */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* Opacity */
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ============================================================
   COMPONENTES COMUNES
   ============================================================ */

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 30px;
    border: 1px solid transparent;
    border-radius: var(--radius-full, 9999px);
    font-family: var(--font-body, var(--font-primary));
    font-size: var(--text-sm, var(--font-size-base));
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform var(--duration-fast, var(--transition-fast)) var(--ease-out, ease),
                box-shadow var(--duration-fast, var(--transition-fast)) var(--ease-out, ease),
                background-color var(--duration-fast, var(--transition-fast)) var(--ease-out, ease),
                border-color var(--duration-fast, var(--transition-fast)) var(--ease-out, ease),
                color var(--duration-fast, var(--transition-fast)) var(--ease-out, ease);
    text-decoration: none;
    vertical-align: middle;
    user-select: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn-primary {
    background-color: var(--accent, var(--primary));
    color: var(--accent-contrast, #fff);
    box-shadow: var(--elevation-2, var(--shadow-sm));
}

.btn-primary:hover {
    background-color: var(--accent, var(--primary));
    filter: brightness(1.08);
    box-shadow: var(--elevation-3, var(--shadow-md));
}

.btn-secondary {
    background-color: var(--text-primary, var(--secondary));
    color: var(--bg-canvas, white);
}

.btn-secondary:hover {
    filter: brightness(1.15);
    box-shadow: var(--elevation-3, var(--shadow-md));
}

.btn-outline-primary {
    border: 1.5px solid var(--accent, var(--primary));
    color: var(--accent, var(--primary));
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--accent, var(--primary));
    color: var(--accent-contrast, #fff);
    box-shadow: var(--elevation-2, var(--shadow-sm));
}

.btn-outline-secondary {
    border: 1.5px solid var(--border-strong, var(--secondary));
    color: var(--text-primary, var(--secondary));
    background-color: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--text-primary, var(--secondary));
    border-color: var(--text-primary, var(--secondary));
    color: var(--bg-canvas, #fff);
}

.btn-light {
    background-color: var(--bg-canvas, #fff);
    color: var(--text-primary, #333);
}

.btn-light:hover {
    box-shadow: var(--elevation-3, var(--shadow-md));
}

.btn-outline-light {
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    color: #fff;
    background-color: transparent;
}

.btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: #fff;
}

.btn-lg {
    padding: 18px 38px;
    font-size: var(--text-base, var(--font-size-lg));
}

.btn-sm {
    padding: 10px 20px;
    font-size: var(--text-xs, var(--font-size-sm));
}

.btn-xs {
    padding: 6px 14px;
    font-size: var(--font-size-xs);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Tarjetas */
.card {
    background: var(--bg-surface-raised, white);
    border: 1px solid var(--border-subtle, #e0e0e0);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--elevation-1, var(--shadow-sm));
    transition: transform var(--duration-base, var(--transition-base)) var(--ease-out, ease),
                box-shadow var(--duration-base, var(--transition-base)) var(--ease-out, ease);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--elevation-3, var(--shadow-md));
}

.card-header {
    padding: var(--spacing-lg);
    background-color: var(--bg-surface, #f8f9fa);
    border-bottom: 1px solid var(--border-subtle, #e0e0e0);
}

.card-body {
    padding: var(--spacing-lg);
}

.card-footer {
    padding: var(--spacing-lg);
    background-color: var(--bg-surface, #f8f9fa);
    border-top: 1px solid var(--border-subtle, #e0e0e0);
}

/* Contenedores */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.container-lg {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--spacing-md);
    margin: 0 auto;
}

/* Grid */
.row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--spacing-md);
}

.col-1 { grid-column: span 1; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }

@media (max-width: 768px) {
    .col-md-1 { grid-column: span 1; }
    .col-md-2 { grid-column: span 2; }
    .col-md-3 { grid-column: span 3; }
    .col-md-4 { grid-column: span 4; }
    .col-md-6 { grid-column: span 6; }
    .col-md-12 { grid-column: span 12; }
}

@media (max-width: 576px) {
    .col-sm-1 { grid-column: span 1; }
    .col-sm-2 { grid-column: span 2; }
    .col-sm-3 { grid-column: span 3; }
    .col-sm-4 { grid-column: span 4; }
    .col-sm-6 { grid-column: span 6; }
    .col-sm-12 { grid-column: span 12; }
}

/* Imágenes */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-fluid {
    max-width: 100%;
    height: auto;
}

.img-thumbnail {
    padding: var(--spacing-sm);
    border: 1px solid #ddd;
    border-radius: var(--radius-md);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1200px) {
    html {
        font-size: 15px;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.25rem; }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
}

@media (max-width: 576px) {
    html {
        font-size: 13px;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.1rem; }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
}

/* ============================================================
   UTILIDADES AVANZADAS
   ============================================================ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.clearfix::after {
    content: '';
    display: table;
    clear: both;
}

/* Truncate text */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Posición */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

.no-wrap { white-space: nowrap; }
.break-word { word-break: break-word; }

/* ============================================================
   ANIMACIONES
   ============================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-fadeIn {
    animation: fadeIn var(--transition-base);
}

.animate-slideInUp {
    animation: slideInUp var(--transition-base);
}

.animate-slideInDown {
    animation: slideInDown var(--transition-base);
}

/* ============================================================
   SECCIÓN MAPA — mapa embebido por ubicación (lat/lng), en vez de un
   iframe de Google Maps pegado a mano. Estados vacío/error del contenedor
   [data-sb-map] (ver assets/js/sb-map-embed.js); el propio mapa Leaflet
   toma el ancho/alto en línea que ya trae ese contenedor.
   ============================================================ */
.sb-map-empty,
.sb-map-error {
    width: 100%;
    height: 100%;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    background: var(--light);
    color: var(--secondary);
    font-size: 14px;
}

/* Botón "expandir" superpuesto sobre el mapa chico embebido — mismo botón,
   mismo comportamiento (abre el mapa maximizado, ver más abajo), en las 4
   opciones de Mapa que tienen coordenadas (01/02/04/05). Cada layout ya
   posiciona su contenedor .maXX-map en position:relative/absolute, así que
   este botón ancla ahí sin tocar el CSS propio de cada opción. */
.sb-map-expand-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    transition: transform .15s, background .15s;
    padding: 0;
}
.sb-map-expand-btn:hover,
.sb-map-expand-btn:focus-visible {
    background: #fff;
    transform: scale(1.06);
}
.sb-map-expand-btn svg {
    width: 16px;
    height: 16px;
}

/* ============================================================
   MAPA MAXIMIZADO — overlay fullscreen dentro de la misma página (nunca
   una pestaña/sitio externo). Un único overlay reutilizado entre
   aperturas, creado perezosamente por assets/js/sb-map-embed.js
   (SBMapEmbed.abrirFullscreen()), disparado por cualquier elemento
   [data-sb-map-abrir] — el botón "expandir" de arriba y el CTA de la
   opción 02 ("Abrir en Maps"/"Cómo llegar").
   ============================================================ */
.sb-map-fs-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, .55);
}

.sb-map-fs-mapa {
    position: absolute;
    inset: 20px;
    z-index: 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--light);
}

.sb-map-fs-cerrar {
    position: absolute;
    top: 30px;
    right: 30px;
    z-index: 2;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #1a1a1a;
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
.sb-map-fs-cerrar:hover {
    background: #f1f1f1;
}

.sb-map-fs-direccion {
    position: absolute;
    left: 30px;
    bottom: 30px;
    z-index: 2;
    max-width: calc(100% - 60px);
    background: #fff;
    color: #1a1a1a;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
}

@media (max-width: 768px) {
    .sb-map-fs-mapa {
        inset: 0;
        border-radius: 0;
    }
    .sb-map-fs-cerrar {
        top: 14px;
        right: 14px;
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
    .sb-map-fs-direccion {
        left: 14px;
        right: 14px;
        bottom: 14px;
        max-width: none;
        font-size: 13px;
    }
}
