/* ============================================================
   LAAP News — Front office
   ============================================================ */
:root {
    --bg: #f6f7fb;
    --bg-card: #ffffff;
    --bg-hover: #eef0f7;
    --bg-header: rgba(255, 255, 255, 0.85);
    --text: #171a23;
    --text-soft: #5b6270;
    --text-faint: #8a91a0;
    --border: #e4e7ef;
    --accent: #4f46e5;
    --accent-soft: #eef0ff;
    --danger: #dc2626;
    --ok: #16a34a;
    --shadow: 0 1px 3px rgba(20, 24, 40, 0.06), 0 8px 24px rgba(20, 24, 40, 0.05);
    --radius: 12px;
    --header-h: 60px;
}

[data-theme="dark"] {
    --bg: #0e1117;
    --bg-card: #161b26;
    --bg-hover: #1d2432;
    --bg-header: rgba(14, 17, 23, 0.85);
    --text: #e8ebf2;
    --text-soft: #9aa3b5;
    --text-faint: #6b7488;
    --border: #262d3d;
    --accent: #818cf8;
    --accent-soft: #232946;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15.5px;
    line-height: 1.55;
}

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

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 880px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--header-h);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 28px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; letter-spacing: -0.2px; }
.brand-text small { color: var(--text-faint); font-size: 11.5px; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    min-width: 0;
}

.search-box { position: relative; flex: 1; max-width: 260px; }
.search-box input {
    width: 100%;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-soft);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn:active { transform: scale(0.95); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-login { padding: 8px 14px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
}
.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}
.admin-link { font-size: 15px; }

/* ---------- Barre de rubriques ---------- */
.cat-bar {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 16px 10px;
}
.cat-bar-inner {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.cat-bar-inner::-webkit-scrollbar { display: none; }

.cat-tab {
    flex-shrink: 0;
    padding: 7px 15px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-soft);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.cat-tab:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.cat-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.cat-tab .lock { font-size: 11px; margin-left: 3px; opacity: 0.75; }

/* ---------- Contenu ---------- */
.container {
    max-width: 880px;
    margin: 0 auto;
    padding: 18px 16px 40px;
}

.cat-desc {
    color: var(--text-soft);
    font-size: 14.5px;
    margin: 2px 2px 16px;
}

.day-sep {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 2px 10px;
    color: var(--text-faint);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.day-sep:first-child { margin-top: 4px; }
.day-sep::before,
.day-sep::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}
.day-sep span { flex-shrink: 0; }

.item-list { display: flex; flex-direction: column; gap: 8px; }

.item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 15px;
    transition: background 0.15s, border-color 0.15s;
}
.item:hover { background: var(--bg-hover); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.item.hidden, .link-card.hidden { display: none; }

.item-main { flex: 1; min-width: 0; }

.item-title {
    display: block;
    font-size: 16px;
    font-weight: 650;
    color: var(--text);
    line-height: 1.35;
    letter-spacing: -0.1px;
    overflow-wrap: break-word;
}
a.item-title:hover { color: var(--accent); text-decoration: none; }
.item-title.no-link { font-weight: 600; }

.item-desc {
    margin: 5px 0 0;
    color: var(--text-soft);
    font-size: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--text-faint);
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 650;
}
.badge.source {
    background: var(--accent-soft);
    color: var(--accent);
}
.badge.cat {
    background: var(--bg-hover);
    color: var(--text-soft);
}
.badge.cat:hover { text-decoration: none; }

.time { white-space: nowrap; }
.author { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

.save-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 15px;
    opacity: 0.55;
    transition: opacity 0.15s, transform 0.1s;
}
.item:hover .save-btn { opacity: 1; }
.save-btn:active { transform: scale(0.92); }

/* ---------- Liens sauvegardés ---------- */
.links-section { margin-top: 34px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.section-head h2 {
    font-size: 17px;
    margin: 0;
    letter-spacing: -0.2px;
}
.section-head h2 small {
    font-size: 12px;
    color: var(--text-faint);
    background: var(--bg-hover);
    border-radius: 999px;
    padding: 2px 9px;
    margin-left: 6px;
    vertical-align: middle;
}

.link-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    transition: background 0.15s;
}
.link-card:hover { background: var(--bg-hover); }

.pf {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 800;
    color: #fff;
}
.pf-x { background: #0f1419; }
.pf-youtube { background: #ff0000; }
.pf-other { background: var(--text-faint); }

.link-main { flex: 1; min-width: 0; }
.link-title {
    display: block;
    font-weight: 650;
    font-size: 15px;
    color: var(--text);
    overflow-wrap: break-word;
}
a.link-title:hover { color: var(--accent); text-decoration: none; }
.link-note { margin: 3px 0 0; color: var(--text-soft); font-size: 13.5px; }
.link-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-faint);
}
.link-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }

.link-actions { display: flex; gap: 4px; }
.link-actions .icon-btn { width: 32px; height: 32px; font-size: 14px; }

/* ---------- État vide ---------- */
.empty-state {
    text-align: center;
    padding: 70px 20px;
    color: var(--text-soft);
}
.empty-icon { font-size: 52px; margin-bottom: 10px; }
.empty-state h2 { color: var(--text); font-size: 19px; margin: 0 0 8px; }
.empty-state p { margin: 0 auto; max-width: 420px; font-size: 14.5px; }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    text-align: center;
    color: var(--text-faint);
    font-size: 12.5px;
}
.site-footer a { color: var(--text-faint); }

/* ---------- Modale ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(10, 12, 20, 0.55);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.modal-backdrop[hidden] { display: none; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow);
    animation: slideUp 0.22s ease;
}
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal h3 { margin: 0 0 14px; font-size: 16.5px; }
.modal label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 12px;
}
.modal input, .modal select, .modal textarea {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    font-family: inherit;
    outline: none;
}
.modal input:focus, .modal select:focus, .modal textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

/* ---------- Toasts ---------- */
.toasts {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(92vw, 420px);
}
.toast {
    background: var(--text);
    color: var(--bg);
    padding: 11px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 550;
    box-shadow: var(--shadow);
    animation: toastIn 0.2s ease;
    text-align: center;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transition: opacity 0.3s; }
@keyframes toastIn {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---------- Page de connexion ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 20px;
    background:
        radial-gradient(60% 50% at 20% 0%, var(--accent-soft) 0%, transparent 70%),
        var(--bg);
}
.auth-wrap { width: 100%; display: flex; justify-content: center; }
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 30px 28px;
    width: 100%;
    max-width: 380px;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-soft);
    margin-bottom: 18px;
}
.auth-brand .brand-icon { font-size: 24px; }
.auth-card h1 { margin: 0 0 16px; font-size: 22px; letter-spacing: -0.3px; }
.auth-card label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 13px;
}
.auth-card input[type="text"], .auth-card input[type="password"] {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 11px 13px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.auth-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-back { margin: 16px 0 0; text-align: center; font-size: 13.5px; }

.alert {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 550;
    margin-bottom: 14px;
}
.alert-error {
    background: color-mix(in srgb, var(--danger) 12%, var(--bg-card));
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border));
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    body { font-size: 15px; }
    .header-inner { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
    .search-box { order: 3; max-width: none; flex-basis: 100%; }
    .header-actions { gap: 6px; }
    .brand-text small { display: none; }
    .user-name { display: none; }
    .container { padding: 12px 12px 32px; }
    .item { padding: 12px 13px; }
    .item-title { font-size: 15.5px; }
    .item-desc { -webkit-line-clamp: 3; }
    .save-btn { opacity: 1; }
    .modal-backdrop { align-items: flex-end; }
}
