﻿/* ============================================
   CompressIO V2 — Design System complet
   Glassmorphism, animations, responsive
   ============================================ */

/* --- Variables & Base --- */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-card-hover: rgba(51, 65, 85, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.3);
    --accent-light: #60a5fa;
    --purple: #8b5cf6;
    --purple-glow: rgba(139, 92, 246, 0.3);
    --success: #10b981;
    --success-light: #34d399;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gradient-accent: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-success: linear-gradient(135deg, #10b981, #34d399);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    line-height: 1.6;
}

[data-theme="light"] body {
    background: linear-gradient(135deg, #eff6ff 0%, #faf5ff 50%, #ecfdf5 100%);
}

/* --- Glassmorphism --- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.glass-header {
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

[data-theme="light"] .glass-header {
    background: rgba(255, 255, 255, 0.85);
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-light), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Drop Zone --- */
.drop-zone {
    position: relative;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.03), rgba(139, 92, 246, 0.03));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: conic-gradient(from var(--border-angle, 0deg), transparent 25%, var(--accent) 50%, var(--purple) 75%, transparent 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s;
    animation: rotate-border 4s linear infinite;
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
    opacity: 1;
}

.drop-zone:hover,
.drop-zone.drag-over {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));
    box-shadow: 0 0 60px var(--accent-glow);
    transform: scale(1.005);
}

@keyframes rotate-border {
    to { --border-angle: 360deg; }
}

@property --border-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

/* --- Tool Cards --- */
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.tool-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--accent);
    box-shadow: 0 12px 40px rgba(59, 130, 246, 0.15), 0 0 0 1px var(--accent-glow);
}

.tool-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.tool-card .tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    transition: transform 0.3s;
}

.tool-card:hover .tool-icon {
    transform: scale(1.1) rotate(-3deg);
}

/* --- Input Fields --- */
.input-field {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.2s;
    outline: none;
}

.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* --- Custom Slider --- */
.slider {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--value, 80%), rgba(100, 116, 139, 0.3) var(--value, 80%), rgba(100, 116, 139, 0.3) 100%);
    outline: none;
    transition: background 0.15s;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 3px var(--accent);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 12px rgba(0,0,0,0.4), 0 0 0 4px var(--accent);
}

.slider::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 3px var(--accent);
    cursor: pointer; border: none;
}

/* --- Carte Image --- */
.image-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

/* --- Barre de progression --- */
.progress-bar-container {
    height: 4px;
    background: rgba(100, 116, 139, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-accent);
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}

.progress-bar-fill.done { background: var(--gradient-success); }
.progress-bar-fill.done::after { animation: none; }

/* --- Thumbnail --- */
.thumbnail {
    width: 64px; height: 64px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.thumbnail:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* --- Badges --- */
.badge-reduction { font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.badge-reduction.good { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-reduction.medium { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-reduction.low { background: rgba(239,68,68,0.15); color: #f87171; }

/* --- Comparaison avant/apres --- */
.compare-container { position: relative; overflow: hidden; border-radius: 12px; cursor: col-resize; user-select: none; }
.compare-container img { display: block; width: 100%; height: auto; }
.compare-after { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }
.compare-after img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }
.compare-slider-line { position: absolute; top: 0; bottom: 0; width: 3px; background: white; box-shadow: 0 0 10px rgba(0,0,0,0.5); z-index: 10; pointer-events: none; }
.compare-slider-handle { position: absolute; top: 50%; transform: translate(-50%,-50%); width: 40px; height: 40px; border-radius: 50%; background: white; box-shadow: 0 2px 10px rgba(0,0,0,0.4); z-index: 11; display: flex; align-items: center; justify-content: center; cursor: col-resize; }
.compare-label { position: absolute; top: 10px; padding: 4px 10px; border-radius: 6px; font-size: 0.7rem; font-weight: 600; background: rgba(0,0,0,0.6); color: white; backdrop-filter: blur(4px); z-index: 5; }
.compare-label-before { left: 10px; }
.compare-label-after { right: 10px; }

/* --- Toast --- */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: 12px; font-size: 0.875rem; font-weight: 500; backdrop-filter: blur(20px); border: 1px solid var(--border-color); animation: toast-in 0.3s ease-out; display: flex; align-items: center; gap: 8px; max-width: 360px; }
.toast-success { background: rgba(16,185,129,0.15); color: var(--success-light); border-color: rgba(16,185,129,0.3); }
.toast-error { background: rgba(239,68,68,0.15); color: #f87171; border-color: rgba(239,68,68,0.3); }
.toast-info { background: rgba(59,130,246,0.15); color: var(--accent-light); border-color: rgba(59,130,246,0.3); }

@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(30px); } }

/* --- Theme toggle --- */
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: block !important; }
[data-theme="dark"] .theme-icon-dark { display: block; }
[data-theme="dark"] .theme-icon-light { display: none; }

/* --- Boutons --- */
.btn-primary { display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px; border-radius: 12px; background: var(--gradient-accent); color: white; font-weight: 600; font-size: 0.875rem; border: none; cursor: pointer; transition: all 0.3s; text-decoration: none; }
.btn-primary:hover { box-shadow: 0 8px 25px var(--accent-glow); transform: translateY(-2px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-success { background: var(--gradient-success); }
.btn-success:hover { box-shadow: 0 8px 25px rgba(16,185,129,0.3); }
.btn-ghost { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 12px; background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-secondary); font-weight: 500; font-size: 0.875rem; cursor: pointer; transition: all 0.3s; }
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-hover); }
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #f87171; }

/* --- Select --- */
select.input-field { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; -webkit-appearance: none; appearance: none; padding-right: 36px; }
select.input-field option { background: var(--bg-secondary); color: var(--text-primary); }

/* --- Animations --- */
@keyframes fade-in-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes pulse-glow { 0%, 100% { box-shadow: 0 0 20px var(--accent-glow); } 50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px var(--purple-glow); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.animate-fade-in-up { animation: fade-in-up 0.5s ease-out both; }
.animate-slide-up { animation: slide-up 0.6s ease-out both; }
.animate-scale-in { animation: scale-in 0.3s ease-out both; }
.animate-float { animation: float 3s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }

/* --- Privacy badge --- */
.privacy-badge { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 50px; background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); color: var(--success-light); font-size: 0.8rem; font-weight: 500; }

/* --- Utilitaires --- */
.line-clamp-1 { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100,116,139,0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,0.5); }

/* --- Navigation --- */
.nav-link { padding: 6px 14px; border-radius: 8px; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); transition: all 0.2s; text-decoration: none; white-space: nowrap; }
.nav-link:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-link.active { color: var(--accent-light); background: rgba(59,130,246,0.1); }

/* --- Preset buttons --- */
.preset-btn { padding: 6px 14px; border-radius: 8px; font-size: 0.8rem; font-weight: 500; background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-secondary); cursor: pointer; transition: all 0.2s; }
.preset-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.preset-btn.active { background: rgba(59,130,246,0.15); border-color: var(--accent); color: var(--accent-light); }

/* --- Responsive --- */
@media (max-width: 640px) {
    .drop-zone { padding: 2rem 1rem; }
    .thumbnail { width: 48px; height: 48px; }
    .image-card { padding: 0.75rem; }
}


/* --- Navigation Dropdowns Desktop --- */
.nav-dropdown-container { position: relative; }
.nav-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.nav-dropdown.nav-dropdown-open {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.nav-dropdown-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.15s;
    font-size: 0.875rem;
}
.nav-dropdown-item:hover {
    background: rgba(59,130,246,0.08);
    color: var(--text-primary);
}
.nav-dropdown-item.active {
    background: rgba(59,130,246,0.12);
    color: var(--accent-light);
}

/* --- Mobile Menu --- */
.mobile-menu {
    position: fixed;
    top: 73px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 200;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.mobile-menu.mobile-menu-open {
    opacity: 1;
    pointer-events: auto;
}
.mobile-menu-content {
    padding: 1.5rem;
    max-width: 400px;
    margin: 0 auto;
}
.mobile-nav-category {
    margin-bottom: 1.5rem;
}
.mobile-nav-category-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
}
.mobile-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.15s;
}
.mobile-nav-link:hover, .mobile-nav-link:active {
    background: rgba(59,130,246,0.08);
    color: var(--text-primary);
}
.mobile-nav-link.active {
    background: rgba(59,130,246,0.12);
    color: var(--accent-light);
}

/* --- Cookie Banner --- */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    padding: 1rem;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.cookie-banner.cookie-banner-visible {
    transform: translateY(0);
}
.cookie-banner-content {
    max-width: 480px;
    margin: 0 auto;
    padding: 1.25rem;
    border-radius: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
}

/* --- Stats Cards (compress page) --- */
.stats-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem;
    border-radius: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
}
.stats-number {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
}

/* --- Toast mobile fix --- */
@media (max-width: 640px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
    .toast {
        max-width: 100%;
    }
}

/* --- Light theme footer links --- */
[data-theme="light"] footer a,
[data-theme="light"] footer button {
    color: #64748b;
}
[data-theme="light"] footer a:hover,
[data-theme="light"] footer button:hover {
    color: #334155;
}


/* Fix responsive mobile - pas de scroll horizontal */
html, body { overflow-x: hidden; max-width: 100vw; }
main { overflow-x: hidden; }
.pdf-item, .image-card, .result-card { overflow: hidden; max-width: 100%; }
.pdf-item * { min-width: 0; }
img, canvas, video { max-width: 100%; height: auto; }
p, span, h1, h2, h3, h4 { word-break: break-word; overflow-wrap: break-word; }