/* HEIC vers JPG (ToolBox)
   =======================
   DA du site hôte : fond en dégradé violet, conteneur blanc arrondi et
   ombré, cartes blanches, accents indigo. Les couleurs de texte visent un
   contraste d'au moins 4.5 pour 1 sur leur fond. */

/* L'attribut hidden doit gagner sur tout display posé par une classe
   (le script masque bannières et boutons via el.hidden). */
[hidden] {
    display: none !important;
}

/* Reset et styles de base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1100px;
    margin: 20px auto;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.tool-content {
    padding: 20px 0;
    display: grid;
    gap: 20px;
}

/* Cartes */
.card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.card h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2em;
    font-weight: 600;
}

.card h3 i {
    color: #4f46e5;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.card-header h3 {
    margin-bottom: 0;
}

/* Introduction sous le h1 */
.intro-answer {
    font-size: 1.05em;
    line-height: 1.7;
    color: #2c3e50;
    background: linear-gradient(135deg, #f8f9ff 0%, #eef2ff 100%);
    border-left: 4px solid #4f46e5;
    border-radius: 8px;
    padding: 18px 20px;
}

/* Message de confidentialité, volontairement très visible */
.privacy-note {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #e7f6ee;
    border: 1px solid #b7e0c6;
    border-left: 5px solid #1e7e34;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 20px;
    color: #14532d;
    font-size: 1.05em;
    line-height: 1.5;
}

.privacy-note i {
    color: #1e7e34;
    font-size: 20px;
    flex-shrink: 0;
}

/* Zone de dépôt */
.dropzone {
    border: 3px dashed #4f46e5;
    border-radius: 12px;
    background: #f8f9ff;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.dropzone:hover {
    background: #eef2ff;
}

.dropzone:focus-visible {
    outline: 3px solid #4338ca;
    outline-offset: 3px;
}

.dropzone.is-dragover {
    background: #e0e7ff;
    border-color: #4338ca;
}

.dropzone > i {
    font-size: 44px;
    color: #4f46e5;
    margin-bottom: 12px;
    display: inline-block;
}

.dropzone-main {
    font-size: 1.1em;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 6px;
}

.dropzone-sub {
    color: #595959;
    font-size: 0.95em;
}

.picker-row {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0 0 0 0);
    overflow: hidden;
    white-space: nowrap;
}

/* Statut du chargement paresseux de la bibliothèque */
.lib-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 0.95em;
}

.lib-status--loading {
    background: #eef2ff;
    color: #3730a3;
}

.lib-status--error {
    background: #fdf2f2;
    color: #b02a37;
}

.lib-status .lib-icon-loading,
.lib-status .lib-icon-error {
    display: none;
}

.lib-status--loading .lib-icon-loading {
    display: inline-block;
}

.lib-status--error .lib-icon-error {
    display: inline-block;
}

/* Options */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.format-fieldset {
    border: none;
}

.format-fieldset legend {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    margin-bottom: 10px;
}

.format-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #2c3e50;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.format-choice:hover {
    border-color: #4f46e5;
    background: #f8f9ff;
}

.format-choice input {
    accent-color: #4f46e5;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.format-choice input:focus-visible {
    outline: 3px solid #4338ca;
    outline-offset: 2px;
}

.quality-group label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    margin-bottom: 12px;
}

.quality-group output {
    color: #3730a3;
    font-weight: 700;
}

.quality-group input[type="range"] {
    width: 100%;
    accent-color: #4f46e5;
    cursor: pointer;
}

.quality-group input[type="range"]:focus-visible {
    outline: 3px solid #4338ca;
    outline-offset: 4px;
}

.quality-group.is-disabled label,
.quality-group.is-disabled output {
    color: #595959;
}

.quality-group.is-disabled input[type="range"] {
    cursor: not-allowed;
    opacity: 0.5;
}

.quality-hint {
    margin-top: 8px;
    font-size: 0.85em;
    color: #595959;
}

/* Boutons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(145deg, #4f46e5, #4338ca);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:focus-visible {
    outline: 3px solid #4338ca;
    outline-offset: 2px;
}

.btn:disabled {
    background: #adb5bd;
    color: #ffffff;
    cursor: not-allowed;
    box-shadow: none;
}

.btn.btn-secondary {
    background: linear-gradient(145deg, #5f676e, #495057);
}

.btn.btn-secondary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(73, 80, 87, 0.3);
}

.btn.btn-secondary:disabled {
    background: #adb5bd;
}

.btn.btn-success {
    background: linear-gradient(145deg, #1e7e34, #186429);
}

.btn.btn-success:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(30, 126, 52, 0.3);
}

.btn.btn-success:disabled {
    background: #adb5bd;
}

.btn-download {
    padding: 10px 16px;
    font-size: 13px;
}

/* Liste des résultats */
.results-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.queue-status {
    color: #3730a3;
    font-size: 0.95em;
    margin-bottom: 12px;
    min-height: 1.2em;
    overflow-wrap: anywhere;
}

.results-list {
    list-style: none;
    display: grid;
    gap: 12px;
}

.result-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 15px;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-left: 4px solid #adb5bd;
    border-radius: 8px;
    padding: 12px 15px;
}

.result-card.is-converting {
    border-left-color: #4f46e5;
}

.result-card.is-done {
    border-left-color: #1e7e34;
}

.result-card.is-error {
    border-left-color: #b02a37;
    background: #fdf2f2;
}

.result-thumb {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.result-thumb i {
    color: #595959;
    font-size: 24px;
}

.result-thumb img {
    max-width: 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.result-info {
    min-width: 0;
}

.result-name {
    font-weight: 600;
    color: #2c3e50;
    overflow-wrap: anywhere;
    margin-bottom: 4px;
}

.result-sizes {
    color: #595959;
    font-size: 0.9em;
    margin-bottom: 4px;
}

.result-status {
    font-size: 0.9em;
    color: #595959;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.result-card.is-converting .result-status {
    color: #3730a3;
}

.result-card.is-done .result-status {
    color: #1e7e34;
}

.result-card.is-error .result-status {
    color: #b02a37;
}

.result-note {
    margin-top: 6px;
    padding: 6px 10px;
    background: #fff3cd;
    border-radius: 6px;
    color: #7a4f01;
    font-size: 0.85em;
    display: inline-block;
}

.empty-state {
    text-align: center;
    color: #595959;
    font-style: italic;
    padding: 30px 20px;
}

/* Contenu éditorial et FAQ */
.content-card h2 {
    color: #2c3e50;
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.4;
}

.content-card h2 i {
    color: #4f46e5;
    flex-shrink: 0;
}

.content-card p,
.content-card li {
    line-height: 1.7;
    color: #333;
    margin-bottom: 12px;
}

.content-card ul,
.content-card ol {
    padding-left: 25px;
    margin-bottom: 12px;
}

.content-card p:last-child {
    margin-bottom: 0;
}

.faq-q {
    color: #2c3e50;
    font-size: 1.05em;
    font-weight: 600;
    margin: 20px 0 8px;
}

.faq-q:first-of-type {
    margin-top: 0;
}

/* Responsive : une colonne sous 768px, aucun débordement horizontal */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
        border-radius: 10px;
    }

    .card {
        padding: 18px;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn {
        justify-content: center;
    }

    .result-card {
        grid-template-columns: auto 1fr;
    }

    .result-actions {
        grid-column: 1 / -1;
    }

    .result-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .dropzone {
        padding: 30px 15px;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 10px 15px;
        font-size: 13px;
    }

    .result-thumb {
        width: 56px;
        height: 56px;
    }
}

/* Impression : on ne garde que l'essentiel */
@media print {
    body {
        background: white;
    }

    .container {
        box-shadow: none;
        margin: 0;
    }

    .dropzone,
    .picker-row,
    .results-actions,
    .result-actions {
        display: none;
    }
}
