/* ============================================================================
 * TropEasy — refonte UX/UI des pages outils
 *
 * Surcharge volontaire des classes existantes (drop-zone, btn-primary,
 * progress-container, result-zone, error-zone, mode-card) afin de monter
 * en gamme sans toucher aux 17 templates héritiers de base_tool.html.
 *
 * Identité préservée : --primary #2563EB, --success #10B981, --accent #F59E0B.
 * Chargé APRÈS style.css → priorité supérieure dans la cascade.
 * ============================================================================ */

/* ---- Hero plus grand --------------------------------------------------- */
.tool-hero {
    padding: 3rem 1rem 1.5rem;
}
.tool-hero h1 {
    font-size: 2rem;
    line-height: 1.15;
    margin-bottom: 0.75rem;
}
.tool-hero p {
    font-size: 1.0625rem;
    max-width: 640px;
    margin: 0 auto;
}
@media (min-width: 720px) {
    .tool-hero h1 { font-size: 2.25rem; }
}

/* ---- Drop zone géante (skin) ------------------------------------------- */
.drop-zone {
    max-width: 720px;
    min-height: 260px;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--primary);
    background: #EFF6FF;
    box-shadow: var(--shadow);
    transition: border-color var(--transition), background var(--transition),
                transform var(--transition), box-shadow var(--transition);
}
.drop-zone:hover {
    border-color: var(--primary-dark);
    background: #DBEAFE;
}
.drop-zone.dragover {
    border-color: var(--primary-dark);
    border-width: 3px;
    background: #DBEAFE;
    transform: scale(1.01);
    box-shadow: var(--shadow-md);
}
.drop-zone .drop-icon {
    width: 96px;
    height: 96px;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border-radius: 24px;
    color: #fff;
    font-size: 2.75rem;       /* fallback emoji si SVG absent */
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
    transition: transform var(--transition);
}
.drop-zone.dragover .drop-icon {
    transform: scale(1.05);
}
.drop-zone .drop-icon svg {
    width: 56px;
    height: 56px;
    stroke: #fff;
    fill: none;
}
.drop-zone > p:first-of-type,
.drop-zone .drop-text {
    font-size: 1.375rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.375rem;
}
.drop-zone .drop-hint {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}
.drop-zone .drop-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.625rem 1.25rem;
    background: var(--bg-white);
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--transition);
    pointer-events: none;     /* le clic sur la zone gère la sélection */
}
.drop-zone:hover .drop-cta {
    background: var(--primary);
    color: #fff;
}

/* ---- File-card : remplace le simple .file-name texte ------------------- */
.drop-zone .file-name {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow);
    display: none;
    max-width: 460px;
    width: 100%;
    text-align: left;
    word-break: break-word;
}
.drop-zone .file-name.show {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.drop-zone .file-name.show::before {
    content: '';
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/><polyline points='14 2 14 8 20 8'/></svg>") center/20px no-repeat,
        #DC2626;
}
/* Quand un fichier est ajouté, on rapetisse la grosse icône drop pour
   laisser la file-card respirer. */
.drop-zone.has-file {
    min-height: 0;
    padding: 1.5rem 1.5rem 2rem;
}
.drop-zone.has-file .drop-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 0.5rem;
    border-radius: 14px;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.2);
}
.drop-zone.has-file .drop-icon svg {
    width: 28px;
    height: 28px;
}
.drop-zone.has-file > p:first-of-type,
.drop-zone.has-file .drop-text,
.drop-zone.has-file .drop-hint,
.drop-zone.has-file .drop-cta {
    display: none;
}

/* ---- Mode-cards (3 niveaux) — boost lisibilité ------------------------- */
.mode-cards {
    max-width: 720px;
    margin-bottom: 1.5rem;
}
.mode-card {
    padding: 1.25rem 1rem 1.125rem;
    border-width: 2px;
    transition: border-color var(--transition), background var(--transition),
                transform 150ms ease, box-shadow var(--transition);
}
.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.mode-card.active {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.mode-card .mode-title {
    font-size: 1.0625rem;
    margin-bottom: 0.25rem;
}
.mode-card .mode-desc {
    font-size: 0.8125rem;
    line-height: 1.35;
}
.mode-card .mode-icon {
    font-size: 1.75rem;
}
/* Indication de gain (~ -50%) */
.mode-card .mode-gain {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--primary);
}
/* Badge "Recommandée" (jaune accent) */
.mode-card .mode-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.125rem 0.625rem;
    background: var(--accent);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
    white-space: nowrap;
}

/* ---- CTA large (boost .btn-primary par défaut sur les pages outil) ----- */
.upload-form-wrapper .btn-primary,
form#upload-form .btn-primary,
form#crop-form .btn-primary,
.cta-xl {
    width: 100%;
    padding: 1.0625rem 1.5rem;     /* ~17px vertical */
    font-size: 1.0625rem;          /* 17px */
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
    justify-content: center;
    transition: background var(--transition), transform var(--transition),
                box-shadow var(--transition);
}
form#upload-form .btn-primary:hover,
form#crop-form .btn-primary:hover,
.cta-xl:hover {
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
    transform: translateY(-1px);
}
form#upload-form .btn-primary:disabled,
form#crop-form .btn-primary:disabled,
.cta-xl:disabled {
    background: var(--text-lighter);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}
form#upload-form .btn-primary > svg,
.cta-xl > svg {
    width: 22px;
    height: 22px;
}

/* ---- Loader circulaire ------------------------------------------------- */
.loader-circle {
    width: 64px;
    height: 64px;
    border: 5px solid #DBEAFE;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: tropeasy-spin 700ms linear infinite;
    margin: 0 auto;
}
.loader-block {
    max-width: 720px;
    margin: 0 auto 1.5rem;
    padding: 2rem 1rem;
    text-align: center;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: none;
}
.loader-block.show { display: block; }
.loader-block .loader-label {
    margin-top: 1rem;
    font-weight: 600;
    color: var(--text);
}
@keyframes tropeasy-spin {
    to { transform: rotate(360deg); }
}

/* ---- Progress bar (skin) ----------------------------------------------- */
.progress-container {
    max-width: 720px;
}
.progress-bar-bg { height: 10px; }
.progress-text {
    font-size: 0.9375rem;
    color: var(--text);
    font-weight: 600;
}

/* ---- Result-card (skin .result-zone) ----------------------------------- */
.result-zone {
    max-width: 720px;
    padding: 1.75rem 1.5rem;
    background: linear-gradient(180deg, #F0FDF4 0%, #ECFDF5 100%);
    border-color: #86EFAC;
    box-shadow: var(--shadow);
}
.result-zone .result-stats {
    font-size: 1.0625rem;
    color: var(--text);
    margin-bottom: 1rem;
}
.result-zone .result-stats strong {
    font-weight: 700;
}
.result-zone .btn-success,
.result-zone .btn-download {
    padding: 0.875rem 1.5rem;
    font-size: 1.0625rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.result-zone .btn-success:hover,
.result-zone .btn-download:hover {
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}

/* ---- Error-zone : on la masque, on remplace par toast ------------------ */
.error-zone {
    /* Reste pour compat upload.js, mais on cache puisque tool-redesign.js
       intercepte et redirige vers un toast. */
    display: none !important;
}
.error-zone.show {
    display: none !important;     /* upload.js add .show, on intercepte */
}

/* ---- Toasts ------------------------------------------------------------ */
.toast-container {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    pointer-events: none;
    max-width: calc(100vw - 3rem);
}
.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 420px;
    padding: 0.875rem 1rem;
    background: var(--bg-white);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    font-size: 0.9375rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    animation: tropeasy-toast-in 240ms ease-out;
}
.toast.toast--leaving {
    animation: tropeasy-toast-out 220ms ease-in forwards;
}
.toast .toast-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
}
.toast .toast-msg { flex: 1; line-height: 1.35; }
.toast .toast-close {
    flex-shrink: 0;
    background: none;
    border: 0;
    color: var(--text-lighter);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.125rem;
}
.toast--success { border-left-color: var(--success); }
.toast--success .toast-icon { color: var(--success); }
.toast--error { border-left-color: #DC2626; }
.toast--error .toast-icon { color: #DC2626; }
.toast--info { border-left-color: var(--primary); }
.toast--info .toast-icon { color: var(--primary); }
@keyframes tropeasy-toast-in {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes tropeasy-toast-out {
    to { transform: translateX(20px); opacity: 0; }
}

/* ---- File-list réorganisable (Fusionner PDF) -------------------------- */
.file-list--reorderable .file-item {
    cursor: grab;
    user-select: none;
}
.file-list--reorderable .file-item:active {
    cursor: grabbing;
}
.file-list--reorderable .file-item:hover {
    border-color: var(--primary-light);
}
.file-list--reorderable .file-item::before {
    content: '⋮⋮';
    color: var(--text-lighter);
    font-size: 0.875rem;
    letter-spacing: -2px;
    margin-right: 0.25rem;
    flex-shrink: 0;
}
.file-item--ghost {
    opacity: 0.4;
    background: var(--primary-light);
}
.file-item--chosen {
    box-shadow: var(--shadow-md);
}
.file-item--dragging {
    transform: rotate(-1deg);
}

/* ---- Reassurance footer ------------------------------------------------ */
.tool-reassurance {
    max-width: 720px;
    margin: 0 auto 2.5rem;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-light);
    font-size: 0.875rem;
    text-align: center;
}
.tool-reassurance svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--success);
}

/* ---- Responsive (mobile-first) ----------------------------------------- */
@media (max-width: 640px) {
    .tool-hero { padding: 2rem 1rem 1rem; }
    .tool-hero h1 { font-size: 1.625rem; }
    .drop-zone {
        min-height: 200px;
        padding: 2rem 1.25rem;
    }
    .drop-zone .drop-icon {
        width: 72px;
        height: 72px;
        border-radius: 18px;
    }
    .drop-zone .drop-icon svg {
        width: 38px;
        height: 38px;
    }
    .drop-zone > p:first-of-type,
    .drop-zone .drop-text {
        font-size: 1.125rem;
    }
    .mode-cards.cols-3 {
        grid-template-columns: 1fr;
    }
    .mode-card .mode-badge {
        position: static;
        transform: none;
        margin: 0 auto 0.5rem;
        display: inline-block;
    }
    .toast-container {
        right: 1rem;
        bottom: 1rem;
        left: 1rem;
        max-width: none;
    }
    .toast {
        min-width: 0;
        max-width: none;
    }
}
