/* ============================================================
   3D'CLYPSE Calculator ? CSS Premium
   Version: 1.0.0
   ============================================================ */

/* ---------- Variables ---------- */
:root {
    --tdclypse-orange:      #f05a00;
    --tdclypse-orange-dark: #d04e00;
    --tdclypse-orange-bg:   rgba(240, 90, 0, 0.07);
    --tdclypse-marine:      #0f2044;
    --tdclypse-bg:          #f8f9fa;
    --tdclypse-white:       #ffffff;
    --tdclypse-border:      #e0e0e0;
    --tdclypse-text:        #333333;
    --tdclypse-text-light:  #777777;
    --tdclypse-shadow:      0 4px 20px rgba(0, 0, 0, 0.08);
    --tdclypse-radius:      12px;
    --tdclypse-radius-sm:   8px;
    --tdclypse-transition:  all 0.25s ease;
}

/* ---------- Conteneur principal ---------- */
.tdclypse-calculator {
    /* BUG2 FIX: 2-column flex layout, full viewport, no scroll */
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    height: 80vh;
    max-height: 80vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    color: var(--tdclypse-text);
    background: var(--tdclypse-bg);
    border-radius: 0;
    position: relative;
    box-sizing: border-box;
}

.tdclypse-calculator *,
.tdclypse-calculator *::before,
.tdclypse-calculator *::after {
    box-sizing: border-box;
}
/* BUG2 FIX: Left column — viewer + price + button */
.tdclypse-left {
    flex: 0 0 55%;
    max-width: 55%;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    padding: 16px;
    gap: 12px;
    background: #111827;
}

.tdclypse-viewer-wrap,
#tdclypse-viewer-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    border-radius: var(--tdclypse-radius);
}

/* BUG2 FIX: Left footer — price + button under viewer */
.tdclypse-left-footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tdclypse-left-footer #tdclypse-section-price {
    margin-bottom: 0;
}

.tdclypse-left-footer #tdclypse-order-btn {
    width: 100%;
    padding: 14px;
    background: var(--tdclypse-orange);
    color: #fff;
    border: none;
    border-radius: var(--tdclypse-radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--tdclypse-transition);
    text-align: center;
}

.tdclypse-left-footer #tdclypse-order-btn:hover {
    background: var(--tdclypse-orange-dark);
    transform: translateY(-1px);
}

.tdclypse-left-footer #tdclypse-order-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* BUG2 FIX: Right column — config panel scrollable */
#tdclypse-config-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--tdclypse-white);
    border-left: 1px solid var(--tdclypse-border);
    scrollbar-width: thin;
    scrollbar-color: var(--tdclypse-orange) transparent;
}

.tdclypse-config-scroll {
    padding: 16px;
}

/* Price box in left footer - compact version */
.tdclypse-left-footer .tdclypse-price-box {
    margin: 0;
    padding: 12px 16px;
    border-radius: var(--tdclypse-radius-sm);
}

.tdclypse-left-footer #tdclypse-price {
    font-size: 1.6rem;
}



/* ---------- Zone Drag & Drop ---------- */
.tdclypse-dropzone {
    display: block;           /* label doit etre block */
    width: 100%;
    border: 2px dashed #cccccc;
    border-radius: var(--tdclypse-radius);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    background: var(--tdclypse-white);
    transition: var(--tdclypse-transition);
    animation: tdFadeIn 0.4s ease forwards;
    position: relative;
}

.tdclypse-dropzone:hover,
.tdclypse-dropzone.dragover,
.tdclypse-dropzone.tdclypse-drag-over {
    border-color: var(--tdclypse-orange);
    background: var(--tdclypse-orange-bg);
}

/* Le label et ses enfants ont pointer-events auto (clics natifs) */
/* Mais les enfants non-interactifs ne captent pas les drag events */
.tdclypse-dropzone .tdclypse-dropzone-icon,
.tdclypse-dropzone p,
.tdclypse-dropzone span,
.tdclypse-dropzone .tdclypse-format-badge {
    pointer-events: none;
}

.tdclypse-dropzone:hover .tdclypse-dropzone-icon svg,
.tdclypse-dropzone.dragover .tdclypse-dropzone-icon svg {
    color: var(--tdclypse-orange);
    stroke: var(--tdclypse-orange);
    transform: translateY(-6px) scale(1.05);
}

.tdclypse-dropzone p {
    margin: 16px 0 8px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--tdclypse-marine);
}

.tdclypse-dropzone span {
    font-size: 0.9rem;
    color: var(--tdclypse-text-light);
}

.tdclypse-dropzone input[type="file"] {
    display: none;
}

/* Clic sur toute la zone */
.tdclypse-dropzone label {
    position: absolute;
    inset: 0;
    cursor: pointer;
    border-radius: var(--tdclypse-radius);
}

/* ---------- Icone Upload ---------- */
.tdclypse-dropzone-icon {
    display: flex;
    justify-content: center;
    align-items: center;
}

.tdclypse-dropzone-icon svg {
    width: 64px;
    height: 64px;
    color: #cccccc;
    stroke: #cccccc;
    transition: var(--tdclypse-transition);
}

/* ---------- Zone Resultat ---------- */
.tdclypse-result {
    display: grid;
    grid-template-columns: 60% 40%;
    gap: 30px;
    animation: tdFadeIn 0.4s ease forwards;
}

/* ---------- Viewer 3D ---------- */
#tdclypse-viewer {
    /* BUG2 FIX: fill parent height, no fixed aspect-ratio */
    width: 100%;
    height: 100%;
    border-radius: var(--tdclypse-radius);
    overflow: hidden;
    background: #111111;
    box-shadow: var(--tdclypse-shadow);
}

#tdclypse-viewer canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ---------- Config Panel ---------- */
.tdclypse-config {
    /* BUG2 FIX: padding moved to .tdclypse-config-scroll */
    background: var(--tdclypse-white);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%;
}

/* ---------- Infos fichier ---------- */
.tdclypse-file-info {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--tdclypse-border);
}

.tdclypse-file-info .tdclypse-filename {
    font-size: 1rem;
    font-weight: 700;
    color: var(--tdclypse-marine);
    word-break: break-word;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tdclypse-file-info .tdclypse-filename svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: var(--tdclypse-orange);
    color: var(--tdclypse-orange);
}

.tdclypse-file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.tdclypse-file-meta span {
    font-size: 0.8rem;
    color: var(--tdclypse-text-light);
    background: var(--tdclypse-bg);
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tdclypse-file-meta span strong {
    color: var(--tdclypse-marine);
    font-weight: 600;
}

/* ---------- Sections ---------- */
.tdclypse-section {
    margin-bottom: 24px;
}

.tdclypse-section-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--tdclypse-marine);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

/* ---------- Boutons toggle materiau / remplissage ---------- */
.tdclypse-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.material-btn,
.infill-btn {
    border: 2px solid var(--tdclypse-border);
    border-radius: var(--tdclypse-radius-sm);
    padding: 10px 20px;
    background: var(--tdclypse-white);
    color: var(--tdclypse-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--tdclypse-transition);
    position: relative;
    white-space: nowrap;
}

.material-btn:hover,
.infill-btn:hover {
    border-color: var(--tdclypse-orange);
    color: var(--tdclypse-orange);
}

.material-btn.active,
.infill-btn.active {
    border-color: var(--tdclypse-orange);
    background: var(--tdclypse-orange-bg);
    color: var(--tdclypse-orange);
    font-weight: 600;
}

.material-btn .material-price,
.infill-btn .infill-pct {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--tdclypse-text-light);
    margin-top: 2px;
}

.material-btn.active .material-price,
.infill-btn.active .infill-pct {
    color: var(--tdclypse-orange);
    opacity: 0.8;
}

/* ---------- Quantite ---------- */
.tdclypse-quantity {
    display: flex;
    align-items: center;
    gap: 0;
    width: fit-content;
    border: 2px solid var(--tdclypse-border);
    border-radius: var(--tdclypse-radius-sm);
    overflow: hidden;
    transition: var(--tdclypse-transition);
}

.tdclypse-quantity:focus-within {
    border-color: var(--tdclypse-orange);
}

.tdclypse-qty-btn {
    background: var(--tdclypse-bg);
    border: none;
    padding: 10px 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--tdclypse-marine);
    transition: var(--tdclypse-transition);
    line-height: 1;
}

.tdclypse-qty-btn:hover {
    background: var(--tdclypse-orange);
    color: var(--tdclypse-white);
}

#tdclypse-quantity {
    width: 60px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--tdclypse-border);
    border-right: 1px solid var(--tdclypse-border);
    padding: 10px 4px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--tdclypse-marine);
    background: var(--tdclypse-white);
    -moz-appearance: textfield;
    outline: none;
}

#tdclypse-quantity::-webkit-outer-spin-button,
#tdclypse-quantity::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---------- Detail prix ---------- */
.tdclypse-price-breakdown {
    background: var(--tdclypse-bg);
    border-radius: var(--tdclypse-radius-sm);
    padding: 20px;
    margin-bottom: 20px;
    flex: 1;
}

.tdclypse-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--tdclypse-text-light);
}

.tdclypse-price-row:not(:last-child) {
    border-bottom: 1px dashed var(--tdclypse-border);
}

.tdclypse-price-row span:first-child {
    font-weight: 500;
}

.tdclypse-price-row span:last-child {
    font-weight: 600;
    color: var(--tdclypse-text);
}

.tdclypse-price-row.tdclypse-total {
    padding-top: 14px;
    margin-top: 4px;
    border-top: 2px solid var(--tdclypse-border);
    border-bottom: none;
}

.tdclypse-total span:first-child {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--tdclypse-marine);
}

.tdclypse-total span:last-child {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--tdclypse-orange);
}

/* ---------- Bouton Commander ---------- */
#tdclypse-order-btn {
    display: block;
    width: 100%;
    padding: 16px;
    background: var(--tdclypse-orange);
    color: var(--tdclypse-white);
    border: none;
    border-radius: var(--tdclypse-radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--tdclypse-transition);
    text-align: center;
    letter-spacing: 0.02em;
}

#tdclypse-order-btn:hover {
    background: var(--tdclypse-orange-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(240, 90, 0, 0.35);
}

#tdclypse-order-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ---------- Loading overlay ---------- */
.tdclypse-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(248, 249, 250, 0.92);
    border-radius: var(--tdclypse-radius);
    z-index: 10;
    gap: 16px;
    backdrop-filter: blur(4px);
}

.tdclypse-loading p {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--tdclypse-marine);
}

.tdclypse-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--tdclypse-border);
    border-top-color: var(--tdclypse-orange);
    border-radius: 50%;
    animation: tdSpin 0.75s linear infinite;
}

/* ---------- Resultats ---------- */
#tdclypse-results {
    margin-top: 24px;
}

/* BUG2 FIX: #tdclypse-config-panel overridden above in left column styles */

#tdclypse-config-panel.tdclypse-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ---------- Prix ---------- */
.tdclypse-price-box {
    background: linear-gradient(135deg, var(--tdclypse-marine) 0%, #1a3460 100%);
    border-radius: var(--tdclypse-radius);
    padding: 24px;
    text-align: center;
    margin: 24px 0;
}

.tdclypse-price-label {
    color: rgba(255,255,255,0.75);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

#tdclypse-price {
    color: #ffffff;
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

#tdclypse-price-note {
    color: rgba(255,255,255,0.7);
    font-size: 0.82rem;
    margin-top: 6px;
}

/* ---------- Messages d'erreur ---------- */
.tdclypse-error {
    background: #fff5f5;
    border: 1px solid #fca5a5;
    border-radius: var(--tdclypse-radius-sm);
    padding: 14px 18px;
    color: #dc2626;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    animation: tdFadeIn 0.3s ease forwards;
}

/* ---------- Badge format supporte ---------- */
.tdclypse-format-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--tdclypse-marine);
    color: var(--tdclypse-white);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    margin-top: 14px;
}

/* ---------- Animations ---------- */
@keyframes tdFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes tdPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.tdclypse-result {
    animation: tdFadeIn 0.4s ease forwards;
}

.tdclypse-price-breakdown {
    animation: tdFadeIn 0.3s ease forwards;
}

/* ---------- Responsive 768px ---------- */
@media (max-width: 768px) {
    .tdclypse-calculator {
        padding: 12px;
    }

    .tdclypse-dropzone {
        padding: 40px 20px;
    }

    .tdclypse-result {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    #tdclypse-viewer {
        width: 100%;
        aspect-ratio: 4 / 3;
    }

    .tdclypse-config {
        padding: 20px;
    }

    .material-btn,
    .infill-btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .tdclypse-total span:last-child {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .tdclypse-dropzone p {
        font-size: 1rem;
    }

    .tdclypse-btn-group {
        gap: 6px;
    }

    .material-btn,
    .infill-btn {
        padding: 7px 12px;
        font-size: 0.78rem;
    }
}


/* ── Neutraliser le wrapper .calculateur (padding:50px) ─────────────── */
.calculateur .tdclypse-calculator {
    margin: 0 -50px -50px -50px;
    width: calc(100% + 100px);
    border-radius: 0 0 24px 24px;
    overflow: hidden;
}

/* ── Left column ajustements ─────────────────────────────────────────── */
.tdclypse-left {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    padding: 12px !important;
    gap: 8px !important;
}
.tdclypse-left-footer {
    padding: 0 4px 4px 4px;
    gap: 8px;
}
.tdclypse-left-footer #tdclypse-order-btn {
    border-radius: 10px !important;
    margin: 0 !important;
}
.tdclypse-left .tdclypse-price-box {
    padding: 12px 16px !important;
}

/* ── Right column compact (éviter scroll) ───────────────────────────── */
.tdclypse-config-scroll {
    padding: 12px !important;
}
/* Scale slider visible */
#tdclypse-scale-slider {
    width: 100%;
    accent-color: var(--tdclypse-orange);
    cursor: pointer;
    margin: 4px 0;
}
#tdclypse-section-scale {
    margin-bottom: 12px !important;
}
.tdclypse-section {
    margin-bottom: 12px !important;
}
.tdclypse-section-label {
    margin-bottom: 6px !important;
    font-size: 0.78rem !important;
}
.tdclypse-file-info {
    margin-bottom: 12px !important;
    padding-bottom: 12px !important;
}
.tdclypse-file-meta {
    margin-top: 4px !important;
}
.material-btn, .tdclypse-infill-btn, .infill-btn {
    padding: 7px 12px !important;
    font-size: 0.82rem !important;
}
.tdclypse-btn-group {
    gap: 6px !important;
}
