/* ==========================================================================
   Augusto Acosta - Certificado de Autenticidad Stylesheet
   ========================================================================== */

/* --- Custom Variables & Tokens --- */
:root {
    --color-dark: #121214;
    --color-dark-surface: #1e1e24;
    --color-dark-border: rgba(255, 255, 255, 0.08);
    
    --color-rust: #d4763b;
    --color-rust-hover: #b85e26;
    --color-bronze: #a46d46;
    --color-gold: #c99c6d;
    --color-paper: #fdfbf7;
    --color-ink: #2c2c2e;
    --color-ink-muted: #5a5a60;

    --font-sans: 'Outfit', 'Inter', sans-serif;
    --font-serif: 'Lora', serif;
    --font-cursive: 'Great Vibes', cursive;
}

/* --- Base Reset & Setup --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-dark);
    color: #e3e3e8;
    font-family: var(--font-sans);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Navigation Header (Non-printable) --- */
.cert-header {
    background: rgba(18, 18, 20, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-dark-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-link {
    text-decoration: none;
    display: flex;
    flex-direction: column;
}

.logo-title {
    color: #f3f3f3;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 1px;
    font-family: var(--font-sans);
}

.logo-tag {
    color: var(--color-rust);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.back-btn {
    color: #a3a3ac;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s ease;
}

.back-btn:hover {
    color: var(--color-rust);
}

/* --- Main Layout Split Container --- */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: row;
    height: calc(100vh - 65px);
    overflow: hidden;
}

/* --- Sidebar Configurator (Non-printable) --- */
.sidebar {
    width: 400px;
    background: rgba(22, 22, 26, 0.95);
    border-right: 1px solid var(--color-dark-border);
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.3);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-family: var(--font-serif);
    color: #f3f3f3;
    margin-bottom: 0.5rem;
}

.sidebar-header p {
    font-size: 0.85rem;
    color: #a3a3ac;
    line-height: 1.4;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.form-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1.5rem;
}

.form-section h3 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-rust);
    margin-bottom: 1rem;
}

.form-section p.section-hint {
    font-size: 0.8rem;
    color: #a3a3ac;
    margin-bottom: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

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

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #c5c5ca;
}

input[type="text"],
input[type="number"],
input[type="url"],
select {
    background: #23232a;
    border: 1px solid var(--color-dark-border);
    color: #ffffff;
    padding: 0.65rem 0.85rem;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all 0.3s ease;
    width: 100%;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--color-rust);
    box-shadow: 0 0 0 2px rgba(212, 118, 59, 0.25);
}

.edition-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edition-inputs input {
    text-align: center;
}

.edition-inputs span {
    font-weight: 600;
    color: #a3a3ac;
}

/* Image Selector Thumbnails Grid */
.image-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.img-thumb {
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    background-color: #000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.img-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.img-thumb:hover img {
    opacity: 0.9;
}

.img-thumb.active {
    border-color: var(--color-rust);
    box-shadow: 0 0 10px rgba(212, 118, 59, 0.4);
}

.img-thumb.active img {
    opacity: 1;
}

/* Print Button */
.print-btn {
    background: linear-gradient(135deg, var(--color-rust), #bf5e22);
    color: #ffffff;
    border: none;
    padding: 0.9rem;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(212, 118, 59, 0.2);
    margin-top: 1rem;
}

.print-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(212, 118, 59, 0.35);
    background: linear-gradient(135deg, #e07f43, #c96525);
}

.print-btn:active {
    transform: translateY(0);
}

/* --- Preview Pane Area (Non-printable outside print mode) --- */
.preview-pane {
    flex: 1;
    background: #0d0d0f;
    padding: 2.5rem;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Document Wrapper to handle landscape scale in browser container */
.certificate-wrapper {
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    background: white;
    width: 950px;
    height: 672px; /* Proportional to A4: 1.414 ratio */
    min-width: 950px;
    position: relative;
}

/* --- The Actual Certificate (Print layout) --- */
.certificate {
    background-color: var(--color-paper);
    width: 100%;
    height: 100%;
    padding: 30px;
    position: relative;
    color: var(--color-ink);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
}

/* Subtle Paper Texture Background overlay */
.certificate::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(#000000 0.5px, transparent 0.5px), radial-gradient(#000000 0.5px, #fdfbf7 0.5px);
    background-size: 8px 8px;
    background-position: 0 0, 4px 4px;
    opacity: 0.015; /* Extremely subtle */
    pointer-events: none;
    z-index: 1;
}

/* Premium Border Filigree Layout */
.border-outer {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    border: 3px double var(--color-bronze);
    pointer-events: none;
    z-index: 2;
}

.border-inner {
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 1px solid rgba(164, 109, 70, 0.4);
}

/* Artistic Corner Ornaments */
.border-outer::before,
.border-outer::after,
.border-inner::before,
.border-inner::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--color-bronze);
    border-style: solid;
    pointer-events: none;
}

.border-outer::before { top: -3px; left: -3px; border-width: 3px 0 0 3px; }
.border-outer::after { top: -3px; right: -3px; border-width: 3px 3px 0 0; }
.border-inner::before { bottom: -5px; left: -5px; border-width: 0 0 3px 3px; }
.border-inner::after { bottom: -5px; right: -5px; border-width: 0 3px 3px 0; }

/* Background Watermark */
.watermark-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 380px;
    height: 380px;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

.watermark-silhouette {
    width: 100%;
    height: 100%;
}

/* Certificate Body Layout */
.cert-body {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

/* Header artist block */
.cert-header-title {
    text-align: center;
    margin-bottom: 8px;
}

.artist-name {
    font-family: var(--font-sans);
    font-size: 1.4rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: var(--color-ink);
}

.artist-subtitle {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--color-rust);
    margin-top: 3px;
    font-weight: 600;
}

.divider-line {
    width: 60px;
    height: 1px;
    background-color: var(--color-bronze);
    margin: 8px auto 0;
    opacity: 0.5;
}

/* Certificate main title */
.cert-main-title {
    text-align: center;
    font-family: var(--font-serif);
    font-size: 2.1rem;
    font-weight: 500;
    color: var(--color-ink);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.cert-declaration {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--color-ink-muted);
    max-width: 680px;
    margin: 0 auto 12px;
}

/* Central split grid */
.cert-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    align-items: center;
    margin-bottom: 12px;
    flex: 1;
}

/* Image frame */
.cert-visual-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.cert-image-frame {
    width: 280px;
    height: 200px;
    border: 1px solid rgba(164, 109, 70, 0.25);
    background-color: #ffffff;
    padding: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
}

.cert-image-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cert-image-caption {
    font-size: 0.65rem;
    color: var(--color-ink-muted);
    font-style: italic;
}

/* Tech Specs Table */
.cert-specs-container {
    height: 100%;
    display: flex;
    align-items: center;
}

.specs-table {
    width: 100%;
    border-collapse: collapse;
}

.specs-table th,
.specs-table td {
    padding: 6px 10px;
    font-size: 0.8rem;
    line-height: 1.3;
    border-bottom: 1px solid rgba(164, 109, 70, 0.12);
}

.specs-table th {
    text-align: left;
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--color-bronze);
    width: 180px;
}

.specs-table td {
    font-family: var(--font-sans);
    color: var(--color-ink);
    font-weight: 300;
}

.specs-table tr:last-child th,
.specs-table tr:last-child td {
    border-bottom: none;
}

.highlight-text {
    font-family: var(--font-serif) !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
}

.italic-text {
    font-style: italic;
}

/* Historical Quote Block */
.cert-historical-quote {
    background-color: rgba(164, 109, 70, 0.03);
    border-top: 1px solid rgba(164, 109, 70, 0.15);
    border-bottom: 1px solid rgba(164, 109, 70, 0.15);
    padding: 10px 20px;
    margin-bottom: 14px;
    text-align: center;
}

.cert-historical-quote p {
    font-family: var(--font-serif);
    font-size: 0.72rem;
    line-height: 1.5;
    font-style: italic;
    color: #4a4a50;
}

/* Footer Section Grid */
.cert-footer-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: flex-end;
    gap: 15px;
    margin-top: auto;
}

.footer-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
}

.block-label {
    font-family: var(--font-sans);
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--color-ink-muted);
    text-transform: uppercase;
}

/* CSS Metallic Embossed Seal */
.seal-container {
    width: 70px;
    height: 70px;
    position: relative;
    border-radius: 50%;
    background: radial-gradient(circle, #fbf9f4 40%, #e2d9ca 75%, #cfa985 95%, #966b44 100%);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.7), 0 3px 8px rgba(164, 109, 70, 0.25);
    display: flex;
    justify-content: center;
    align-items: center;
}

.seal-inner {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 1px dashed rgba(150, 107, 68, 0.35);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.seal-text {
    position: absolute;
    width: 100%;
    height: 100%;
    animation: rotateSeal 20s linear infinite;
}

@keyframes rotateSeal {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.seal-center {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: radial-gradient(circle, #fcfaf6 20%, #ebdcc5 70%, #bca182 100%);
    border: 1px solid rgba(164, 109, 70, 0.4);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), inset 0 1px 2px rgba(255,255,255,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}

.seal-icon {
    opacity: 0.8;
}

/* QR Code styling */
.qr-wrapper {
    width: 65px;
    height: 65px;
    background-color: #ffffff;
    border: 1px solid rgba(164, 109, 70, 0.25);
    padding: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.qr-wrapper svg,
.qr-wrapper img {
    width: 100% !important;
    height: 100% !important;
}

/* Signature block */
.signature-area {
    width: 100%;
    max-width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.signature-container {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}

.signature-svg {
    color: #1a1a1c;
    display: block;
    height: 100%;
}

.signature-line {
    width: 100%;
    height: 1px;
    background-color: var(--color-ink-muted);
    opacity: 0.6;
    margin-bottom: 4px;
}

.signature-meta {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    color: var(--color-ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Preloader Screen --- */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.preloader-content {
    text-align: center;
}

.spark-circle {
    width: 50px;
    height: 50px;
    border: 3px solid transparent;
    border-top: 3px solid var(--color-rust);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: spin 1s linear infinite;
}

.preloader-title {
    font-size: 1.8rem;
    font-family: var(--font-serif);
    color: #ffffff;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.preloader-subtitle {
    font-size: 0.9rem;
    color: #a3a3ac;
    letter-spacing: 2px;
    text-transform: uppercase;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Responsive Adaptations (Screen-only) --- */
@media (max-width: 1366px) {
    .preview-pane {
        padding: 1.5rem;
    }
    
    /* Scale down the certificate visually in smaller desktops to fit screen view */
    .certificate-wrapper {
        transform: scale(0.85);
        transform-origin: top center;
        margin-bottom: -100px; /* offset the scale space gap */
    }
}

@media (max-width: 1100px) {
    .app-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--color-dark-border);
        box-shadow: none;
        overflow-y: visible;
    }
    
    .preview-pane {
        height: auto;
        padding: 3rem 1rem;
        overflow-y: visible;
    }
    
    .certificate-wrapper {
        transform: scale(0.72);
        margin-bottom: -180px;
    }
}

@media (max-width: 768px) {
    .certificate-wrapper {
        transform: scale(0.48);
        margin-bottom: -320px;
        min-width: 950px; /* Keep container layout stable, just let CSS transform shrink it */
    }
    
    .cert-header {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .certificate-wrapper {
        transform: scale(0.35);
        margin-bottom: -420px;
    }
}


/* ==========================================================================
   Print Stylesheet (@media print)
   Optimized for physical printer output on A4/Letter Landscape
   ========================================================================== */
@media print {
    /* Set page dimension to Landscape and hide default margin headers/footers */
    @page {
        size: A4 landscape;
        margin: 0;
    }

    html, body {
        background-color: #ffffff !important;
        color: #000000 !important;
        width: 297mm;
        height: 210mm;
        margin: 0;
        padding: 0;
        overflow: hidden;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Hide any interactive UI elements */
    .no-print,
    .cert-header,
    .sidebar,
    #preloader {
        display: none !important;
    }

    .app-container,
    .preview-pane {
        display: block !important;
        background: #ffffff !important;
        width: 297mm;
        height: 210mm;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    /* Reset scale transforming for actual printing output */
    .certificate-wrapper {
        transform: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 297mm !important;
        height: 210mm !important;
        min-width: auto !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        position: absolute;
        top: 0;
        left: 0;
    }

    .certificate {
        width: 297mm !important;
        height: 210mm !important;
        padding: 12mm !important; /* precise print padding */
        background-color: var(--color-paper) !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        border: none !important;
    }

    /* Keep the paper tint and metallic gradients visible on printers */
    .certificate::before {
        opacity: 0.02 !important;
    }
    
    .border-outer {
        top: 6mm !important;
        left: 6mm !important;
        right: 6mm !important;
        bottom: 6mm !important;
        border: 3px double var(--color-bronze) !important;
    }
    
    .border-inner {
        top: 1mm !important;
        left: 1mm !important;
        right: 1mm !important;
        bottom: 1mm !important;
    }

    .watermark-bg {
        width: 120mm !important;
        height: 120mm !important;
        opacity: 0.05 !important;
    }

    /* Layout structure adjustments for print sizing */
    .cert-header-title {
        margin-bottom: 2mm !important;
    }

    .artist-name {
        font-size: 1.5rem !important;
        letter-spacing: 6px !important;
    }

    .cert-main-title {
        font-size: 2.2rem !important;
        margin-bottom: 2mm !important;
    }

    .cert-declaration {
        font-size: 0.75rem !important;
        margin-bottom: 4mm !important;
    }

    .cert-grid {
        grid-template-columns: 85mm 1fr !important;
        gap: 8mm !important;
        margin-bottom: 4mm !important;
    }

    .cert-image-frame {
        width: 85mm !important;
        height: 60mm !important;
        border: 1px solid rgba(164, 109, 70, 0.25) !important;
        padding: 2mm !important;
    }

    .specs-table th,
    .specs-table td {
        padding: 2mm 3mm !important;
        font-size: 0.8rem !important;
    }

    .specs-table th {
        width: 45mm !important;
    }

    .cert-historical-quote {
        padding: 3mm 6mm !important;
        margin-bottom: 4mm !important;
    }

    .cert-historical-quote p {
        font-size: 0.72rem !important;
        line-height: 1.5 !important;
    }

    .cert-footer-row {
        margin-top: auto !important;
        gap: 10mm !important;
    }

    /* Print color properties adjustments */
    .seal-container {
        box-shadow: inset 0 2px 4px rgba(255,255,255,0.7), 0 3px 8px rgba(164, 109, 70, 0.15) !important;
    }

    /* Ensure text path elements render in high quality */
    text {
        fill: var(--color-bronze) !important;
    }

    /* Disable rotating animation during print to avoid formatting freeze glitches */
    .seal-text {
        animation: none !important;
        transform: rotate(-15deg) !important; /* Nice resting angle for print */
    }

    /* Ink properties */
    .signature-svg {
        color: #000000 !important;
    }
}
