/**
 * Send - CSS minimaliste
 */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #fff;
    --bg-alt: #f8f9fa;
    --text: #212529;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --primary: #212529;
    --primary-hover: #000;
    --danger: #dc3545;
    --success: #28a745;
    --warning: #ffc107;
    --radius: 4px;
    /* Fond des pages publiques le temps que l'image de fond charge */
    --backdrop: #111;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

/* Typography */
h1, h2, h3 { font-weight: 600; margin-bottom: 1rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

p { margin-bottom: 0.5rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code { background: var(--bg-alt); padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}

.btn:hover { background: var(--bg-alt); text-decoration: none; }

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

.btn-secondary { background: var(--bg-alt); }

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

.btn-block { display: block; width: 100%; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-sm { padding: 4px 8px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Radio & Checkbox */
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.radio-label input { width: auto; }

/* Alerts */
.alert {
    padding: 12px 16px;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    border: 1px solid;
}

.alert-error { background: #f8d7da; border-color: #f5c6cb; color: #721c24; }
.alert-success { background: #d4edda; border-color: #c3e6cb; color: #155724; }
.alert-warning { background: #fff3cd; border-color: #ffeeba; color: #856404; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 10px;
    background: var(--bg-alt);
}

.badge-active { background: #d4edda; color: #155724; }
.badge-paused { background: #fff3cd; color: #856404; }
.badge-deleted { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    background: var(--bg-alt);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover td { background: var(--bg-alt); }
.table tfoot .table-total td { font-weight: 600; border-top: 2px solid var(--border); background: var(--bg-alt); }
.table .col-check { width: 36px; }
.table .col-check input { width: auto; }
.bulk-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bulk-hint { margin-left: auto; font-size: 12px; }
.row-muted { opacity: 0.6; }
.user-agent { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }

/* Layout - Admin */
.admin-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--primary);
    color: #fff;
}

.nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
}

.nav-links { display: flex; gap: 16px; }

.nav-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
}
.nav-link:hover, .nav-link.active { color: #fff; text-decoration: none; }

.admin-main {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 { margin-bottom: 0; }

.section { margin-bottom: 32px; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
    background: var(--bg-alt);
    border-radius: var(--radius);
    text-align: center;
}

.stat-value { font-size: 32px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; }

.stats-grid-small .stat-value { font-size: 24px; }

/* Share URL Box */
.share-url-box {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.share-url-box input {
    flex: 1;
    font-family: monospace;
}

/* Actions */
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.actions { white-space: nowrap; }

/* Info List */
.info-list { display: grid; gap: 8px; }
.info-list dt { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
.info-list dd { margin-left: 0; margin-bottom: 8px; }

/* Edit Form */
.edit-form { max-width: 400px; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-alt);
}

.login-container { width: 100%; max-width: 360px; padding: 16px; }

.login-box {
    background: var(--bg);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.login-box h1 { text-align: center; margin-bottom: 4px; }
.login-box .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; }

/* Upload Page */
.upload-form { max-width: 600px; }

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--bg-alt);
}

.drop-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.file-list { margin: 16px 0; }
.file-list h3 { margin-bottom: 8px; }
.file-list ul { list-style: none; }

.file-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-alt);
    border-radius: var(--radius);
    margin-bottom: 4px;
}

.file-list .file-name { flex: 1; word-break: break-all; }
.file-list .file-size { color: var(--text-muted); font-size: 12px; }
.file-list .btn-remove {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
}
.file-list .btn-remove:hover { color: var(--danger); }

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

.form-section { margin: 24px 0; }

.input-with-prefix {
    display: flex;
    align-items: stretch;
}

.input-prefix {
    padding: 8px 12px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.input-with-prefix input {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.progress-section { margin: 24px 0; }

.progress-bar {
    height: 8px;
    background: var(--bg-alt);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0;
    transition: width 0.2s;
}

.progress-text {
    margin-top: 8px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.progress-files {
    list-style: none;
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.progress-file {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.progress-file:last-child { border-bottom: none; }
.progress-file .progress-bar { grid-column: 1 / -1; }
.progress-bar-sm { height: 4px; }

.progress-file-name { word-break: break-all; }
.progress-file-status { font-size: 12px; color: var(--text-muted); text-align: right; }
.progress-file-meta {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.progress-file.is-waiting { opacity: 0.6; }
.progress-file.is-sending .progress-file-status { color: var(--text); font-weight: 500; }
.progress-file.is-done .progress-fill { background: var(--success); }
.progress-file.is-done .progress-file-status { color: var(--success); }
.progress-file.is-rejected .progress-fill { background: var(--danger); }
.progress-file.is-rejected .progress-file-status { color: var(--danger); grid-column: 1 / -1; text-align: left; }

@media (prefers-reduced-motion: reduce) {
    .progress-fill { transition: none; }
}

.result-section { margin: 24px 0; }

.result-success {
    text-align: center;
    padding: 32px;
    background: var(--bg-alt);
    border-radius: var(--radius);
}

.result-success svg {
    width: 48px;
    height: 48px;
    color: var(--success);
    margin-bottom: 16px;
}

.result-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

/* Public Page */
.public-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-alt);
}

.download-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.download-box {
    background: var(--bg);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
}

.download-header {
    text-align: center;
    margin-bottom: 24px;
}

.download-header h1 { margin-bottom: 8px; }
.file-info { color: var(--text-muted); }

.password-form { text-align: center; }
.password-form p { margin-bottom: 16px; }

.btn-download-all { margin-bottom: 16px; }

.file-list-public {
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.file-list-public li { border-bottom: 1px solid var(--border); }
.file-list-public li:last-child { border-bottom: none; }

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s;
}

.file-item:hover { background: var(--bg-alt); text-decoration: none; }

.file-item .file-name { word-break: break-all; margin-right: 16px; }
.file-item .file-size { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.public-footer {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

/* Error Page */
.error-page .error-container {
    text-align: center;
}

.error-container h1 {
    font-size: 72px;
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-nav {
        flex-direction: column;
        gap: 12px;
    }

    .nav-links { flex-wrap: wrap; justify-content: center; }

    .admin-main { padding: 16px; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .table { font-size: 12px; }
    .table th, .table td { padding: 8px; }

    .share-url-box { flex-direction: column; }

    .action-buttons { flex-direction: column; }
    .action-buttons .btn { width: 100%; }
}

/* Personnalisation : image de fond et encart des pages publiques */
.page-wallpapers {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--backdrop);
}

/* La durée doit rester égale à WALLPAPER_FADE_MS (wallpaper-rotator.js) */
.page-wallpaper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

.page-wallpaper.is-visible { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .page-wallpaper { transition: none; }
}

.has-wallpaper { background: var(--backdrop); }

/* Sur une image quelconque, le texte n'est lisible que sur une surface pleine */
.has-wallpaper .public-footer p {
    display: inline-block;
    margin: 0;
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Bandeau en bas de page : dernier élément du flex de .public-page (min-height 100vh),
   donc collé au bas de l'écran sans jamais recouvrir la liste des fichiers */
.promo-card {
    width: 100%;
    padding: 12px 24px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 13px;
}

/* En ligne et non en flex : un texte saisi hors paragraphe deviendrait un élément
   flex à part, séparé du lien qui le suit par l'écart */
.promo-card h1,
.promo-card p { display: inline; margin: 0; }
.promo-card h1 { font-size: 13px; }
.promo-card p { color: var(--text-muted); }
.promo-card h1 + p,
.promo-card p + p { margin-left: 8px; }
.promo-card a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.promo-card a:hover { color: var(--primary-hover); }

.promo-align-left { text-align: left; }
.promo-align-center { text-align: center; }
.promo-align-right { text-align: right; }

@media (min-width: 900px) {
    .has-wallpaper .download-container { align-items: flex-start; padding: 48px 64px; }
    /* Aligné sur le bord gauche du bloc de téléchargement */
    .has-wallpaper .public-footer { padding: 16px 0; }
    .promo-card { padding: 12px 64px; }
}

.branding-page { max-width: 1400px; }

.branding-columns { display: grid; gap: 32px; }
@media (min-width: 1100px) {
    .branding-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; }
    .branding-preview-panel { position: sticky; top: 16px; }
}

.wallpaper-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.wallpaper-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-alt);
}

.wallpaper-item img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.wallpaper-remove { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: 12px; cursor: pointer; }
.wallpaper-remove input { width: auto; }
.wallpaper-item:has(input:checked) img { opacity: 0.35; }

.editor { border: 1px solid var(--border); border-radius: var(--radius); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.editor-toolbar-separator { width: 1px; margin: 2px 4px; background: var(--border); }
.editor-toolbar [aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.editor-area { min-height: 120px; padding: 12px; outline: none; }
.editor-area:focus { box-shadow: inset 0 0 0 1px var(--primary); }
.editor-area h1 { font-size: 1.25rem; margin-bottom: 6px; }
.editor-area p { margin-bottom: 6px; }
.editor-area a { text-decoration: underline; }

.branding-preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.branding-preview-header h3 { margin: 0; }

.preview-frame {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-alt);
}

.preview-frame iframe {
    position: absolute;
    top: 0;
    left: 0;
    border: 0;
    transform-origin: 0 0;
}
