/* ==========================================================================
   Calculadora de Plafón Poliestireno 61×122 — Styles
   Prefix: cpe-
   ========================================================================== */

/* -------------------------------------------------------------------------
   1. CSS Variables
   ------------------------------------------------------------------------- */
.cpe-container {
    --rfc-primary: #1e3a8a;
    --rfc-primary-hover: #1e40af;
    --rfc-accent: #f97316;
    --rfc-bg: #f8fafc;
    --rfc-bg-alt: #e2e8f0;
    --rfc-text: #1e293b;
    --rfc-text-light: #64748b;
    --rfc-border: #cbd5e1;
    --rfc-radius: 6px;
    --rfc-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --rfc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --rfc-font-mono: 'SF Mono', 'Fira Code', monospace;

    font-family: var(--rfc-font);
    color: var(--rfc-text);
    background: var(--rfc-bg);
    padding: 24px;
    border-radius: var(--rfc-radius);
    max-width: 100%;
    margin: 0 auto;
    box-shadow: var(--rfc-shadow);
    box-sizing: border-box;
}

/* -------------------------------------------------------------------------
   2. Reset
   ------------------------------------------------------------------------- */
.cpe-container *,
.cpe-container *::before,
.cpe-container *::after {
    box-sizing: border-box;
}

.cpe-container p { margin: 0; }

/* -------------------------------------------------------------------------
   3. Business Header (hidden on screen, shown in PDF)
   ------------------------------------------------------------------------- */
.cpe-business-header {
    background: #fff;
    padding: 20px;
    border-bottom: 2px solid var(--rfc-primary);
    margin-bottom: 30px;
    display: none;
}

.cpe-biz-columns {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.cpe-biz-logo { width: 250px; }
.cpe-biz-logo img { max-width: 250px; display: block; }

.cpe-biz-info {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--rfc-text);
}

.cpe-quotation-meta { text-align: right; }
.cpe-quotation-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--rfc-primary);
    margin-bottom: 5px;
}
.cpe-date, .cpe-currency {
    font-size: 0.9rem;
    color: var(--rfc-text-light);
}

/* -------------------------------------------------------------------------
   4. Screen Header
   ------------------------------------------------------------------------- */
.cpe-header {
    text-align: center;
    margin-bottom: 24px;
}

.cpe-header-brand img {
    max-width: 250px;
    display: block;
    margin: 0 auto 15px;
}

.cpe-header h2 {
    margin: 0 0 8px 0;
    color: var(--rfc-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.cpe-header p {
    margin: 0;
    color: var(--rfc-text-light);
    font-size: 0.95rem;
}

/* -------------------------------------------------------------------------
   5. Input Section
   ------------------------------------------------------------------------- */
.cpe-input-section {
    background: #fff;
    padding: 20px;
    border-radius: var(--rfc-radius);
    border: 1px solid var(--rfc-border);
    margin-bottom: 24px;
}

/* -------------------------------------------------------------------------
   6. Tabs
   ------------------------------------------------------------------------- */
.cpe-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--rfc-bg-alt);
}

.cpe-tab {
    background: transparent;
    border: none;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--rfc-text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s ease, border-color 0.2s ease;
    font-family: var(--rfc-font);
}

.cpe-tab:hover { color: var(--rfc-primary); }
.cpe-tab.active {
    color: var(--rfc-primary);
    border-bottom-color: var(--rfc-accent);
}

/* -------------------------------------------------------------------------
   7. Input Groups
   ------------------------------------------------------------------------- */
.cpe-input-group { display: none; }
.cpe-input-group.active { display: block; }

.cpe-input-group label {
    display: block;
    margin-bottom: 6px;
    margin-top: 12px;
    font-weight: 500;
    font-size: 0.95rem;
}
.cpe-input-group label:first-child { margin-top: 0; }

.cpe-input-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--rfc-border);
    border-radius: var(--rfc-radius);
    font-size: 1rem;
    font-family: var(--rfc-font);
    transition: border-color 0.2s ease;
}

.cpe-input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--rfc-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.cpe-dim-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.cpe-dim-result {
    margin-top: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--rfc-primary);
    background: rgba(30, 58, 138, 0.05);
    padding: 12px;
    border-radius: var(--rfc-radius);
    text-align: center;
}

/* -------------------------------------------------------------------------
   8. Options Row
   ------------------------------------------------------------------------- */
.cpe-options-row {
    display: flex;
    align-items: center;
    margin-top: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.cpe-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cpe-option label {
    font-size: 0.85rem;
    color: var(--rfc-text-light);
    white-space: nowrap;
}

.cpe-option select,
.cpe-option input[type="number"] {
    padding: 6px 10px;
    border: 1px solid var(--rfc-border);
    border-radius: 4px;
    font-size: 0.9rem;
    background: #fff;
    font-family: var(--rfc-font);
}

.cpe-option input[type="number"] { width: 100px; }

.cpe-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.cpe-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* -------------------------------------------------------------------------
   9. SVG Container
   ------------------------------------------------------------------------- */
.cpe-svg-container {
    background: #fff;
    border: 1px solid var(--rfc-border);
    border-radius: var(--rfc-radius);
    padding: 20px;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #fcfcfc, #f1f5f9);
    margin-bottom: 24px;
}

.cpe-svg-container svg {
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.1));
}

.cpe-svg-placeholder {
    text-align: center;
    padding: 40px;
    color: var(--rfc-text-light);
    font-style: italic;
}

/* -------------------------------------------------------------------------
   10. Results Section
   ------------------------------------------------------------------------- */
.cpe-results {
    background: #fff;
    padding: 24px;
    border-radius: var(--rfc-radius);
    border: 1px solid var(--rfc-border);
    margin-bottom: 24px;
}

.cpe-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.cpe-results-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--rfc-primary);
}

.cpe-area-badge {
    background: var(--rfc-accent);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* -------------------------------------------------------------------------
   11. Table
   ------------------------------------------------------------------------- */
.cpe-table-wrapper { overflow-x: auto; }

.cpe-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.cpe-table th {
    background: var(--rfc-bg);
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--rfc-text);
    border-bottom: 2px solid var(--rfc-border);
    font-size: 0.85rem;
}

.cpe-table td {
    padding: 8px;
    border-bottom: 1px solid var(--rfc-border);
}

.cpe-table th:nth-child(1),
.cpe-table td:nth-child(1) { width: 42%; }

.cpe-table th:nth-child(2),
.cpe-table td:nth-child(2) {
    width: 12%;
    text-align: center;
}

.cpe-table th:nth-child(3),
.cpe-table td:nth-child(3) {
    width: 12%;
    text-align: center;
}

.cpe-table th:nth-child(4),
.cpe-table td:nth-child(4) {
    width: 17%;
    text-align: right;
}

.cpe-table th:nth-child(5),
.cpe-table td:nth-child(5) {
    width: 17%;
    text-align: right;
}

.cpe-table tbody tr:nth-child(even) {
    background: rgba(248, 250, 252, 0.5);
}

.cpe-pdf-note {
    display: block;
    font-size: 0.78rem;
    color: var(--rfc-text-light);
    font-style: italic;
    line-height: 1.3;
}

/* -------------------------------------------------------------------------
   12. Footer Rows
   ------------------------------------------------------------------------- */
.cpe-text-right { text-align: right !important; }
.cpe-font-bold { font-weight: 600; }

.cpe-summary-row td {
    background: var(--rfc-bg);
    font-weight: 600;
    padding: 10px 8px;
}

.cpe-grand-total td {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--rfc-primary);
    border-top: 2px solid var(--rfc-border);
    background: rgba(30, 58, 138, 0.05);
    padding: 10px 8px;
}

/* -------------------------------------------------------------------------
   13. Footer Notes
   ------------------------------------------------------------------------- */
.cpe-footer-notes {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--rfc-text-light);
    font-style: italic;
    border-top: 1px solid var(--rfc-border);
    padding-top: 12px;
}

.cpe-footer-notes p { margin: 0 0 4px; }

.cpe-tutorial-box {
    margin-top: 15px;
    background: #fff;
    border: 1px solid var(--rfc-accent);
    padding: 12px;
    border-radius: var(--rfc-radius);
    text-align: center;
    font-style: normal;
}

.cpe-tutorial-box a {
    color: var(--rfc-accent);
    text-decoration: none;
    font-weight: 600;
}

.cpe-tutorial-box a:hover { text-decoration: underline; }

/* -------------------------------------------------------------------------
   14. PDF Button
   ------------------------------------------------------------------------- */
.cpe-actions { text-align: right; }

.cpe-btn-pdf {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--rfc-primary);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--rfc-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--rfc-font);
    transition: background 0.2s ease, transform 0.1s ease;
}

.cpe-btn-pdf:hover { background: var(--rfc-primary-hover); }
.cpe-btn-pdf:active { transform: scale(0.98); }

/* -------------------------------------------------------------------------
   15. Responsive — max-width 600px
   ------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .cpe-container { padding: 16px; }
    .cpe-dim-row { grid-template-columns: 1fr; }

    .cpe-results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .cpe-options-row {
        flex-direction: column;
        align-items: stretch;
    }

    .cpe-option {
        flex-direction: column;
        align-items: stretch;
    }

    .cpe-option input[type="number"] { width: 100%; }
    .cpe-business-header { display: none; }
    .cpe-table { font-size: 0.8rem; }
    .cpe-table th, .cpe-table td { padding: 6px 4px; }

    .cpe-table th:nth-child(1),
    .cpe-table td:nth-child(1) { width: 36%; }

    .cpe-table th:nth-child(2),
    .cpe-table td:nth-child(2),
    .cpe-table th:nth-child(3),
    .cpe-table td:nth-child(3) { width: 10%; }

    .cpe-table th:nth-child(4),
    .cpe-table td:nth-child(4),
    .cpe-table th:nth-child(5),
    .cpe-table td:nth-child(5) { width: 22%; }

    .cpe-btn-pdf {
        width: 100%;
        justify-content: center;
    }

    .cpe-header-brand img { max-width: 180px; }
}

@media (max-width: 480px) {
    .cpe-container { padding: 10px; }
    .cpe-header h2 { font-size: 1.15rem; }
    .cpe-header p { font-size: 0.85rem; }
    .cpe-input-section { padding: 14px; }
    .cpe-tab { font-size: 0.85rem; padding: 8px 10px; }
    .cpe-results { padding: 14px; }
    .cpe-results-header h3 { font-size: 1rem; }
    .cpe-table { font-size: 0.72rem; }
    .cpe-table th, .cpe-table td { padding: 4px 3px; }
    .cpe-grand-total td { font-size: 0.95rem; }
    .cpe-btn-pdf { font-size: 0.9rem; padding: 10px 16px; }
    .cpe-checkbox-label { font-size: 0.85rem; }
    .cpe-header-brand img { max-width: 160px; }
    .cpe-svg-container { padding: 10px; min-height: 150px; }
}

/* -------------------------------------------------------------------------
   16. Print Styles
   ------------------------------------------------------------------------- */
@media print {
    .cpe-header,
    .cpe-input-section,
    .cpe-tabs,
    .cpe-options-row,
    .cpe-svg-container,
    .cpe-actions,
    .cpe-btn-pdf,
    .cpe-tutorial-box,
    .cpe-footer-notes { display: none !important; }

    #wpadminbar, header, footer, nav, .sidebar, aside { display: none !important; }

    .cpe-container {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        background: none !important;
    }

    .cpe-business-header {
        display: block !important;
        margin-bottom: 25px !important;
        padding-bottom: 15px !important;
        border-bottom: 2px solid #1e3a8a !important;
    }

    .cpe-results {
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: none !important;
    }

    .cpe-table { font-size: 9pt; width: 100%; }
    .cpe-table th, .cpe-table td { padding: 3px 6px; }
    .cpe-table th { background: #f1f5f9 !important; }
    .cpe-summary-row td { background: #f8fafc !important; }
    .cpe-grand-total td {
        color: #1e3a8a !important;
        background: rgba(30, 58, 138, 0.05) !important;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    @page { size: letter; margin: 1.2cm; }
    body { margin: 0; padding: 0; }
}
