/* ═══════════════════════════════════════════════
   Desarrollo Module – Design System
   Centralized tokens, shared styles, print rules.
   All sub-module CSS files inherit from here.
   ═══════════════════════════════════════════════ */

/* ── Global Design Tokens ────────────────────── */
:root {
    /* ─── Surface & Color ─── */
    --pv-bg-base: #0a0e1a;
    --pv-card-surface: rgba(18, 24, 40, 0.75);
    --pv-card-surface-solid: #121828;
    --pv-card-border: rgba(56, 73, 107, 0.25);
    --pv-card-radius: 16px;
    --pv-accent: #3b82f6;
    --pv-accent-hover: #2563eb;
    --pv-accent-cyan: #22d3ee;
    --pv-text-primary: #e2e8f0;
    --pv-text-secondary: #8091a7;
    --pv-text-muted: #9fb0c4;
    --pv-elevation: 0 4px 24px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.1);
    --pv-input-radius: 10px;

    /* ─── Semantic Colors ─── */
    --pv-green: #22c55e;
    --pv-green-text: #4ade80;
    --pv-red: #ef4444;
    --pv-red-text: #f87171;
    --pv-amber: #f59e0b;
    --pv-amber-text: #fbbf24;
    --pv-purple-text: #c084fc;

    /* ─── Typography ─── */
    --pv-font-ui: 'Inter', 'DM Sans', system-ui, sans-serif;
    --pv-font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Modular scale — minor third (1.2 ratio) */
    --pv-text-xs: 0.68rem;
    /* ~11px — captions, minor labels */
    --pv-text-sm: 0.78rem;
    /* ~12.5px — labels, badges, table headers */
    --pv-text-base: 0.88rem;
    /* ~14px — body, inputs, data cells */
    --pv-text-lg: 1.05rem;
    /* ~17px — section titles */
    --pv-text-xl: 1.3rem;
    /* ~21px — hero product name */
    --pv-text-2xl: 1.6rem;
    /* ~26px — KPI values */

    /* ─── Glassmorphism ─── */
    --pv-glass-blur: blur(12px);
    --pv-glass-blur-heavy: blur(20px) saturate(1.4);
    --pv-glass-surface: rgba(18, 24, 40, 0.65);
    --pv-glass-border: rgba(56, 73, 107, 0.3);
    --pv-glow-cyan: 0 0 20px rgba(34, 211, 238, 0.08);
    --pv-glow-accent: 0 0 16px rgba(59, 130, 246, 0.1);

    /* ─── Transitions ─── */
    --pv-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --pv-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --pv-duration-fast: 0.15s;
    --pv-duration-normal: 0.25s;
    --pv-duration-slow: 0.35s;

    /* ─── Layout ─── */
    --pv-page-max: 1400px;
    --pv-page-gutter: 1.5rem;

    /* ─── Marbete — Shell (dark UI) ─── */
    --mb-bg-deep: #0f172a;
    --mb-bg-surface: #1e293b;
    --mb-border: rgba(255, 255, 255, 0.06);
    --mb-border-alt: rgba(255, 255, 255, 0.08);
    --mb-text: #e2e8f0;
    --mb-text-muted: #94a3b8;
    --mb-text-dim: #64748b;
    --mb-accent: #3b82f6;
    --mb-accent-hover: #2563eb;
    --mb-green: #22c55e;
    --mb-red: #ef4444;

    /* ─── Marbete — Label (print surface) ─── */
    --mb-lbl-text: #111827;
    --mb-lbl-muted: #374151;
    --mb-lbl-subtle: #6b7280;
    --mb-lbl-border: #d1d5db;
    --mb-lbl-border-lt: #e5e7eb;

    /* Label typography scale (px for print fidelity) */
    --mb-fs-xs: 7.5px;
    --mb-fs-sm: 8px;
    --mb-fs-base: 9px;
    --mb-fs-md: 10px;
    --mb-fs-lg: 12px;
}

/* ── Shared autocomplete dropdown base ─────── */
.desarrollo-autocomplete-results {
    color: var(--pv-text-primary);
    max-height: 320px;
    overflow-y: auto;
    background: var(--pv-card-surface-solid);
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.desarrollo-autocomplete-results>div {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background var(--pv-duration-fast) ease;
}

.desarrollo-autocomplete-results>div:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* ── Sub-module section transitions ────────── */
.sub-module-section {
    animation: fadeIn 0.25s var(--pv-ease-out);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Global Focus Ring (Accessibility) ───────── */
.sub-module-section :focus-visible {
    outline: 2px solid var(--pv-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (max-width: 900px) {
    #section-desarrollo,
    #section-desarrollo .desarrollo-shell,
    #section-desarrollo .sub-module-section {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    #section-desarrollo .desarrollo-shell {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    #section-desarrollo .module-subnav {
        position: sticky;
        top: 56px;
        z-index: 420;
        margin: -4px -4px 14px;
        padding: 8px 4px;
        background: rgba(10, 14, 26, 0.9);
        border-bottom: 1px solid rgba(148, 163, 184, 0.12);
        backdrop-filter: blur(14px) saturate(1.25);
        -webkit-backdrop-filter: blur(14px) saturate(1.25);
    }
}

/* ── Skeleton Shimmer (Reusable Loading) ─────── */
.pv-skeleton {
    background: linear-gradient(90deg,
            rgba(148, 163, 184, 0.06) 25%,
            rgba(148, 163, 184, 0.12) 50%,
            rgba(148, 163, 184, 0.06) 75%);
    background-size: 200% 100%;
    animation: pv-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--pv-card-radius);
}

@keyframes pv-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ── Desarrollo Configuracion ───────────────────────────────────────── */
.devcfg-shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 0 40px;
    color: var(--pv-text-primary);
    font-family: var(--pv-font-ui);
}

.devcfg-header,
.devcfg-card-head,
.devcfg-actions,
.devcfg-files-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.devcfg-header {
    margin-bottom: 16px;
}

.devcfg-header h2,
.devcfg-card h3,
.devcfg-files h4 {
    margin: 0;
    color: var(--pv-text-primary);
    font-weight: 650;
    letter-spacing: 0;
}

.devcfg-header h2 {
    font-size: var(--pv-text-xl);
}

.devcfg-card h3 {
    font-size: var(--pv-text-lg);
}

.devcfg-files h4 {
    font-size: var(--pv-text-base);
}

.devcfg-header p,
.devcfg-card-head p,
.devcfg-files-head span {
    margin: 4px 0 0;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
}

.devcfg-card {
    padding: 22px;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-card-radius);
    background: var(--pv-card-surface);
    box-shadow: var(--pv-elevation);
    backdrop-filter: var(--pv-glass-blur);
    -webkit-backdrop-filter: var(--pv-glass-blur);
}

.devcfg-card + .devcfg-card {
    margin-top: 18px;
}

.devcfg-card--bridge {
    border-color: rgba(34, 211, 238, 0.18);
}

.devcfg-status {
    margin: 18px 0;
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid rgba(56, 73, 107, 0.35);
    background: rgba(10, 14, 26, 0.55);
    color: var(--pv-text-muted);
    font-size: var(--pv-text-sm);
}

.devcfg-status--success {
    border-color: rgba(34, 197, 94, 0.35);
    color: var(--pv-green-text);
}

.devcfg-status--warning {
    border-color: rgba(245, 158, 11, 0.35);
    color: var(--pv-amber-text);
}

.devcfg-status--error {
    border-color: rgba(239, 68, 68, 0.45);
    color: var(--pv-red-text);
}

.devcfg-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 14px;
}

.devcfg-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.devcfg-field--wide {
    grid-column: 1 / -1;
}

.devcfg-field span {
    color: var(--pv-text-muted);
    font-size: var(--pv-text-sm);
    font-weight: 650;
}

.devcfg-field textarea,
.devcfg-field input {
    width: 100%;
    min-height: 46px;
    padding: 12px 13px;
    border: 1px solid rgba(56, 73, 107, 0.55);
    border-radius: var(--pv-input-radius);
    background: rgba(6, 10, 20, 0.72);
    color: var(--pv-text-primary);
    font-size: var(--pv-text-base);
    resize: vertical;
}

.devcfg-field textarea:focus,
.devcfg-field input:focus {
    border-color: rgba(34, 211, 238, 0.55);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08);
    outline: none;
}

.devcfg-files {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.devcfg-smtp-box {
    margin: 0 0 18px;
    padding: 16px;
    border: 1px solid rgba(56, 73, 107, 0.34);
    border-radius: 14px;
    background: rgba(6, 10, 20, 0.36);
}

.devcfg-grid--smtp {
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
    margin-top: 12px;
}

.devcfg-smtp-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.devcfg-smtp-actions .devcfg-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    filter: grayscale(0.25);
}

.devcfg-help {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 650;
}

.devcfg-help--ok {
    color: var(--pv-green-text);
}

.devcfg-help--warn {
    color: var(--pv-amber-text);
}

.devcfg-oauth-note {
    display: grid;
    gap: 6px;
    margin-top: 13px;
    padding: 10px 12px;
    border: 1px solid rgba(56, 73, 107, 0.34);
    border-radius: 10px;
    background: rgba(10, 14, 26, 0.42);
}

.devcfg-oauth-note span {
    color: var(--pv-text-muted);
    font-size: var(--pv-text-xs);
    font-weight: 700;
    letter-spacing: 0;
}

.devcfg-oauth-note code {
    color: var(--pv-accent-cyan);
    font-family: var(--pv-font-mono);
    font-size: var(--pv-text-xs);
    white-space: normal;
    word-break: break-all;
}

.devcfg-file-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.devcfg-file-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    padding: 13px;
    border: 1px solid rgba(56, 73, 107, 0.38);
    border-radius: 12px;
    background: rgba(6, 10, 20, 0.55);
    cursor: pointer;
}

.devcfg-file-option input {
    margin-top: 3px;
}

.devcfg-file-copy {
    min-width: 0;
}

.devcfg-file-copy strong {
    display: block;
    color: var(--pv-text-primary);
    font-size: var(--pv-text-sm);
    font-weight: 650;
}

.devcfg-file-copy small {
    display: block;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    line-height: 1.35;
    margin-top: 3px;
}

.devcfg-file-option em {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(34, 211, 238, 0.24);
    color: var(--pv-accent-cyan);
    font-size: var(--pv-text-xs);
    font-style: normal;
    font-weight: 650;
}

.devcfg-actions {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.devcfg-bridge-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.devcfg-bridge-metric {
    min-width: 0;
    padding: 14px;
    border: 1px solid rgba(56, 73, 107, 0.34);
    border-radius: 12px;
    background: rgba(6, 10, 20, 0.48);
}

.devcfg-bridge-metric span {
    display: block;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 700;
}

.devcfg-bridge-metric strong {
    display: block;
    margin-top: 6px;
    color: var(--pv-text-primary);
    font-family: var(--pv-font-mono);
    font-size: var(--pv-text-base);
    font-weight: 700;
}

.devcfg-bridge-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.devcfg-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--pv-text-muted);
    font-size: var(--pv-text-sm);
    font-weight: 650;
}

.devcfg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 15px;
    border-radius: 10px;
    border: 1px solid rgba(56, 73, 107, 0.5);
    background: rgba(15, 23, 42, 0.75);
    color: var(--pv-text-primary);
    font-size: var(--pv-text-sm);
    font-weight: 650;
    cursor: pointer;
}

.devcfg-btn--primary {
    border-color: rgba(34, 211, 238, 0.35);
    background: rgba(8, 145, 178, 0.18);
    color: #67e8f9;
}

.devcfg-btn:hover {
    border-color: rgba(34, 211, 238, 0.45);
}

.devcfg-pill {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 700;
}

.devcfg-pill--ok {
    border-color: rgba(34, 197, 94, 0.35);
    color: var(--pv-green-text);
    background: rgba(34, 197, 94, 0.08);
}

.devcfg-pill--warn {
    border-color: rgba(245, 158, 11, 0.35);
    color: var(--pv-amber-text);
    background: rgba(245, 158, 11, 0.08);
}

@media (max-width: 900px) {
    .devcfg-grid,
    .devcfg-file-list,
    .devcfg-bridge-grid {
        grid-template-columns: 1fr;
    }

    .devcfg-header,
    .devcfg-card-head,
    .devcfg-actions {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* =============================================
   Consolidated Print Rules
   Only one sub-module's printable area is shown.
   ============================================= */
@media print {

    /* 1. Hide everything by default */
    body * {
        visibility: hidden;
    }

    /* 2. Make the printable areas and all their children visible */
    #cofepris-doc-preview,
    #cofepris-doc-preview *,
    #sub-desarrollo-marbete .label-preview,
    #sub-desarrollo-marbete .label-preview * {
        visibility: visible;
    }

    /* Cuali prints using a body class to avoid any conflict */
    body.cuali-printing #cuali-print-area,
    body.cuali-printing #cuali-print-area * {
        visibility: visible;
    }

    /* 3. Reset the main layout shells */
    body,
    html {
        height: auto !important;
        overflow: visible !important;
    }

    /* 4. Cofepris print area */
    #cofepris-doc-preview {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 15mm;
        box-shadow: none !important;
        background: white !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* 5. Cuali print area — only active with body class */
    body.cuali-printing #cuali-print-area {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 8mm;
        box-shadow: none !important;
        background: white !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    #sub-desarrollo-marbete .label-preview {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    @page {
        size: A4 landscape;
        margin: 10mm;
    }
}

/* ── Autocomplete Loading Spinner ────────────── */
.ac-loading-spinner {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
}

.ac-spinner-ring {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(148, 163, 184, 0.25);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: ac-spin 0.6s linear infinite;
}

@keyframes ac-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Autocomplete — keyboard navigation highlight (Arrow Up/Down) */
.ac-active {
    background-color: rgba(59, 130, 246, 0.18) !important;
    box-shadow: inset 3px 0 0 #3b82f6;
}
