/* ═══════════════════════════════════════════════════════════════════════
   /tienda-admin/editor.css
   Estilos del shell del editor del eCommerce admin.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --brand: #16A344;
    --g: #16A344;
    --g-dark: #0E5C2A;
    --gd: #0E5C2A;
    --gl: #DCFCE7;
    --orange: #F49B1F;
    --accent: #F49B1F;
    --paper: #FBF8F0;
    --white: #FFFFFF;
    --ink: #1A1F1A;
    --t1: #1A1F1A;
    --t2: #4A4A48;
    --t3: #6B6459;
    --muted: #6B6459;
    --border: #E5DDC9;
    --line: #E5DDC9;
    --surface: #FFFFFF;
    --surface-2: #FAFAF7;
    --err: #DC2626;
    --warn: #D97706;
    --ok: #16A34A;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Arial, sans-serif;
    background: #F1F5F9;
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ─── LOGIN ────────────────────────────────── */
.login-wrap {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0E5C2A 0%, #16A344 60%, #8BC34A 100%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { max-width: 120px; height: auto; }
.login-title { font-size: 22px; font-weight: 800; text-align: center; color: var(--g-dark); margin-bottom: 6px; }
.login-sub { font-size: 13px; text-align: center; color: var(--t3); margin-bottom: 28px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--t2); margin-bottom: 6px; margin-top: 14px; }
.login-card input { width: 100%; padding: 12px 14px; border: 2px solid var(--border); border-radius: 10px; font-size: 15px; font-family: inherit; }
.login-card input:focus { outline: none; border-color: var(--brand); }
.login-btn {
    width: 100%; padding: 14px; margin-top: 20px;
    background: linear-gradient(135deg, var(--brand), var(--g-dark));
    color: white; border: none; border-radius: 10px;
    font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
    transition: transform .1s;
}
.login-btn:hover { transform: translateY(-1px); }
.login-btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
.login-err {
    margin-top: 14px; padding: 10px 12px;
    background: #FEF2F2; color: var(--err);
    border-radius: 8px; font-size: 13px; display: none;
}
.login-foot { text-align: center; margin-top: 20px; font-size: 12px; color: var(--t3); }
.login-foot a { color: var(--brand); text-decoration: none; }

/* ─── LOADING ──────────────────────────────── */
.app-loading {
    height: 100vh; display: flex;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 14px; color: var(--t3);
}
.app-loading .spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border); border-top-color: var(--brand);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── APP SHELL ────────────────────────────── */
.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── TOOLBAR ─────────────────────────────── */
.toolbar {
    background: #1F2937;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 3px solid var(--orange);
    height: 56px;
    flex-shrink: 0;
    gap: 10px;
}

.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.toolbar-center { flex: 1; justify-content: center; }
.toolbar-right { gap: 8px; }

.brand {
    display: flex; align-items: center; gap: 10px;
    color: white; text-decoration: none; font-weight: 700; font-size: 14px;
}
.brand img { height: 28px; }

/* Mode toggle (Edit / Preview) */
.mode-toggle, .lang-toggle, .device-toggle {
    display: flex;
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}
.mode-btn, .lang-btn, .dev-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.65);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.15s;
}
.mode-btn:hover, .lang-btn:hover, .dev-btn:hover {
    color: white;
    background: rgba(255,255,255,0.05);
}
.mode-btn.active, .lang-btn.active, .dev-btn.active {
    background: white;
    color: var(--ink);
}
.dev-btn { padding: 6px 10px; font-size: 14px; }

/* Indicador "X cambios sin guardar" */
.dirty-tag {
    color: var(--orange);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    background: rgba(244,155,31,0.15);
    border-radius: 20px;
    display: none;
}
.dirty-tag.visible { display: inline-block; }

.user-tag {
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    padding-left: 8px;
    border-left: 1px solid rgba(255,255,255,0.2);
}

/* ─── BOTONES ─────────────────────────────── */
.btn {
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .15s;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn-primary:hover:not(:disabled) { background: var(--g-dark); border-color: var(--g-dark); }
.btn-secondary { background: rgba(255,255,255,0.08); color: white; border-color: rgba(255,255,255,0.2); }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.15); }
.btn-ghost { background: transparent; color: rgba(255,255,255,0.85); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.1); color: white; }
.btn-danger { background: #FEF2F2; color: var(--err); border-color: #FECACA; }
.btn-danger:hover:not(:disabled) { background: var(--err); color: white; }
.btn-sm { padding: 5px 10px; font-size: 11px; }

.btn-icon {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.85);
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); color: white; }

/* Estilo "claro" para botón icono dentro de paneles claros */
.side-panel .btn-icon, .drawer .btn-icon, .modal-box .btn-icon {
    color: var(--t3);
}
.side-panel .btn-icon:hover, .drawer .btn-icon:hover, .modal-box .btn-icon:hover {
    background: var(--surface-2);
    color: var(--t1);
}

/* ─── MAIN AREA ──────────────────────────── */
.main-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #E2E8F0;
}

/* Iframe wrap */
.iframe-wrap {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
    padding: 20px;
    transition: padding 0.2s;
}
.iframe-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: max-width 0.3s ease, max-height 0.3s ease;
}

/* Devices */
.iframe-wrap.device-desktop iframe { max-width: 100%; max-height: 100%; }
.iframe-wrap.device-tablet { padding: 30px; }
.iframe-wrap.device-tablet iframe { max-width: 820px; max-height: 100%; }
.iframe-wrap.device-mobile { padding: 30px; }
.iframe-wrap.device-mobile iframe { max-width: 390px; max-height: 100%; }

/* ─── SIDE PANEL ─────────────────────────── */
.side-panel {
    width: 0;
    background: white;
    border-left: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    flex-shrink: 0;
}
.side-panel.open { width: 380px; }

.side-panel-header {
    padding: 14px 18px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.side-panel-header h3 {
    font-size: 15px;
    color: var(--t1);
    font-weight: 700;
    margin: 0;
}
.side-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
}
.side-panel-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.side-panel-footer:empty { display: none; }

/* Form fields dentro del side panel */
.side-panel label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--t2);
    margin-top: 14px;
    margin-bottom: 5px;
}
.side-panel label:first-child { margin-top: 0; }
.side-panel input[type="text"],
.side-panel input[type="number"],
.side-panel textarea,
.side-panel select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    background: white;
    color: var(--t1);
}
.side-panel input:focus,
.side-panel textarea:focus,
.side-panel select:focus {
    outline: none;
    border-color: var(--brand);
}
.side-panel textarea { min-height: 70px; resize: vertical; }
.side-panel input[type="color"] { width: 50px; height: 40px; padding: 2px; border-radius: 6px; cursor: pointer; }

.field-row { margin-bottom: 4px; }
.field-row .help {
    font-size: 11px;
    color: var(--t3);
    margin-top: 4px;
}
.field-bilingual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.field-bilingual .lang-tag {
    font-size: 10px;
    color: var(--t3);
    margin-bottom: 4px;
    display: block;
    font-weight: 700;
}

.section-divider {
    height: 1px;
    background: var(--border);
    margin: 20px -18px;
}

.image-preview-box {
    width: 100%;
    aspect-ratio: 16/10;
    background: var(--surface-2);
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t3);
    font-size: 24px;
    border: 1px solid var(--border);
}

/* ─── DRAWER (Diseño global) ──────────────── */
.drawer-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.drawer-bg.on { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed;
    top: 0; right: 0;
    width: 90%;
    max-width: 1200px;
    height: 100vh;
    background: white;
    z-index: 101;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(0,0,0,0.2);
}
.drawer.on { transform: translateX(0); }

.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    flex-shrink: 0;
}
.drawer-header h2 { font-size: 18px; color: var(--t1); margin-bottom: 4px; }
.drawer-header p { font-size: 12px; color: var(--t3); margin: 0; max-width: 700px; }
.drawer-close {
    color: var(--t3) !important;
    font-size: 20px;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 24px;
    background: #FAFAF7;
}

/* ─── MODAL ─────────────────────────────── */
.modal-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-bg.on { display: flex; }
.modal-box {
    background: white;
    border-radius: 14px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal-box.wide { max-width: 900px; }
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 16px; color: var(--t1); margin: 0; }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--surface-2);
}

/* Estilos de botón dentro de modal/drawer (claros) */
.modal-box .btn,
.side-panel .btn,
.drawer-body .btn {
    color: var(--t1);
}
.modal-box .btn-primary,
.side-panel .btn-primary,
.drawer-body .btn-primary {
    background: var(--brand);
    color: white;
    border-color: var(--brand);
}
.modal-box .btn-secondary,
.side-panel .btn-secondary,
.drawer-body .btn-secondary {
    background: white;
    color: var(--t1);
    border-color: var(--border);
}
.modal-box .btn-ghost,
.side-panel .btn-ghost,
.drawer-body .btn-ghost {
    background: transparent;
    color: var(--t2);
}
.modal-box .btn-ghost:hover:not(:disabled),
.side-panel .btn-ghost:hover:not(:disabled),
.drawer-body .btn-ghost:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--t1);
}

/* Inputs en modal */
.modal-body label { display: block; font-size: 12px; font-weight: 600; color: var(--t2); margin-top: 12px; margin-bottom: 5px; }
.modal-body label:first-child { margin-top: 0; }
.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    background: white;
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
    outline: none;
    border-color: var(--brand);
}

/* ─── TOAST ─────────────────────────────── */
.toast-host {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 12px 18px;
    background: var(--ink);
    color: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    font-size: 13px;
    font-weight: 500;
    animation: toastIn 0.3s ease;
    pointer-events: auto;
}
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } }
.toast-error { background: var(--err); }
.toast-success { background: var(--ok); }

/* ─── Cuando el drawer (diseño global) está abierto, los estilos
       del editor diseno.js los heredamos ─────────────────────── */
.drawer-body .input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 13px; background: white; color: var(--t1); }
.drawer-body .input:focus { outline: none; border-color: var(--brand); }
.drawer-body select.input { cursor: pointer; }

/* ─── List items para banners/testimonios/services en drawer ─── */
.dz-list-item .btn { padding: 5px 10px; font-size: 11px; }

/* Responsive: en pantallas pequeñas, ocultar centro de toolbar */
@media (max-width: 900px) {
    .toolbar-center { gap: 6px; }
    .device-toggle { display: none; }
}
@media (max-width: 700px) {
    .toolbar-left .brand span { display: none; }
    .toolbar-right .btn-ghost { display: none; }
    .lang-toggle { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   v85.7: Selector de página (toolbar central)
   ═══════════════════════════════════════════════════════════════════ */
.page-toggle { position: relative; }
.page-btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    background: var(--gl, #f0fdf4);
    border: 1.5px solid var(--brand, #16A344);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--brand, #16A344);
    cursor: pointer;
    transition: all .15s;
    min-width: 200px;
    justify-content: space-between;
    gap: 8px;
}
.page-btn:hover { background: var(--brand, #16A344); color: #fff; }
.page-btn:hover #page-btn-label { color: #fff; }
.page-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0,0,0,.16);
    min-width: 320px;
    z-index: 600;
    overflow: hidden;
    padding: 6px;
}
.page-menu-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background .12s;
}
.page-menu-item:hover { background: var(--gl, #f0fdf4); }
.page-menu-item.active { background: var(--gl, #f0fdf4); }
.page-menu-item.active .pmi-text b { color: var(--brand, #16A344); }
.pmi-ico { font-size: 18px; flex-shrink: 0; line-height: 1.2; }
.pmi-text { display: flex; flex-direction: column; gap: 2px; }
.pmi-text b { font-size: 13px; color: var(--ink, #1a1a1a); font-weight: 600; }
.pmi-text small { font-size: 11px; color: var(--t2, #6b7280); }
.page-menu-sep { height: 1px; background: var(--border, #e5e7eb); margin: 6px 8px; }

/* Aviso "página no edit-aware" */
.page-not-aware {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 28px 32px;
    box-shadow: 0 16px 48px rgba(0,0,0,.18);
    text-align: center;
    max-width: 380px;
    z-index: 50;
}
.page-not-aware h3 { font-size: 15px; margin: 0 0 8px; color: var(--ink, #1a1a1a); }
.page-not-aware p { font-size: 13px; color: var(--t2, #6b7280); line-height: 1.5; margin: 0 0 16px; }
.page-not-aware .pna-icon { font-size: 36px; margin-bottom: 12px; }

@media (max-width: 900px) {
    .page-btn { min-width: 160px; font-size: 12px; padding: 6px 10px; }
    .page-menu { min-width: 280px; }
}
