/* Calculateur Solaire – style proche de l’interface AFR */
.cs-wrapper {
    max-width: 920px;
    margin: 0 auto 2rem;
    padding: 1.75rem 2rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1a1a1a;
    line-height: 1.45;
}

.cs-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e8e8e8;
}

.cs-section:last-of-type {
    border-bottom: none;
}

.cs-section-title {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #222;
}

.cs-optional {
    font-weight: 400;
    font-size: 0.85em;
    color: #888;
}

.cs-grid {
    display: grid;
    gap: 1rem 1.25rem;
}

.cs-grid-2 {
    grid-template-columns: 1fr 1fr;
}

.cs-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 720px) {
    .cs-grid-2,
    .cs-grid-3 {
        grid-template-columns: 1fr;
    }
    .cs-wrapper {
        padding: 1.25rem;
    }
}

.cs-field {
    display: flex;
    flex-direction: column;
}

.cs-field label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: #333;
}

.cs-field input[type="text"],
.cs-field input[type="email"],
.cs-field input[type="number"],
.cs-field input[type="tel"],
.cs-field select,
.cs-field textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.cs-field input:focus,
.cs-field select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.cs-field input[type="file"] {
    font-size: 0.85rem;
}

.required {
    color: #dc2626;
}

.cs-help {
    margin: 0.3rem 0 0;
    font-size: 0.8rem;
    color: #6b7280;
}

.cs-photo-count {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: #6b7280;
}

.cs-surface-box {
    margin-top: 0.9rem;
    padding: 0.6rem 0.9rem;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #334155;
}

.cs-surface-box strong {
    color: #0f766e;
    font-size: 1.05rem;
}

/* Pièces */
.cs-piece-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.85rem;
}

.cs-piece-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.cs-piece-header strong {
    font-size: 0.95rem;
    color: #374151;
}

.cs-remove-piece {
    background: transparent;
    border: 1px solid #fca5a5;
    color: #dc2626;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cs-remove-piece:hover {
    background: #fef2f2;
}

/* Boutons */
.cs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.15rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, transform 0.1s;
}

.cs-btn-outline {
    background: #fff;
    color: #4f46e5;
    border: 1px solid #a5b4fc;
}

.cs-btn-outline:hover {
    background: #eef2ff;
}

.cs-btn-primary {
    background: #4f46e5;
    color: #fff;
    padding: 0.75rem 1.6rem;
    font-size: 1rem;
}

.cs-btn-primary:hover {
    background: #4338ca;
}

.cs-btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.cs-actions {
    text-align: left;
    margin-top: 0.5rem;
}

.cs-submit-help {
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
    color: #6b7280;
}

.cs-loading {
    margin-top: 0.85rem;
    color: #4f46e5;
    font-weight: 500;
}

.cs-message {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-weight: 500;
}

.cs-message.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.cs-message.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ===== Récapitulatif visuel ===== */
.cs-recap {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.cs-recap-title {
    margin: 0 0 1.25rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
    text-align: center;
}

.cs-recap-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
    .cs-recap-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.cs-recap-card {
    background: #fff;
    border-radius: 10px;
    padding: 1rem 0.85rem;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

.cs-recap-card.cs-recap-prod {
    border-top: 3px solid #4f46e5;
}

.cs-recap-card.cs-recap-eco {
    border-top: 3px solid #0d9488;
}

.cs-recap-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.cs-recap-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.cs-recap-value small {
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
}

.cs-recap-sub {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.2rem;
}

.cs-recap-costs h4 {
    margin: 1.1rem 0 0.5rem;
    font-size: 0.95rem;
    color: #334155;
}

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

.cs-recap-table td {
    padding: 0.4rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.cs-recap-table .cs-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.cs-recap-table .cs-subtotal td {
    font-weight: 600;
    border-bottom: 2px solid #cbd5e1;
    padding-top: 0.55rem;
}

.cs-recap-table .cs-aide {
    color: #0d9488;
    font-weight: 600;
}

.cs-recap-net {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding: 0.9rem 1.1rem;
    background: #0f766e;
    color: #fff;
    border-radius: 10px;
    font-size: 1.05rem;
}

.cs-recap-net strong {
    font-size: 1.35rem;
}

.cs-recap-note {
    margin: 0.85rem 0 0;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.45;
}


/* Empêche le nom de fichier long de casser la grille */
.cs-field input[type="file"] {
    max-width: 100%;
}

/* Actions buttons row */
.cs-actions-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.cs-btn-reset {
    background: #fff;
    color: #64748b;
    border: 1px solid #cbd5e1;
    padding: 0.7rem 1.2rem;
    font-size: 0.95rem;
}

.cs-btn-reset:hover {
    background: #f1f5f9;
    color: #334155;
    border-color: #94a3b8;
}

/* ===== Photos : input + aperçus (renforcé) ===== */
.cs-file-input {
    max-width: 100% !important;
    width: 100%;
    font-size: 0.8rem !important;
    box-sizing: border-box;
}

.cs-photo-preview {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.75rem;
    min-height: 0;
    visibility: visible !important;
    opacity: 1 !important;
}

.cs-preview-item {
    width: 80px;
    flex: 0 0 80px;
    text-align: center;
    background: #f8fafc;
    border-radius: 8px;
    padding: 4px;
    border: 1px solid #e2e8f0;
}

.cs-preview-item img,
.cs-preview-img {
    width: 72px !important;
    height: 72px !important;
    max-width: 72px !important;
    max-height: 72px !important;
    object-fit: cover !important;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    display: block !important;
    margin: 0 auto;
    background: #e2e8f0;
}

.cs-preview-placeholder {
    width: 72px;
    height: 72px;
    line-height: 72px;
    margin: 0 auto;
    background: #e2e8f0;
    border-radius: 6px;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 600;
}

.cs-preview-name {
    display: block;
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 76px;
    margin-left: auto;
    margin-right: auto;
}

.cs-field input[type="file"] {
    max-width: 100%;
}

/* Empêcher les thèmes de masquer nos previews */
#cs-calculateur .cs-photo-preview,
#cs-calculateur .cs-preview-item,
#cs-calculateur .cs-preview-img {
    display: flex;
}
#cs-calculateur .cs-preview-item {
    display: block;
}
#cs-calculateur .cs-preview-img {
    display: block !important;
}

/* Bouton supprimer sur chaque miniature */
.cs-preview-item {
    position: relative;
}

.cs-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #dc2626;
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.cs-preview-remove:hover {
    background: #b91c1c;
}

.cs-part-header {
    background: linear-gradient(90deg, #eef2ff, #f8fafc);
    border-radius: 10px;
    padding: 1rem 1.25rem !important;
    border: 1px solid #c7d2fe !important;
}
.cs-part-header .cs-section-title {
    color: #4338ca;
}

/* Diagnostics compteurs */
.cs-diag-box {
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}
.cs-diag-title {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}
.cs-diag-status {
    margin: 0 0 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.cs-diag-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    color: #334155;
}
.cs-diag-list li {
    margin-bottom: 0.25rem;
}
.cs-diag-ok {
    border-color: #6ee7b7;
    background: #ecfdf5;
}
.cs-diag-ok .cs-diag-status { color: #047857; }
.cs-diag-warn {
    border-color: #fcd34d;
    background: #fffbeb;
}
.cs-diag-warn .cs-diag-status { color: #b45309; }
.cs-diag-ko {
    border-color: #fca5a5;
    background: #fef2f2;
}
.cs-diag-ko .cs-diag-status { color: #b91c1c; }
.cs-diag-pending {
    border-color: #e2e8f0;
    background: #f8fafc;
}
.cs-diag-pending .cs-diag-status { color: #64748b; font-weight: 500; }
