/**
 * Estilos para el Generador de Códigos QR Tamaño Carta
 * Trinity OS // MenuGepi
 */

:root, [data-theme="light"] {
    --bg-main: #f6f9fc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #ffffff;
    --border-main: #e3e8ee;
    --border-focus: #635bff;
    --text-primary: #0a2540;
    --text-secondary: #425466;
    --text-muted: #8792a2;
    --accent-emerald: #635bff;
    --accent-teal: #0d9488;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --navbar-height: 64px;
}

[data-theme="dark"] {
    --bg-main: #0b0f19;
    --bg-card: #111827;
    --bg-card-hover: #1f2937;
    --bg-input: #1e293b;
    --border-main: rgba(255, 255, 255, 0.08);
    --border-focus: #10b981;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.font-mono-num {
    font-family: 'JetBrains Mono', monospace;
}

/* Clases de tema */
.theme-card {
    background-color: var(--bg-card);
    border-color: var(--border-main);
}
.theme-border {
    border-color: var(--border-main);
}
.theme-text-main {
    color: var(--text-primary);
}
.theme-text-sub {
    color: var(--text-secondary);
}
.theme-input {
    background-color: var(--bg-input);
    border-color: var(--border-main);
    color: var(--text-primary);
}

/* Layout Principal con Sidebar */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-main);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.app-sidebar.collapsed .sidebar-text,
.app-sidebar.collapsed .sidebar-header-info,
.app-sidebar.collapsed .sidebar-badge {
    display: none !important;
}

.app-sidebar.collapsed .sidebar-nav-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.app-main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

/* Navbar */
.app-navbar {
    height: var(--navbar-height);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-main);
}

[data-theme="dark"] .app-navbar {
    background-color: rgba(17, 24, 39, 0.85);
}

/* Drawer móvil */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 1023px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    }

    .app-sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-backdrop.active {
        display: block;
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(3px);
        z-index: 45;
    }
}

/* Botones de navegación del Sidebar */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.875rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
}

.sidebar-nav-item:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(20, 184, 166, 0.1));
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Selector de Tipos de QR (Grid / Píldoras) */
.btn-tipo-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.65rem 0.5rem;
    border-radius: 0.875rem;
    font-size: 0.6875rem;
    font-weight: 700;
    background-color: var(--bg-input);
    border: 1.5px solid var(--border-main);
    color: var(--text-secondary);
    transition: all 0.15s ease;
    cursor: pointer;
    text-align: center;
    user-select: none;
}

.btn-tipo-qr:hover {
    border-color: var(--accent-emerald);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-tipo-qr.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(20, 184, 166, 0.15));
    border-color: #10b981;
    color: #34d399;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

/* ========================================================================== */
/* LIENZO DE HOJA TAMAÑO CARTA (8.5 x 11 pulgadas = ratio 1:1.2941)           */
/* ========================================================================== */
.letter-canvas-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.8) 100%);
    border-radius: 1.5rem;
    border: 1px solid var(--border-main);
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 820px;
}

[data-theme="light"] .letter-canvas-wrapper {
    background: radial-gradient(circle at center, #e2e8f0 0%, #cbd5e1 100%);
}

/* Cartel en tamaño carta (816px x 1056px = 8.5 x 11 pulgadas exactas a 96 DPI) */
.letter-sheet {
    width: 816px;
    min-width: 816px;
    max-width: 816px;
    height: 1056px;
    min-height: 1056px;
    max-height: 1056px;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
    border-radius: 0;
    padding: 3.25rem 3rem 2.75rem; /* Márgenes normales uniformes: ~0.8in */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    box-sizing: border-box;
    transform-origin: top center;
    transition: transform 0.2s ease;
}

#poster-display-empresa {
    line-height: 1.35 !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible !important;
    padding-top: 2px;
    padding-bottom: 2px;
}

#poster-display-eslogan {
    line-height: 1.35 !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible !important;
}

.sheet-template-dark #poster-display-empresa {
    color: #f8fafc !important;
}
.sheet-template-dark #poster-display-eslogan {
    color: #94a3b8 !important;
}

/* Escalado visual responsivo en pantallas sin alterar la resolución de exportación */
@media (min-width: 1600px) {
    .letter-sheet {
        transform: scale(0.78);
        margin-bottom: -232px;
    }
}
@media (max-width: 1599px) and (min-width: 1200px) {
    .letter-sheet {
        transform: scale(0.68);
        margin-bottom: -338px;
    }
}
@media (max-width: 1199px) and (min-width: 768px) {
    .letter-sheet {
        transform: scale(0.55);
        margin-bottom: -475px;
    }
}
@media (max-width: 767px) {
    .letter-sheet {
        transform: scale(0.42);
        margin-bottom: -612px;
    }
}

/* Contenedor del código QR dentro del cartel */
.qr-render-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 1.25rem auto;
    position: relative;
    flex: 1;
}

.qr-render-box canvas,
.qr-render-box svg {
    display: block;
    width: 380px !important;
    height: 380px !important;
    max-width: 100%;
    border-radius: 1rem;
}

/* Plantillas de diseño visual para el cartel con barras de acento sin deformación */
/* 1. Plantilla Minimalista Corporativa */
.sheet-template-minimal::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: #0f172a;
}
.sheet-template-minimal .sheet-accent-box {
    background-color: #f8fafc;
    border: 1.5px solid #e2e8f0;
}

/* 2. Plantilla Ejecutivo Esmeralda */
.sheet-template-emerald::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: #059669;
}
.sheet-template-emerald::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: #059669;
}
.sheet-template-emerald .sheet-accent-box {
    background-color: #ecfdf5;
    border: 1.5px solid #a7f3d0;
    color: #065f46;
}

/* 3. Plantilla Cafetería / Restaurante Cálido */
.sheet-template-cafe {
    background: #fffbeb !important;
}
.sheet-template-cafe::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: #d97706;
}
.sheet-template-cafe::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: #d97706;
}
.sheet-template-cafe .sheet-accent-box {
    background-color: #fef3c7;
    border: 1.5px solid #fde68a;
    color: #78350f;
}

/* 4. Plantilla Dark / Nocturno Elegante (Impresión con fondo oscuro) */
.sheet-template-dark {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}
.sheet-template-dark::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: #38bdf8;
}
.sheet-template-dark .sheet-accent-box {
    background-color: #1e293b;
    border: 1.5px solid #475569;
    color: #38bdf8;
}

/* ========================================================================== */
/* REGLAS DE IMPRESIÓN DIRECTA TAMAÑO CARTA (WINDOW.PRINT)                     */
/* ========================================================================== */
@page {
    size: letter portrait;
    margin: 0;
}

@media print {
    body, html {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 8.5in !important;
        height: 11in !important;
        overflow: hidden !important;
    }

    .no-print,
    .app-sidebar,
    .app-navbar,
    .sidebar-backdrop,
    .form-controls-col,
    header,
    footer,
    #btn-container-actions {
        display: none !important;
    }

    .app-container,
    .app-main-wrapper,
    main,
    .letter-canvas-wrapper {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        min-height: auto !important;
        overflow: visible !important;
    }

    .letter-sheet {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 8.5in !important;
        height: 11in !important;
        max-width: 8.5in !important;
        margin: 0 !important;
        padding: 0.65in 0.6in !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .letter-sheet .qr-render-box canvas,
    .letter-sheet .qr-render-box svg {
        width: 3.5in !important;
        height: 3.5in !important;
    }
}
