/* ============================================================
   ImageHost — Feuille de style principale
   Dark mode léger, design moderne et responsive
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg:            #0d1117;
    --bg-surface:    #161b22;
    --bg-card:       #21262d;
    --bg-hover:      #30363d;
    --border:        #30363d;
    --border-focus:  #58a6ff;
    --text:          #e6edf3;
    --text-muted:    #7d8590;
    --accent:        #58a6ff;
    --accent-hover:  #1f6feb;
    --success-bg:    #238636;
    --success-text:  #3fb950;
    --error:         #da3633;
    --error-text:    #f85149;
    --radius:        8px;
    --radius-lg:     12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    font-size: 15px;
}

/* ===== HEADER ===== */

.header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    text-decoration: none;
}

.header-brand svg { color: var(--accent); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger {
    background: transparent;
    color: var(--error-text);
    border-color: transparent;
}
.btn-danger:hover { background: rgba(248,81,73,.12); border-color: var(--error); }

.btn-copy {
    background: transparent;
    color: var(--accent);
    border-color: transparent;
}
.btn-copy:hover { background: rgba(88,166,255,.12); border-color: var(--accent); }

.btn-logout {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
    padding: 5px 12px;
    font-size: 13px;
}
.btn-logout:hover { color: var(--error-text); border-color: var(--error); }

.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 10px 14px; font-size: 15px; }

/* ===== CONTAINER ===== */

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 24px;
}

/* ===== UPLOAD ZONE ===== */

.upload-zone {
    background: var(--bg-surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 52px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 28px;
    -webkit-user-select: none;
    user-select: none;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(88,166,255,.05);
}

.upload-icon {
    width: 52px;
    height: 52px;
    color: var(--accent);
    margin: 0 auto 16px;
    transition: transform 0.2s;
}

.upload-zone.drag-over .upload-icon { transform: scale(1.12) translateY(-4px); }

.upload-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.upload-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.upload-subtitle strong { color: var(--accent); }

.upload-limits {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

#fileInput { display: none; }

/* Progress */
.upload-progress { display: none; margin-top: 20px; }
.upload-progress.active { display: block; }

.progress-bar-container {
    background: var(--bg-hover);
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    width: 0%;
    transition: width 0.25s ease;
}

.progress-text {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* ===== GALLERY HEADER ===== */

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

.gallery-count {
    font-size: 15px;
    color: var(--text-muted);
}
.gallery-count span { color: var(--text); font-weight: 600; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px 12px;
    min-width: 260px;
    transition: border-color 0.15s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    width: 100%;
    font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ===== IMAGE GRID ===== */

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

/* ===== IMAGE CARD ===== */

.image-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    animation: fadeUp 0.3s ease;
}

.image-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-focus);
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Thumbnail */
.image-thumb {
    width: 100%;
    height: 185px;
    overflow: hidden;
    background: var(--bg);
    cursor: zoom-in;
    position: relative;
}

.image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
    display: block;
}

.image-thumb:hover img { transform: scale(1.06); }

.open-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.45);
    opacity: 0;
    transition: opacity 0.2s;
    color: #fff;
}

.image-thumb:hover .open-icon { opacity: 1; }

/* Info */
.image-info { padding: 13px; }

.image-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.image-url {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 5px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    cursor: copy;
    transition: border-color 0.15s;
    display: block;
}
.image-url:hover { border-color: var(--accent); color: var(--accent); }

.image-actions {
    display: flex;
    gap: 6px;
}

/* ===== EMPTY STATE ===== */

.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    opacity: 0.25;
    display: block;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 6px;
    color: var(--text);
}

/* ===== ALERTS ===== */

.alert {
    padding: 11px 15px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid;
}
.alert-error  { background: rgba(218,54,51,.1); border-color: var(--error); color: var(--error-text); }
.alert-info   { background: rgba(88,166,255,.1); border-color: var(--accent); color: var(--accent); }

/* ===== LOGIN PAGE ===== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo svg { color: var(--accent); margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto; }
.login-logo h1 { font-size: 26px; font-weight: 700; }
.login-logo p  { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}
.form-input::placeholder { color: var(--text-muted); }

/* ===== TOAST NOTIFICATIONS ===== */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    min-width: 280px;
    max-width: 380px;
    border: 1px solid;
    animation: toastIn 0.3s ease;
    pointer-events: all;
    line-height: 1.4;
}

.toast svg { flex-shrink: 0; margin-top: 1px; }

.toast-success { background: #1a3d20; border-color: var(--success-text); color: #aef2b8; }
.toast-error   { background: #3d1a1a; border-color: var(--error-text);    color: #f9a8a8; }
.toast-info    { background: #1a2a3d; border-color: var(--accent);         color: #a8d0f9; }

.toast.fade-out { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn  { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:none; } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateX(16px); } }

/* ===== MODAL ===== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 440px;
    width: 100%;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:none; } }

.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.modal-body  { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== LIGHTBOX ===== */

.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 300;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 24px;
}
.lightbox-overlay.active { display: flex; }

.lightbox-overlay img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,.8);
}

/* ===== ONGLETS ===== */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    padding: 10px 10px 0;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    position: relative;
    bottom: -1px;
}

.tab-btn:hover { color: var(--text); background: var(--bg-hover); }

.tab-active {
    background: var(--bg-card) !important;
    color: var(--accent) !important;
    border-color: var(--border) !important;
    border-bottom-color: var(--bg-card) !important;
}

/* Quand les onglets sont là, la zone en dessous hérite du style "carte" */
.tabs + .upload-zone,
.tabs + * + .import-zone {
    border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
    border-top-left-radius: 0;
}

/* ===== IMPORT URL ===== */

.import-zone {
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
    padding: 40px 32px;
    margin-bottom: 28px;
    text-align: center;
}

.import-icon {
    color: var(--accent);
    margin: 0 auto 14px;
    opacity: 0.85;
}

.import-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.import-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.import-input-row {
    display: flex;
    gap: 10px;
    max-width: 640px;
    margin: 0 auto 10px;
}

.import-input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.import-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}

.import-input::placeholder { color: var(--text-muted); font-family: inherit; }

.import-hint {
    font-size: 12px;
    color: var(--text-muted);
}

kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 11px;
    font-family: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    line-height: 1.6;
}

.btn-paste {
    margin-top: 18px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s, border-color 0.15s;
}

.btn-paste:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.paste-kbd {
    font-size: 11px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--text-muted);
    margin-left: 2px;
}

/* ===== OVERLAY COLLER ===== */

.paste-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: toastIn .2s ease;
}

.paste-overlay-box {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    animation: modalIn .2s ease;
    outline: none; /* le focus est géré en interne */
}

.paste-overlay-icon {
    color: var(--accent);
    margin-bottom: 16px;
}

.paste-overlay-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
}

.paste-overlay-title strong {
    color: var(--accent);
    background: rgba(88,166,255,.12);
    padding: 2px 8px;
    border-radius: 5px;
    font-family: monospace;
}

.paste-overlay-sub {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 24px;
}

.paste-overlay-cancel {
    font-size: 13px;
}

.paste-textarea {
    display: block;
    width: 100%;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--bg-card);
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 14px;
    font-family: inherit;
    text-align: center;
    padding: 18px;
    outline: none;
    resize: none;
    cursor: default;
    caret-color: transparent;
}

.paste-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,.2);
    color: var(--text-muted);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 640px) {
    .container { padding: 16px; }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .image-thumb { height: 140px; }

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

    .search-box { min-width: 100%; }

    .header { padding: 0 16px; }

    .header-info { display: none; }

    .upload-zone { padding: 36px 16px; }

    .toast { min-width: auto; max-width: calc(100vw - 32px); }

    .toast-container { left: 16px; right: 16px; bottom: 16px; }
}
