﻿/* ============================================
   QR GENERATOR — REDISEÑO UI/UX
   Usa variables del tema global (styles.css)
   --card-surface, --text-dark, --text-gray,
   --border-subtle, --shadow-card, --bg-canvas,
   --brand-red, --brand-red-glow
   ============================================ */

/* Variables locales adicionales (no existen globalmente) */
:root {
    --brand-orange: #FF6B35;
    --brand-green: #16A34A;
    --qr-accent-soft: rgba(234, 118, 0, 0.08);
    --qr-accent-ring: rgba(234, 118, 0, 0.18);
    --qr-focus-ring: rgba(234, 118, 0, 0.28);
    --qr-success-soft: rgba(22, 163, 74, 0.12);
}

body.dark-theme {
    --qr-accent-soft: rgba(234, 118, 0, 0.14);
    --qr-accent-ring: rgba(234, 118, 0, 0.32);
    --qr-focus-ring: rgba(234, 118, 0, 0.45);
    --qr-success-soft: rgba(22, 163, 74, 0.18);
}

/* ============================================
   LAYOUT GENERAL
   ============================================ */
.qr-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 28px;
    align-items: start;
}

@media (max-width: 1100px) {
    .qr-layout {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   SECCIONES DEL FORM — rediseñadas como cards
   ============================================ */
.qr-config-panel .form-section {
    background: var(--card-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 22px 24px;
    box-shadow: var(--shadow-card);
    margin-bottom: 18px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.qr-config-panel .form-section:hover {
    border-color: var(--qr-accent-ring);
}

.qr-config-panel .form-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: var(--text-dark) !important;
    margin: 0 0 6px !important;
    letter-spacing: 0;
    text-transform: none;
}

/* Badge numerado antes del título (0./1./2.) */
.qr-config-panel .form-section-title::before {
    content: attr(data-step);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--qr-accent-soft);
    color: var(--brand-red);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    font-family: var(--font-display, 'Montserrat', sans-serif);
    flex-shrink: 0;
}

.qr-config-panel .form-section-help {
    color: var(--text-gray);
    font-size: 0.83rem;
    margin: 0 0 18px;
    line-height: 1.45;
}

.qr-config-panel .form-group {
    margin-bottom: 14px;
}

.qr-config-panel .form-group:last-child {
    margin-bottom: 0;
}

.qr-config-panel .form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.qr-config-panel .form-select,
.qr-config-panel .form-input,
.qr-config-panel .form-textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-canvas);
    border: 1.5px solid var(--border-subtle);
    border-radius: 10px;
    color: var(--text-dark);
    font-family: var(--font, 'Montserrat', sans-serif);
    font-size: 0.92rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    outline: none;
}

.qr-config-panel .form-textarea {
    resize: vertical;
    min-height: 64px;
    line-height: 1.5;
}

.qr-config-panel .form-select:hover,
.qr-config-panel .form-input:hover,
.qr-config-panel .form-textarea:hover {
    border-color: var(--qr-accent-ring);
}

.qr-config-panel .form-select:focus,
.qr-config-panel .form-input:focus,
.qr-config-panel .form-textarea:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px var(--qr-focus-ring);
    background: var(--card-surface);
}

.qr-config-panel .form-select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ============================================
   SELECTOR DE TIPO DE ORIGEN — grid visual
   ============================================ */
.type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.type-option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 22px 14px;
    background: var(--bg-canvas);
    border: 2px solid var(--border-subtle);
    border-radius: 14px;
    cursor: pointer;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-gray);
    transition: all 0.18s ease;
    overflow: hidden;
}

.type-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.type-option::after {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border-subtle);
    background: var(--card-surface);
    transition: all 0.18s ease;
}

.type-option:hover {
    border-color: var(--qr-accent-ring);
    background: var(--card-surface);
    transform: translateY(-1px);
}

.type-option:has(input:checked) {
    border-color: var(--brand-red);
    background: var(--qr-accent-soft);
    color: var(--brand-red);
    box-shadow: 0 6px 20px var(--qr-accent-soft);
}

.type-option:has(input:checked)::after {
    border-color: var(--brand-red);
    background: var(--brand-red);
    box-shadow: inset 0 0 0 4px var(--card-surface);
}

.type-icon {
    font-size: 1.9rem;
    line-height: 1;
}

/* ============================================
   SUBPANEL DE CONFIG (social / store)
   ============================================ */
.config-subpanel {
    margin-top: 16px;
    padding-top: 18px;
    border-top: 1px dashed var(--border-subtle);
    animation: slideDown 0.25s ease;
}

.config-subpanel:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* Badge de tienda asignada (para rol store — legado) */
.store-badge {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--qr-accent-soft);
    color: var(--brand-red);
    border: 1px solid var(--qr-accent-ring);
    border-radius: 12px;
}

.store-badge .store-icon {
    font-size: 1.7rem;
    line-height: 1;
}

.store-badge strong {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.75;
    margin-bottom: 2px;
}

.store-badge div > :last-child {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-dark);
}

/* ============================================
   BOTÓN PRIMARIO DE GENERAR
   ============================================ */
.btn-block {
    width: 100%;
    margin-top: 4px;
}

#btn-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px;
    background: var(--brand-red);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: var(--font, 'Montserrat', sans-serif);
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow: 0 6px 20px var(--brand-red-glow);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px var(--brand-red-glow);
}

#btn-generate:active:not(:disabled) {
    transform: translateY(0);
}

#btn-generate:disabled {
    opacity: 0.75;
    cursor: wait;
    transform: none;
}

/* ============================================
   PANEL DERECHO — PREVIEW
   ============================================ */
.qr-preview-panel {
    background: var(--card-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: sticky;
    top: 20px;
}

/* La ficha imprimible — más grande y premium */
.qr-card {
    width: 100%;
    max-width: 340px;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    padding: 28px 24px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 8px 28px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

/* Banda decorativa superior de la ficha */
.qr-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--brand-red), var(--brand-orange));
}

.qr-header {
    margin-bottom: 20px;
    padding-top: 6px;
}

.qr-logo {
    font-family: var(--font-display, 'Montserrat', sans-serif);
    font-weight: 900;
    font-style: italic;
    color: var(--brand-red);
    letter-spacing: -0.3px;
    font-size: 1.4rem;
    text-transform: uppercase;
}

/* Placeholder antes de generar */
.qr-placeholder {
    width: 240px;
    height: 240px;
    background:
        repeating-linear-gradient(45deg,
            rgba(0, 0, 0, 0.02) 0 10px,
            rgba(0, 0, 0, 0.04) 10px 20px);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #999;
    font-size: 0.85rem;
    font-weight: 500;
    border: 2px dashed #d6d6d6;
    text-align: center;
    padding: 16px;
}

.qr-placeholder::before {
    content: '◻';
    font-size: 3.2rem;
    line-height: 1;
    opacity: 0.4;
}

/* Canvas del QR real */
.qr-canvas-container {
    padding: 12px;
    background: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-canvas-container canvas,
.qr-canvas-container img {
    display: block;
    max-width: 100%;
    border-radius: 4px;
}

/* Footer de la ficha (fuente + ID) */
.qr-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed #e0e0e0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.qr-footer strong {
    color: #1a1a1a;
    font-size: 1rem;
    font-weight: 700;
}

.qr-footer span {
    color: #888;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-family: 'Courier New', monospace;
}

/* ============================================
   ACCIONES POST-GENERACIÓN
   ============================================ */
.qr-actions {
    width: 100%;
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.success-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 10px 14px;
    background: var(--qr-success-soft);
    color: var(--brand-green);
    border: 1px solid rgba(22, 163, 74, 0.25);
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0;
}

.action-buttons .btn {
    padding: 11px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.15s ease;
    border: 1px solid var(--border-subtle);
}

.action-buttons .btn-primary {
    background: var(--brand-red);
    color: #fff;
    border-color: var(--brand-red);
}

.action-buttons .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--brand-red-glow);
}

.action-buttons .btn-ghost {
    background: var(--bg-canvas);
    color: var(--text-dark);
}

.action-buttons .btn-ghost:hover {
    background: var(--card-surface);
    border-color: var(--qr-accent-ring);
}

/* Input + botón de copiar link */
.link-copy-group {
    display: flex;
    gap: 0;
    border: 1.5px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.link-copy-group:focus-within {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px var(--qr-focus-ring);
}

.link-copy-group input {
    flex: 1;
    padding: 10px 12px;
    border: none !important;
    border-radius: 0 !important;
    background: var(--bg-canvas);
    color: var(--text-gray);
    font-size: 0.78rem;
    font-family: 'Courier New', monospace;
    outline: none;
    min-width: 0;
}

.link-copy-group button {
    padding: 10px 16px;
    background: var(--card-surface);
    color: var(--text-dark);
    border: none;
    border-left: 1px solid var(--border-subtle);
    border-radius: 0;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.link-copy-group button:hover {
    background: var(--qr-accent-soft);
    color: var(--brand-red);
}

/* ============================================
   UTILS & ANIMACIONES
   ============================================ */
.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   DARK MODE — ajustes específicos
   La ficha QR siempre queda blanca (tiene que
   imprimirse y escanearse correctamente)
   ============================================ */
body.dark-theme .qr-placeholder {
    background:
        repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.02) 0 10px,
            rgba(255, 255, 255, 0.04) 10px 20px);
    border-color: #d6d6d6;
}

/* ============================================
   RESPONSIVE MÓVIL
   ============================================ */
@media (max-width: 640px) {
    .qr-layout {
        gap: 18px;
    }

    .qr-config-panel .form-section {
        padding: 18px 16px;
    }

    .qr-preview-panel {
        padding: 20px;
        position: static;
    }

    .qr-card {
        max-width: 100%;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   HISTORIAL — HEADER
   ============================================ */
.qr-history-section {
    margin-bottom: 8px;
}

.qr-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.qr-history-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qr-history-title h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.qr-history-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 9px;
    background: var(--qr-accent-soft);
    color: var(--brand-red);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 800;
    font-family: var(--font-display, 'Montserrat', sans-serif);
    transition: background 0.2s ease;
}

/* ============================================
   HISTORIAL — EMPTY STATE
   ============================================ */
.qr-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 24px;
    background: var(--card-surface);
    border: 2px dashed var(--border-subtle);
    border-radius: 16px;
    gap: 10px;
    color: var(--text-gray);
    text-align: center;
}

.qr-empty-icon {
    font-size: 2.8rem;
    opacity: 0.35;
    line-height: 1;
}

.qr-empty-state strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-top: 4px;
}

.qr-empty-state p {
    margin: 0;
    font-size: 0.86rem;
    max-width: 360px;
    line-height: 1.5;
}

/* ============================================
   HISTORIAL — BUSCADOR
   ============================================ */
.qr-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 280px;
    flex: 0 1 360px;
}

.qr-search-icon {
    position: absolute;
    left: 14px;
    font-size: 0.95rem;
    pointer-events: none;
    opacity: 0.6;
}

.qr-search-input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    background: var(--bg-canvas);
    border: 1.5px solid var(--border-subtle);
    border-radius: 10px;
    color: var(--text-dark);
    font-family: var(--font, 'Montserrat', sans-serif);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.qr-search-input:hover {
    border-color: var(--qr-accent-ring);
}

.qr-search-input:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px var(--qr-focus-ring);
    background: var(--card-surface);
}

.qr-search-input::-webkit-search-cancel-button {
    cursor: pointer;
}

/* ============================================
   HISTORIAL — TABLA
   ============================================ */
.qr-table-container {
    background: var(--card-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.qr-table-scroll {
    max-height: 480px;
    overflow-y: auto;
    overflow-x: auto;
}

.qr-table {
    width: 100%;
    min-width: 880px;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.qr-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--card-surface);
    box-shadow: inset 0 -1px 0 var(--border-subtle);
}

.qr-table thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    white-space: nowrap;
    background: var(--card-surface);
}

.qr-table tbody tr {
    border-top: 1px solid var(--border-subtle);
    transition: background 0.12s ease;
    animation: fadeIn 0.2s ease;
}

.qr-table tbody tr:hover {
    background: var(--qr-accent-soft);
}

.qr-table tbody td {
    padding: 13px 16px;
    color: var(--text-dark);
    vertical-align: middle;
}

.qr-table .cell-label {
    font-weight: 700;
    color: var(--text-dark);
    max-width: 280px;
    word-break: break-word;
}

.qr-table .cell-ref {
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    color: var(--text-gray);
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.qr-table .cell-date {
    font-size: 0.82rem;
    color: var(--text-gray);
    white-space: nowrap;
}

/* Badge de origen (compartido con el modal) */
.qr-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    width: fit-content;
    white-space: nowrap;
}

.qr-source-badge.src-facebook  { background: #e7f0fd; color: #1877F2; }
.qr-source-badge.src-instagram { background: #fce7f3; color: #E1306C; }
.qr-source-badge.src-tiktok    { background: #f0f0f0; color: #111;    }
.qr-source-badge.src-twitter   { background: #f0f0f0; color: #111;    }
.qr-source-badge.src-email     { background: #ede9fe; color: #6366F1; }
.qr-source-badge.src-website   { background: #dcfce7; color: #16A34A; }
.qr-source-badge.src-store     { background: #fff0f0; color: var(--brand-red); }

/* Pill de escaneos */
.qr-scan-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-gray);
    padding: 3px 10px;
    background: var(--bg-canvas);
    border-radius: 12px;
    white-space: nowrap;
}

.qr-scan-pill.has-scans {
    color: var(--brand-green);
    background: rgba(22, 163, 74, 0.12);
}

/* Acciones de la fila */
.qr-row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    white-space: nowrap;
}

.qr-row-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.14s ease;
    border: 1.5px solid transparent;
    font-family: var(--font, 'Montserrat', sans-serif);
    white-space: nowrap;
}

.qr-row-btn-view {
    background: var(--brand-red);
    color: #fff;
    border-color: var(--brand-red);
}

.qr-row-btn-view:hover {
    background: #c41430;
}

.qr-row-btn-ghost {
    background: transparent;
    color: var(--text-dark);
    border-color: var(--border-subtle);
}

.qr-row-btn-ghost:hover {
    background: var(--bg-canvas);
    border-color: var(--qr-accent-ring);
    color: var(--brand-red);
}

.qr-row-btn-danger {
    background: transparent;
    color: #b91c1c;
    border-color: rgba(185, 28, 28, 0.25);
}

.qr-row-btn-danger:hover {
    background: rgba(185, 28, 28, 0.08);
    border-color: #b91c1c;
    color: #b91c1c;
}

body.dark-theme .qr-row-btn-danger {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

body.dark-theme .qr-row-btn-danger:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: #f87171;
    color: #f87171;
}

/* No results state */
.qr-no-results {
    padding: 40px 24px;
    text-align: center;
    color: var(--text-gray);
    font-size: 0.9rem;
}

.qr-no-results strong {
    display: block;
    color: var(--text-dark);
    font-size: 1rem;
    margin-bottom: 4px;
}

/* ============================================
   MODAL — VER QR EN GRANDE
   ============================================ */
.qr-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.18s ease;
}

.qr-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

.qr-modal-content {
    position: relative;
    background: var(--card-surface);
    border-radius: 18px;
    width: 100%;
    max-width: 440px;
    padding: 30px 28px 26px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    animation: modalPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.qr-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-canvas);
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    color: var(--text-gray);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.qr-modal-close:hover {
    background: var(--qr-accent-soft);
    color: var(--brand-red);
    border-color: var(--qr-accent-ring);
}

.qr-modal-qr-wrap {
    padding: 20px;
    background: #ffffff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.qr-modal-qr-wrap::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-red), var(--brand-orange));
}

.qr-modal-qr-wrap img,
.qr-modal-qr-wrap canvas {
    display: block;
    width: 280px;
    height: 280px;
    max-width: 100%;
}

.qr-modal-info {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.qr-modal-label {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-dark);
    word-break: break-word;
}

.qr-modal-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.qr-modal-ref {
    font-family: 'Courier New', monospace;
    font-size: 0.76rem;
    color: var(--text-gray);
    letter-spacing: 0.4px;
}

.qr-modal-download {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    background: var(--brand-red);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: var(--font, 'Montserrat', sans-serif);
    font-size: 0.94rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px var(--brand-red-glow);
    transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.qr-modal-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px var(--brand-red-glow);
}

.qr-modal-download:active {
    transform: translateY(0);
}

/* ============================================
   MODAL — CONFIRMAR ELIMINACIÓN
   ============================================ */
.qr-delete-modal-content {
    max-width: 440px;
    text-align: center;
    gap: 14px;
    padding: 34px 28px 26px;
}

.qr-delete-icon {
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(185, 28, 28, 0.12);
    font-size: 2rem;
    line-height: 1;
}

.qr-delete-body {
    margin: 0;
    font-size: 0.92rem;
    color: var(--text-gray);
    line-height: 1.55;
}

.qr-delete-body strong {
    color: var(--text-dark);
    font-weight: 700;
    word-break: break-word;
}

.qr-delete-warning {
    margin: 0;
    padding: 10px 14px;
    font-size: 0.84rem;
    color: #b91c1c;
    background: rgba(185, 28, 28, 0.08);
    border: 1px solid rgba(185, 28, 28, 0.22);
    border-radius: 10px;
    line-height: 1.45;
}

body.dark-theme .qr-delete-warning {
    color: #fca5a5;
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.3);
}

.qr-delete-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 10px;
    margin-top: 6px;
}

.qr-delete-btn {
    padding: 12px 16px;
    border-radius: 10px;
    font-family: var(--font, 'Montserrat', sans-serif);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
    border: 1.5px solid transparent;
}

.qr-delete-btn-cancel {
    background: var(--bg-canvas);
    color: var(--text-dark);
    border-color: var(--border-subtle);
}

.qr-delete-btn-cancel:hover {
    background: var(--card-surface);
    border-color: var(--qr-accent-ring);
}

.qr-delete-btn-confirm {
    background: #b91c1c;
    color: #fff;
    border-color: #b91c1c;
    box-shadow: 0 4px 14px rgba(185, 28, 28, 0.35);
}

.qr-delete-btn-confirm:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(185, 28, 28, 0.45);
    background: #991b1b;
}

.qr-delete-btn-confirm:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* ============================================
   SEPARADOR DE SECCIÓN
   ============================================ */
.section-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 36px 0 30px;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.section-divider span {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-gray);
    white-space: nowrap;
    padding: 7px 18px;
    background: var(--card-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
}

/* ============================================
   FAB — botón flotante "↑ Historial"
   ============================================ */
.btn-scroll-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    background: var(--brand-red);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: var(--font, 'Montserrat', sans-serif);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px var(--brand-red-glow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
}

.btn-scroll-fab.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.btn-scroll-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px var(--brand-red-glow);
}

/* ============================================
   @MEDIA PRINT — sólo imprimir la ficha
   ============================================ */
@media print {
    @page {
        margin: 1.5cm;
    }

    body,
    body.dark-theme {
        background: #fff !important;
        color: #000 !important;
    }

    /* Ocultar TODO lo que no es la ficha */
    .cfg-sidebar,
    .cfg-header,
    .qr-config-panel,
    .qr-actions,
    .hamburger,
    .user-menu {
        display: none !important;
    }

    /* Expandir el main a toda la página */
    .cfg-main,
    .cfg-content,
    .qr-layout,
    .qr-preview-panel {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
        position: static !important;
    }

    /* Centrar la ficha en la página */
    .qr-preview-panel {
        display: flex !important;
        justify-content: center !important;
        align-items: flex-start !important;
        padding-top: 1cm !important;
    }

    .qr-card {
        max-width: 10cm !important;
        width: 10cm !important;
        box-shadow: 0 0 0 1px #ccc !important;
        page-break-inside: avoid;
        background: #fff !important;
    }

    .qr-card::before {
        background: var(--brand-red) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .qr-canvas-container canvas,
    .qr-canvas-container img {
        width: 7cm !important;
        height: 7cm !important;
    }
}
