/* ═══════════════════════════════════════════════════════════
   Pixora Viewer — Styles identiques au desktop Pixora
   Couleurs exactes de main.py (COLORS dict)
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg-primary:    #0f0f1a;
    --bg-secondary:  #1a1a2e;
    --bg-surface:    #16213e;
    --bg-elevated:   #1e1f35;
    --bg-card:       #1c1d32;
    --accent:        #7c5cfc;
    --accent-hover:  #9b7fff;
    --accent-light:  rgba(124,92,252,0.15);
    --text-primary:  #e8e8f0;
    --text-secondary:#9898b0;
    --text-muted:    #606078;
    --border:        #2a2b45;
    --border-hover:  #3e3f5c;
    --success:       #4ade80;
    --danger:        #f87171;
    --warning:       #fbbf24;
    --glass-bg:      rgba(26,26,46,0.85);
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html, body {
    width:100%; height:100%; overflow:hidden;
    font-family:'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background:var(--bg-primary);
    color:var(--text-primary);
    -webkit-tap-highlight-color:transparent;
    user-select:none; -webkit-user-select:none;
    display:flex; flex-direction:column;
    min-width:320px;
}

a { color:var(--accent); text-decoration:none; }
.hidden { display:none !important; }

/* ═══════════ TOP BAR (56px, #1a1a2e) ═══════════ */
#topbar {
    display:flex; align-items:center; gap:12px;
    padding:6px 16px; height:56px; flex-shrink:0;
    background:var(--bg-secondary);
    border-bottom:1px solid var(--border);
}

.app-title {
    display:flex; align-items:center;
    white-space:nowrap;
    text-decoration:none; color:inherit;
}
.app-title-img {
    height:22px; width:auto; display:block;
}

.btn-browse {
    padding:9px 22px;
    background:linear-gradient(180deg, #9b7fff 0%, #7c5cfc 45%, #7c5cfc 55%, #5a3fd8 100%);
    color:#fff; border:none; border-radius:25px;
    font-size:13px; font-weight:700; cursor:pointer;
    box-shadow:0 4px 16px rgba(124,92,252,0.35);
    transition:all 0.15s; white-space:nowrap;
}
.btn-browse:hover {
    background:linear-gradient(180deg, #b094ff 0%, #9b7fff 45%, #9b7fff 55%, #7a5aed 100%);
    box-shadow:0 6px 22px rgba(124,92,252,0.5);
}

.auth-widget {
    display:flex; flex-direction:column; align-items:center; gap:2px;
    flex-shrink:0;
}
.auth-user-label {
    font-size:11px; color:var(--text-secondary);
    max-width:160px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

.path-field {
    flex:1; min-width:0;
    background:rgba(255,255,255,0.04);
    border:1px solid var(--border); border-radius:18px;
    color:var(--text-secondary); font-size:12px;
    padding:8px 14px; outline:none; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

.btn-help {
    width:32px; height:32px; border-radius:50%;
    background:var(--accent-light); border:1px solid var(--border);
    color:var(--text-secondary); font-size:15px; font-weight:700;
    cursor:pointer; display:flex; align-items:center; justify-content:center;
    transition:all 0.15s;
}
.btn-help:hover { color:#fff; border-color:var(--accent); background:rgba(124,92,252,0.25); }

.dur-slider { width:140px; accent-color:var(--accent); }
.dur-spinbox {
    width:64px; padding:6px 8px; text-align:center;
    background:linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-surface) 100%);
    border:1px solid var(--border); border-radius:18px;
    color:var(--text-primary); font-size:13px; font-weight:600; outline:none;
}
.dur-spinbox:focus { border-color:var(--accent); }
.dur-spinbox::-webkit-inner-spin-button { -webkit-appearance:none; }

.lang-select {
    width:130px; padding:6px 8px;
    background:linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-surface) 100%);
    border:1px solid var(--border); border-radius:18px;
    color:var(--text-primary); font-size:12px; outline:none;
}
.lang-select option { background:var(--bg-elevated); color:var(--text-primary); }

/* ═══════════ MEDIA AREA (#0f0f1a) ═══════════ */
#media-area {
    flex:1; position:relative; overflow:hidden;
    background:var(--bg-primary);
    display:flex; align-items:center; justify-content:center;
}

#media-container {
    position:relative; width:100%; height:100%;
    display:flex; align-items:center; justify-content:center;
}

#media-image, #media-video {
    max-width:100%; max-height:100%; object-fit:contain;
    transition:opacity 350ms ease-in-out;
}
#media-image { display:none; }
#media-video { display:none; }

#counter {
    position:absolute; top:16px; left:50%; transform:translateX(-50%);
    font-size:14px; font-weight:600; color:#fff;
    background:rgba(15,15,26,0.88); padding:4px 16px;
    border-radius:12px; display:none; z-index:5;
    border:1px solid rgba(255,255,255,0.2);
    box-shadow:0 2px 10px rgba(0,0,0,0.4);
    text-shadow:0 1px 3px rgba(0,0,0,0.6);
}
#counter.muted { color:#fff; }
#counter.warning { color:var(--warning); background:rgba(0,0,0,0.75); }

#ad-overlay {
    position:absolute; top:16px; right:16px; z-index:5; display:none;
    max-width:320px; width:calc(100% - 32px);
    background:var(--glass-bg);
    backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px);
    border:1px solid rgba(251,191,36,0.25);
    border-radius:14px; padding:16px 18px;
    box-shadow:0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(251,191,36,0.08);
}
.ad-badge {
    display:inline-block; padding:3px 10px;
    background:rgba(251,191,36,0.15);
    color:var(--warning); border-radius:8px;
    font-size:11px; font-weight:700; text-transform:uppercase;
    letter-spacing:0.5px; margin-bottom:10px;
}
#ad-title {
    font-size:16px; font-weight:700; color:#fff;
    margin-bottom:12px; line-height:1.3;
}
.ad-cta {
    display:inline-flex; align-items:center; gap:6px;
    padding:8px 18px;
    background:linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
    color:#0f0f1a; border-radius:20px;
    font-size:13px; font-weight:700; text-decoration:none;
    transition:all 0.15s; box-shadow:0 4px 14px rgba(251,191,36,0.3);
}
.ad-cta:hover {
    background:linear-gradient(180deg, #fcd34d 0%, #fbbf24 100%);
    box-shadow:0 6px 20px rgba(251,191,36,0.45);
    color:#000;
}
.ad-cta::after { content:"→"; font-size:14px; }

/* ── Mobile : overlay minimal semi-transparent (style YouTube) ── */
@media (max-width:768px), (max-height:600px) {
    #ad-overlay {
        top:auto; bottom:8px; left:8px; right:auto;
        max-width:calc(100vw - 16px); width:auto;
        padding:6px 10px; border-radius:10px;
        display:flex; align-items:center; gap:8px; flex-wrap:nowrap;
    }
    .ad-badge {
        font-size:9px; padding:2px 6px; border-radius:5px;
        margin-bottom:0; flex-shrink:0; order:2;
        background:rgba(251,191,36,0.18);
    }
    #ad-title {
        font-size:11px; margin-bottom:0; flex:1; min-width:0; max-width:140px;
        white-space:nowrap; overflow:hidden; text-overflow:ellipsis; order:0;
        line-height:1.2;
    }
    .ad-cta {
        font-size:10px; padding:4px 8px; flex-shrink:0;
        box-shadow:0 2px 6px rgba(251,191,36,0.2); order:1;
        border-radius:14px;
    }
    .ad-cta::after { font-size:11px; }
}

/* Welcome overlay */
#welcome-overlay {
    position:absolute; inset:0;
    display:flex; align-items:center; justify-content:center;
    background:var(--bg-primary); z-index:10;
}
.welcome-card { text-align:center; padding:40px 24px; }
.welcome-card h1 {
    font-size:42px; font-weight:800; letter-spacing:-1px;
    background:linear-gradient(135deg, #7c5cfc, #a78bfa);
    -webkit-background-clip:text; -webkit-text-fill-color:transparent;
    background-clip:text; margin-bottom:12px;
}
.welcome-card p {
    color:var(--text-secondary); font-size:15px; margin-bottom:24px;
}

/* Loading state */
#welcome-overlay.loading .welcome-card h1 { display:none; }
#welcome-overlay.loading .welcome-card p { display:none; }
#welcome-overlay.loading .welcome-card .btn-primary { display:none; }
.loading-msg { display:none; }
#welcome-overlay.loading .loading-msg { display:block; }

.loading-spinner {
    display:inline-block; width:48px; height:48px; margin-bottom:20px;
    border:4px solid rgba(139,92,246,0.15); border-top-color:#8b5cf6;
    border-radius:50%; animation:spin 0.8s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }

.btn-primary {
    display:inline-block; padding:14px 32px;
    background:linear-gradient(180deg, #9b7fff 0%, #7c5cfc 45%, #7c5cfc 55%, #5a3fd8 100%);
    color:#fff; border:none; border-radius:25px;
    font-size:16px; font-weight:700; cursor:pointer;
    box-shadow:0 4px 20px rgba(124,92,252,0.35);
    transition:all 0.15s;
}
.btn-primary:hover {
    background:linear-gradient(180deg, #b094ff 0%, #9b7fff 45%, #9b7fff 55%, #7a5aed 100%);
    box-shadow:0 6px 28px rgba(124,92,252,0.5);
}

/* ═══════════ BOTTOM BAR ═══════════ */
#bottombar {
    flex-shrink:0; background:var(--bg-secondary);
    border-top:1px solid var(--border);
    padding:0 16px;
}

/* Progress section */
#progress-section {
    display:flex; align-items:center; gap:0;
    height:40px; padding:0;
}
#time-left, #time-right {
    width:42px; text-align:center;
    font-size:12px; color:var(--text-muted); flex-shrink:0;
}
#progress-track {
    flex:1; height:5px; margin:0 8px;
    background:var(--bg-elevated); border-radius:3px;
    overflow:hidden; display:flex; align-items:center;
}
#progress-fill {
    height:100%; width:0%;
    background:linear-gradient(90deg, var(--accent), #a78bfa);
    border-radius:3px; transition:width 0.1s linear;
}

/* Buttons section */
#buttons-section {
    display:flex; align-items:center; gap:8px;
    height:56px; padding:0 0 6px 0;
}
.stretch { flex:1; }
.gap-12 { width:12px; flex-shrink:0; }

.btn-ctrl {
    padding:8px 20px; border-radius:25px;
    font-size:13px; font-weight:600; cursor:pointer;
    transition:all 0.15s; white-space:nowrap; border:none;
}

/* Base button style */
.btn-base {
    background:linear-gradient(180deg,
        rgba(255,255,255,0.09) 0%,
        rgba(255,255,255,0.06) 45%,
        rgba(255,255,255,0.04) 55%,
        rgba(255,255,255,0.02) 100%);
    color:var(--text-primary);
    border-top:2px solid rgba(255,255,255,0.10);
    border-bottom:2px solid rgba(0,0,0,0.20);
    border-left:2px solid rgba(255,255,255,0.04);
    border-right:2px solid rgba(0,0,0,0.10);
}
.btn-base:hover {
    background:linear-gradient(180deg,
        rgba(255,255,255,0.15) 0%,
        rgba(255,255,255,0.11) 45%,
        rgba(255,255,255,0.08) 55%,
        rgba(255,255,255,0.05) 100%);
    border-top-color:rgba(255,255,255,0.18);
}
.btn-base:active {
    background:linear-gradient(180deg,
        rgba(0,0,0,0.15) 0%,
        rgba(0,0,0,0.08) 45%,
        rgba(0,0,0,0.04) 55%,
        rgba(0,0,0,0.02) 100%);
    padding:10px 20px 6px 20px;
    border-top:2px solid rgba(0,0,0,0.25);
    border-bottom:2px solid rgba(255,255,255,0.05);
}
.btn-base:disabled {
    background:rgba(255,255,255,0.02);
    color:var(--bg-surface);
    border-color:rgba(255,255,255,0.03);
}

/* Primary button style */
.btn-primary {
    background:linear-gradient(180deg, #9b7fff 0%, #7c5cfc 45%, #7c5cfc 55%, #5a3fd8 100%);
    color:#fff;
    border-top:2px solid rgba(255,255,255,0.20);
    border-bottom:2px solid rgba(0,0,0,0.20);
    border-left:2px solid rgba(255,255,255,0.08);
    border-right:2px solid rgba(0,0,0,0.10);
    font-weight:700;
}
.btn-primary:hover {
    background:linear-gradient(180deg, #b094ff 0%, #9b7fff 45%, #9b7fff 55%, #7a5aed 100%);
    border-top-color:rgba(255,255,255,0.30);
}
.btn-primary:active {
    background:linear-gradient(180deg, #4a2fbf 0%, #5a3fd8 45%, #6e50e8 100%);
    padding:10px 20px 6px 20px;
    border-top:2px solid rgba(0,0,0,0.30);
}

/* Status bar */
#statusbar {
    height:24px; display:flex; align-items:center;
    font-size:11px; color:var(--text-muted);
    padding:0 4px;
}

/* ═══════════ FULLSCREEN ═══════════ */
.btn-icon {
    display:inline-flex; align-items:center; justify-content:center;
    width:44px; padding:8px 0;
}
.btn-icon svg { display:block; flex-shrink:0; }
#btn-fullscreen .icon-compress { display:none; }

body.fullscreen #btn-fullscreen .icon-expand { display:none; }
body.fullscreen #btn-fullscreen .icon-compress { display:block; }

body.fullscreen #topbar,
body.fullscreen #progress-section,
body.fullscreen #statusbar,
body.fullscreen #counter { display:none !important; }

/* ═══════════ MODALS ═══════════ */
.modal-overlay {
    position:fixed; inset:0; z-index:2000;
    background:rgba(15,15,26,0.85); backdrop-filter:blur(8px);
    -webkit-backdrop-filter:blur(8px);
    display:flex; align-items:center; justify-content:center;
    padding:20px;
}
.modal-card {
    background:var(--bg-card); border:1px solid var(--border);
    border-radius:16px; padding:28px 24px;
    max-width:400px; width:100%; max-height:90vh; overflow-y:auto;
    box-shadow:0 24px 80px rgba(0,0,0,0.5);
    position:relative;
}
.modal-wide { max-width:520px; }
.modal-card h2 { font-size:20px; font-weight:700; color:#fff; margin-bottom:8px; text-align:center; }
.modal-card > p { color:var(--text-secondary); font-size:14px; text-align:center; margin-bottom:20px; }

.modal-close {
    position:absolute; top:12px; right:14px;
    width:32px; height:32px; border-radius:50%;
    background:rgba(255,255,255,0.06); border:1px solid var(--border);
    color:var(--text-secondary); font-size:20px; line-height:1;
    cursor:pointer; display:flex; align-items:center; justify-content:center;
    transition:all 0.15s; padding:0; z-index:5;
}
.modal-close:hover { color:#fff; background:rgba(255,255,255,0.12); border-color:var(--border-hover); }

/* Auth providers */
#auth-providers { display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
.btn-auth {
    display:flex; align-items:center; gap:12px;
    padding:12px 16px; border:1px solid var(--border);
    border-radius:12px; background:rgba(255,255,255,0.03);
    color:var(--text-primary); font-size:15px; font-weight:500;
    cursor:pointer; transition:all 0.2s;
}
.btn-auth:hover { background:rgba(255,255,255,0.06); border-color:var(--border-hover); }
.prov-icon {
    width:34px; height:34px; border-radius:50%;
    display:flex; align-items:center; justify-content:center;
    flex-shrink:0; overflow:hidden;
}
.btn-auth.google .prov-icon { background:#fff; }
.btn-auth.facebook .prov-icon { background:#1877f2; }
.btn-auth.messenger .prov-icon { background:linear-gradient(135deg, #00C6FF, #0078FF); }
.btn-auth.microsoft .prov-icon { background:#fff; }
.btn-auth.email .prov-icon { background:var(--accent); color:#fff; font-weight:700; font-size:15px; }

/* Email form */
#email-form { margin-bottom:12px; }
#email-form label { display:block; font-size:13px; color:var(--text-secondary); margin-bottom:6px; }
#email-input {
    width:100%; padding:12px 16px; background:rgba(255,255,255,0.05);
    border:1px solid var(--border); border-radius:10px;
    color:var(--text-primary); font-size:15px; outline:none; margin-bottom:10px;
}
#email-input:focus { border-color:var(--accent); }
.btn-primary-s {
    width:100%; padding:12px; margin-bottom:6px; border:none; border-radius:12px;
    background:var(--accent); color:#fff; font-size:15px; font-weight:600;
    cursor:pointer; transition:all 0.15s;
}
.btn-primary-s:hover { background:#8b6fff; }
.fb { font-size:13px; padding:6px 0; text-align:center; }
.fb.ok { color:var(--success); }
.fb.err { color:var(--danger); }
#otp-row { display:flex; gap:8px; justify-content:center; margin-bottom:14px; }
.otp-d {
    width:42px; height:52px; background:rgba(255,255,255,0.05);
    border:1px solid var(--border); border-radius:10px;
    color:var(--text-primary); font-size:24px; font-weight:700;
    text-align:center; outline:none; transition:border-color 0.15s;
}
.otp-d:focus { border-color:var(--accent); }
.btn-text { background:none; border:none; color:var(--text-secondary); font-size:13px; cursor:pointer; padding:6px 12px; border-radius:8px; }
.btn-text:hover { color:#fff; }
#btn-back-auth { margin-top:8px; }
#auth-status { font-size:13px; color:var(--text-secondary); }
#auth-email { color:var(--success); margin:0 4px; }
.btn-logout { background:none; border:none; color:var(--danger); font-size:12px; cursor:pointer; }

/* Account panel */
#account-panel {
    display:flex; flex-direction:column; align-items:center; gap:16px;
    padding:8px 0 4px 0;
}
.account-header {
    display:flex; flex-direction:column; align-items:center; gap:10px;
}
.account-avatar {
    width:72px; height:72px; border-radius:50%; object-fit:cover;
    border:3px solid var(--accent); box-shadow:0 0 20px rgba(124,92,252,0.25);
    background:var(--bg-surface);
}
.account-avatar-placeholder {
    width:72px; height:72px; border-radius:50%;
    background:var(--bg-surface); display:flex; align-items:center; justify-content:center;
    border:3px solid var(--accent); box-shadow:0 0 20px rgba(124,92,252,0.25);
}
#account-name {
    font-size:18px; font-weight:700; color:#fff; text-align:center;
    word-break:break-word;
}
.account-info {
    width:100%; background:rgba(255,255,255,0.03);
    border:1px solid var(--border); border-radius:12px;
    padding:12px 16px; display:flex; flex-direction:column; gap:10px;
}
.account-row {
    display:flex; justify-content:space-between; align-items:center;
    flex-wrap:wrap; gap:4px;
}
.account-label {
    font-size:12px; color:var(--text-muted); text-transform:uppercase;
    letter-spacing:0.5px; flex-shrink:0;
}
.account-value {
    font-size:14px; color:var(--text-primary); text-align:right;
    word-break:break-all; max-width:65%;
}
.account-provider-badge {
    display:inline-block; padding:3px 10px;
    background:var(--accent-light); color:var(--accent);
    border-radius:12px; font-size:13px; font-weight:600;
    word-break:normal; max-width:none;
}
.btn-logout-full {
    width:100%; padding:12px; border:none; border-radius:12px;
    background:rgba(248,113,113,0.12); color:var(--danger);
    font-size:14px; font-weight:600; cursor:pointer;
    transition:all 0.15s; margin-top:4px;
}
.btn-logout-full:hover {
    background:rgba(248,113,113,0.22);
}

/* Partners */
#partners-list { display:flex; flex-direction:column; gap:12px; margin-bottom:16px; }
.partner-card {
    display:flex; gap:12px; align-items:center; padding:14px;
    background:linear-gradient(135deg, rgba(124,92,252,0.08), rgba(167,139,250,0.05));
    border:1px solid var(--border); border-radius:14px; transition:all 0.2s;
}
.partner-card:hover { border-color:var(--accent); }
.partner-thumb { width:72px; height:72px; object-fit:cover; border-radius:10px; flex-shrink:0; }
.partner-info { flex:1; min-width:0; }
.partner-info h4 { font-size:14px; font-weight:600; color:#fff; margin-bottom:4px; }
.partner-info p { font-size:12px; color:var(--text-secondary); line-height:1.4; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.partner-info a { font-size:12px; color:var(--accent); }

/* Context menu */
#context-menu {
    position:fixed; z-index:3000;
    background:var(--bg-elevated); border:1px solid var(--border);
    border-radius:8px; padding:4px 0; min-width:180px;
    box-shadow:0 12px 40px rgba(0,0,0,0.4);
}
#context-menu ul { list-style:none; }
#context-menu li {
    padding:8px 14px; font-size:13px; color:var(--text-secondary);
    cursor:pointer; transition:all 0.1s;
}
#context-menu li:hover { background:var(--accent-light); color:#fff; }

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width:768px) {
    #topbar { gap:6px; padding:4px 8px; flex-wrap:wrap; height:auto; min-height:48px; }
    .app-title { display:flex; }
    .app-title-img { height:18px; width:auto; }
    .btn-browse { padding:6px 14px; font-size:12px; border-radius:20px; }
    .path-field { font-size:11px; padding:6px 10px; display:none; }
    .dur-slider { width:80px; }
    .dur-spinbox { width:52px; }
    .lang-select { width:80px; font-size:11px; }
    #buttons-section { gap:4px; flex-wrap:wrap; justify-content:center; height:auto; padding:4px 0 6px 0; }
    #buttons-section .stretch { display:none; }
    #buttons-section .gap-12 { width:100%; height:0; order:4; }
    .btn-ctrl { padding:6px 14px; font-size:12px; border-radius:18px; }
    #btn-prev { order:1; }
    #btn-next { order:2; }
    #btn-pause { order:3; }
    #btn-stop { order:5; }
    #btn-rotate-ccw { order:6; }
    #btn-rotate-cw { order:7; }
    #btn-fullscreen { order:8; width:38px; }
    /* Account panel mobile */
    #account-panel { gap:12px; padding:4px 0 0 0; }
    .account-avatar, .account-avatar-placeholder { width:56px; height:56px; }
    #account-name { font-size:16px; }
    .account-info { padding:10px 12px; gap:8px; }
    .account-value { font-size:13px; max-width:60%; }
}
