/* === Themes dynamiques === */
:root {
    --accent-color: #64748b;
    --accent-hover: #475569;
    --accent-gradient-from: #64748b;
    --accent-gradient-to: #475569;
    --accent-gradient-hover-from: #7c8a9d;
    --accent-gradient-hover-to: #64748b;
}

[data-theme="youtube"] {
    --accent-color: #ef4444;
    --accent-hover: #dc2626;
    --accent-gradient-from: #dc2626;
    --accent-gradient-to: #b91c1c;
    --accent-gradient-hover-from: #ef4444;
    --accent-gradient-hover-to: #dc2626;
}

[data-theme="x"] {
    --accent-color: #1d9bf0;
    --accent-hover: #1a8cd8;
    --accent-gradient-from: #1d9bf0;
    --accent-gradient-to: #1a8cd8;
    --accent-gradient-hover-from: #3aabf8;
    --accent-gradient-hover-to: #1d9bf0;
}

[data-theme="tiktok"] {
    --accent-color: #ff0050;
    --accent-hover: #e6004a;
    --accent-gradient-from: #00f2ea;
    --accent-gradient-to: #ff0050;
    --accent-gradient-hover-from: #33f5ed;
    --accent-gradient-hover-to: #ff3371;
}

[data-theme="instagram"] {
    --accent-color: #E1306C;
    --accent-hover: #c9285f;
    --accent-gradient-from: #833ab4;
    --accent-gradient-to: #fcb045;
    --accent-gradient-hover-from: #9b4bc9;
    --accent-gradient-hover-to: #fdc066;
}

[data-theme="facebook"] {
    --accent-color: #1877f2;
    --accent-hover: #1565d8;
    --accent-gradient-from: #1877f2;
    --accent-gradient-to: #1565d8;
    --accent-gradient-hover-from: #3d8ff5;
    --accent-gradient-hover-to: #1877f2;
}

[data-theme="pornhub"] {
    --accent-color: #ff9000;
    --accent-hover: #e68200;
    --accent-gradient-from: #1b1b1b;
    --accent-gradient-to: #ff9000;
    --accent-gradient-hover-from: #2a2a2a;
    --accent-gradient-hover-to: #ffab40;
}

/* === Utilitaires theme === */
.theme-accent { color: var(--accent-color); }
.theme-accent-bg { background-color: var(--accent-color); }
.theme-border-accent { border-color: var(--accent-color); }

.theme-gradient {
    background: linear-gradient(to right, var(--accent-gradient-from), var(--accent-gradient-to));
}
.theme-gradient:hover {
    background: linear-gradient(to right, var(--accent-gradient-hover-from), var(--accent-gradient-hover-to));
}

.theme-transition {
    transition: all 0.3s ease;
}

.theme-focus:focus {
    --tw-ring-color: var(--accent-color);
    border-color: var(--accent-color);
}

.theme-spinner {
    border-bottom-color: var(--accent-color);
}

input:checked + .theme-checked-border {
    border-color: var(--accent-color);
    background-color: rgb(30 41 59);
}

/* === Icon X custom === */
.icon-x::before {
    content: "\1D54F";
    font-family: system-ui, sans-serif;
    font-weight: bold;
}

/* === Barre de progression === */
.progress-container {
    position: relative;
    width: 100%;
    height: 2.5rem;
    background: #1e293b;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #334155;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--accent-gradient-from), var(--accent-gradient-to));
    border-radius: 0.75rem;
    transition: width 0.3s ease;
    min-width: 0;
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* === Previsualisation === */
.preview-container {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
    margin-top: 0;
}

.preview-container.visible {
    max-height: 200px;
    opacity: 1;
    margin-top: 1rem;
}

.preview-thumbnail {
    width: 120px;
    min-width: 120px;
    height: 68px;
    border-radius: 0.5rem;
    object-fit: cover;
    background: #334155;
}

.preview-placeholder {
    width: 120px;
    min-width: 120px;
    height: 68px;
    border-radius: 0.5rem;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Animations succes/erreur === */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes checkmark-pop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.checkmark-pop {
    animation: checkmark-pop 0.4s ease-out forwards;
}

/* === Toast notification === */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1000;
    transition: bottom 0.3s ease;
    max-width: 90vw;
}

.toast.visible {
    bottom: 2rem;
}

.toast-error {
    background: #991b1b;
    color: white;
    border: 1px solid #dc2626;
}

/* === Canvas confetti === */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* === Historique panneau === */
.history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.history-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.history-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    max-width: 100%;
    height: 100%;
    background: #1e293b;
    z-index: 901;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #334155;
}

.history-panel.visible {
    right: 0;
}

.history-header {
    padding: 1.25rem;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

/* History item wrapper — contains the delete backdrop + sliding content */
.history-item-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 0.75rem;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                margin 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-item-wrapper.removing {
    max-height: 0 !important;
    opacity: 0;
    margin-top: 0;
    margin-bottom: 0;
    pointer-events: none;
}

/* Red delete backdrop revealed on swipe */
.history-delete-backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: linear-gradient(90deg, transparent 50%, #dc2626 75%, #b91c1c 100%);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 1.25rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.history-item-wrapper.swiping .history-delete-backdrop {
    opacity: 1;
}

.history-delete-backdrop i {
    color: white;
    font-size: 1.1rem;
    opacity: 0.9;
    transition: transform 0.2s ease;
}

.history-item-wrapper.swipe-past .history-delete-backdrop i {
    transform: scale(1.3);
}

/* The slidable foreground content */
.history-item {
    position: relative;
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    transition: background 0.2s, transform 0.15s ease;
    align-items: center;
    background: #1e293b;
    touch-action: pan-y;
    will-change: transform;
    z-index: 1;
}

.history-item:hover {
    background: #334155;
}

/* Desktop delete button — appears on hover */
.history-delete-btn {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: #94a3b8;
    border: none;
    background: none;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.history-delete-btn:hover {
    color: #ef4444;
    transform: scale(1.15);
}

@media (hover: hover) {
    .history-item-wrapper:hover .history-delete-btn {
        display: flex;
    }
}

.history-item-thumb {
    width: 64px;
    min-width: 64px;
    height: 36px;
    border-radius: 0.375rem;
    object-fit: cover;
    background: #334155;
}

.history-item-placeholder {
    width: 64px;
    min-width: 64px;
    height: 36px;
    border-radius: 0.375rem;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-footer {
    padding: 1rem;
    border-top: 1px solid #334155;
}

/* === Bouton historique badge === */
.history-btn {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
}

.history-btn:hover {
    transform: rotate(-15deg);
}

.history-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent-color);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* === Drag & drop === */
.drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    border: 3px dashed var(--accent-color);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.drop-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.dragging {
    transform: scale(1.02);
    transition: transform 0.2s ease;
}

/* === Responsive mobile (<640px) === */
@media (max-width: 639px) {
    body {
        align-items: flex-start;
        padding: 0;
    }

    #mainCard {
        max-width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 1rem;
        min-height: 100vh;
    }

    #pasteBtn span {
        display: none;
    }

    .preview-container .flex {
        flex-direction: column;
    }

    .preview-thumbnail,
    .preview-placeholder {
        width: 100%;
        min-width: unset;
        height: 120px;
    }

    #submitBtn {
        position: sticky;
        bottom: 1rem;
        z-index: 40;
    }

    .history-panel {
        width: 100%;
        right: -100%;
    }

    .quality-option,
    .type-option {
        min-height: 44px;
        padding: 0.5rem;
    }

    .quality-option span,
    .type-option span {
        font-size: 0.75rem;
    }

    #dlForm {
        gap: 1.25rem;
    }
}

/* === Paysage mobile === */
@media (max-width: 639px) and (orientation: landscape) {
    .preview-container .flex {
        flex-direction: row;
    }

    .preview-thumbnail,
    .preview-placeholder {
        width: 120px;
        min-width: 120px;
        height: 68px;
    }
}

/* === Easter egg PornHub modal === */
.pornhub-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.pornhub-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.pornhub-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
}

.pornhub-modal-card {
    position: relative;
    background: #1b1b1b;
    border: 2px solid #ff9000;
    border-radius: 1.5rem;
    padding: 2.5rem 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pornhub-modal.visible .pornhub-modal-card {
    transform: scale(1);
}

.pornhub-modal-bonk {
    font-size: 4rem;
    font-weight: 900;
    color: #ff9000;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 30px rgba(255, 144, 0, 0.4);
}

.pornhub-modal-emoji {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.pornhub-modal-text {
    color: #ccc;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.pornhub-modal-text strong {
    color: #ff9000;
}

.pornhub-modal-btn {
    background: #ff9000;
    color: #1b1b1b;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.pornhub-modal-btn:hover {
    background: #ffab40;
    transform: scale(1.05);
}

.pornhub-modal-btn:active {
    transform: scale(0.97);
}
