/* ========== RESET ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1419;
    --bg-card: #1a2028;
    --bg-card-hover: #222a34;
    --border: #2a323d;
    --text: #e6e9ee;
    --text-muted: #7d8896;
    --accent: #06b6d4;
    --accent-hover: #22d3ee;
    --favori: #fbbf24;
    --danger: #ef4444;
    --radius: 10px;
}

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

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ========== HEADER / MENU ========== */
.site-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.logo {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.3px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.logo img { max-height: 32px; }

.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a {
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: .9em;
    font-weight: 500;
    transition: all .15s;
    white-space: nowrap;
}
.main-nav a:hover { color: var(--text); background: var(--bg-card); }
.main-nav a.active { color: var(--accent); background: rgba(6, 182, 212, .1); }

/* ========== PUB (header + footer) ========== */
.pub {
    max-width: 1100px;
    margin: 16px auto;
    padding: 24px 14px 14px;   /* ← padding-top plus grand pour le label */
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    position: relative;
}
.pub-header { margin-top: 20px; margin-bottom: 0; }
.pub-footer { margin-top: 32px; margin-bottom: 16px; }

.pub-label {
    position: absolute;
    top: 6px;
    left: 12px;
    font-size: .65em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: .6;
}
.pub-slot {
    width: 100%;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a5563;
    font-size: .85em;
    font-weight: 500;
    background: rgba(255,255,255,.02);
    border-radius: 6px;
    overflow: hidden;
}

/* L'image ou l'iframe publicitaire prend toute la largeur */
.pub-slot img,
.pub-slot iframe,
.pub-slot ins,
.pub-slot a img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    border: 0;
}

/* ========== CONTAINER ========== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px;
    width: 100%;
}

/* ========== TITRE + COMPTEUR ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 1.5em; font-weight: 700; letter-spacing: -.3px; }
.page-header .count { color: var(--text-muted); font-size: .9em; }

/* ========== RECHERCHE ========== */
.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: var(--bg-card);
    padding: 8px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.search-form input[type="text"] {
    flex: 1;
    min-width: 160px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: .95em;
    outline: none;
}
.search-form input[type="text"]::placeholder { color: var(--text-muted); }
.search-form select {
    padding: 10px 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .9em;
    cursor: pointer;
    outline: none;
}
.search-form button {
    background: var(--accent);
    color: var(--bg);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: .9em;
    transition: background .15s;
}
.search-form button:hover { background: var(--accent-hover); }

/* ========== GRILLE 2 COLONNES ========== */
.links-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* ========== CARTE LIEN ========== */
.link-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all .15s;
    position: relative;
    overflow: hidden;
    min-width: 0;
}
.link-card:hover {
    background: var(--bg-card-hover);
    border-color: #3a4653;
    transform: translateY(-1px);
}

.link-favicon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.link-favicon img { width: 100%; height: 100%; object-fit: contain; }
.link-favicon .fallback {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 1em;
    text-transform: uppercase;
}

.link-content { flex: 1; min-width: 0; }
.link-title {
    font-size: .95em;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    transition: color .15s;
}
.link-card:hover .link-title { color: var(--accent); }
.link-category {
    font-size: .75em;
    color: var(--text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-clicks {
    font-size: .78em;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    padding: 4px 9px;
    border-radius: 20px;
    flex-shrink: 0;
    letter-spacing: .3px;
    white-space: nowrap;
}

.link-fav-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    padding: 4px;
    color: var(--text-muted);
    transition: all .15s;
    flex-shrink: 0;
    line-height: 1;
}
.link-fav-btn:hover { color: var(--favori); transform: scale(1.15); }
.link-fav-btn.active { color: var(--favori); }

.link-actions-admin {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
}
.link-card:hover .link-actions-admin { opacity: 1; }
.link-actions-admin a {
    background: rgba(0,0,0,.6);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75em;
    transition: background .15s;
}
.link-actions-admin a:hover { background: var(--accent); }
.link-actions-admin a.del:hover { background: var(--danger); }

/* ========== PAGINATION ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 32px 0 16px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: .88em;
    font-weight: 600;
    transition: all .15s;
}
.pagination a:hover { color: var(--text); border-color: var(--accent); }
.pagination a.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.pagination .page-info {
    color: var(--text-muted);
    font-size: .85em;
    margin-left: 12px;
    border: none;
    background: none;
    min-width: auto;
}

/* ========== FORMULAIRES ========== */
.form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
}
.form label {
    display: block;
    margin-bottom: 16px;
    font-size: .9em;
    color: var(--text-muted);
    font-weight: 500;
}
.form input, .form textarea, .form select {
    width: 100%;
    padding: 10px 14px;
    margin-top: 6px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .95em;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
.form input:focus, .form textarea:focus, .form select:focus { border-color: var(--accent); }
.form textarea { resize: vertical; min-height: 80px; }

.form-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: .9em;
    transition: all .15s;
    text-align: center;
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    max-width: none;
    margin-bottom: 24px;
}
.form-inline label { margin-bottom: 0; flex: 1; min-width: 180px; }

/* ========== TABLEAU ========== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: collapse; background: var(--bg-card); min-width: 500px; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th {
    background: var(--bg);
    color: var(--text-muted);
    font-size: .8em;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: var(--bg-card-hover); }
.table a { color: var(--accent); }
.table a:hover { text-decoration: underline; }

/* ========== MESSAGES ========== */
.error {
    background: rgba(239, 68, 68, .1);
    color: #fca5a5;
    padding: 12px 16px;
    border-left: 3px solid var(--danger);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: .9em;
}
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

/* ========== LOGIN ========== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 36px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
}
.login-box h1 { text-align: center; margin-bottom: 24px; font-size: 1.3em; }
.login-box .form { box-shadow: none; padding: 0; border: none; background: none; max-width: none; }
.login-box .btn { width: 100%; margin-bottom: 8px; }

/* ========== FOOTER ========== */
.site-footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    text-align: center;
    padding: 24px;
    font-size: .85em;
}

/* ========== RESPONSIVE ========== */
/* Tablette */
@media (max-width: 900px) {
    .container { padding: 24px 20px; }
    .pub { margin-left: 20px; margin-right: 20px; }
}

/* Mobile paysage / petites tablettes */
@media (max-width: 700px) {
    .links-grid { grid-template-columns: 1fr; }
    .header-inner { gap: 12px; }
    .main-nav { width: 100%; justify-content: flex-start; }
    .main-nav a { padding: 6px 10px; font-size: .85em; }
    .container { padding: 20px 16px; }
    .pub { margin-left: 16px; margin-right: 16px; padding: 8px; }
    .pub-slot { min-height: 70px; font-size: .8em; }
    .search-form { flex-direction: column; }
    .search-form select, .search-form button { width: 100%; }
    .page-header h1 { font-size: 1.25em; }
    .site-header { padding: 12px 16px; }
    .logo { font-size: 1.15em; }
}

/* Mobile portrait */
@media (max-width: 480px) {
    body { font-size: 14px; }
    .container { padding: 16px 12px; }
    .pub { margin-left: 12px; margin-right: 12px; }
    .pub-slot { min-height: 60px; }

    .header-inner { flex-direction: column; align-items: stretch; gap: 10px; }
    .logo { justify-content: center; }
    .main-nav { justify-content: center; }
    .main-nav a { font-size: .82em; padding: 6px 8px; }

    .link-card { padding: 12px; gap: 10px; }
    .link-favicon { width: 28px; height: 28px; }
    .link-title { font-size: .9em; }
    .link-clicks { font-size: .72em; padding: 3px 7px; }

    .pagination a, .pagination span { min-width: 32px; height: 32px; padding: 0 9px; font-size: .82em; }
    .pagination .page-info { display: none; } /* masqué sur très petit écran */

    .form { padding: 18px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }

    .login-box { padding: 24px 20px; }
}
/* ========== PLACEHOLDER BANNIÈRE (à retirer une fois la vraie pub en place) ========== */
.banner-demo {
    width: 100%;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;

    /* Dégradé animé pour l'effet "place holder" */
    background: linear-gradient(
        135deg,
        #1a2028 0%,
        #222a34 25%,
        #1a2028 50%,
        #222a34 75%,
        #1a2028 100%
    );
    background-size: 200% 200%;
    animation: bannerShift 8s ease infinite;

    border: 1px dashed #3a4653;
    border-radius: 6px;
    padding: 16px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Petite ligne décorative en haut */
.banner-demo::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #06b6d4, transparent);
    border-radius: 0 0 3px 3px;
}

.banner-demo-tag {
    font-size: .95em;
    font-weight: 700;
    color: #06b6d4;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.banner-demo-text {
    font-size: .78em;
    color: #4a5563;
    font-weight: 500;
}

@keyframes bannerShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Responsive : adapte la hauteur sur mobile */
@media (max-width: 700px) {
    .banner-demo {
        min-height: 70px;
        padding: 12px;
    }
    .banner-demo-tag { font-size: .85em; }
    .banner-demo-text { font-size: .7em; }
}

@media (max-width: 480px) {
    .banner-demo {
        min-height: 60px;
        padding: 10px;
    }
    .banner-demo-tag { font-size: .8em; }
    .banner-demo-text { font-size: .68em; }
}
/* ========== MENU DÉROULANT CATÉGORIES ========== */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: .9em;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
    white-space: nowrap;
}
.nav-dropdown-btn:hover { color: var(--text); background: var(--bg-card); }
.nav-dropdown-btn.active { color: var(--accent); background: rgba(6, 182, 212, .1); }

.nav-dropdown-btn .arrow {
    font-size: .7em;
    transition: transform .2s;
    display: inline-block;
}
.nav-dropdown.open .arrow { transform: rotate(180deg); }

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: all .18s ease;
    z-index: 200;
    max-height: 400px;
    overflow-y: auto;
}

.nav-dropdown.open .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-menu a {
    display: block;
    padding: 9px 14px;
    color: var(--text-muted);
    border-radius: 6px;
    font-size: .88em;
    font-weight: 500;
    transition: all .12s;
    white-space: nowrap;
}
.nav-dropdown-menu a:hover {
    background: var(--bg);
    color: var(--text);
}
.nav-dropdown-menu a.active {
    background: rgba(6, 182, 212, .12);
    color: var(--accent);
    font-weight: 600;
}

.nav-dropdown-empty {
    display: block;
    padding: 9px 14px;
    color: var(--text-muted);
    font-size: .85em;
    font-style: italic;
}

/* ========== VERSION MOBILE ========== */
@media (max-width: 700px) {
    .nav-dropdown { width: 100%; }

    .nav-dropdown-btn {
        width: 100%;
        justify-content: space-between;
        background: var(--bg-card);
        border: 1px solid var(--border);
        padding: 10px 14px;
    }

    /* Sur mobile : le menu devient un accordéon intégré (pas en position absolue) */
    .nav-dropdown-menu {
        position: static;
        box-shadow: none;
        border: 1px solid var(--border);
        margin-top: 6px;
        max-height: 0;
        padding: 0 6px;
        overflow: hidden;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: max-height .25s ease, padding .25s ease;
    }
    .nav-dropdown.open .nav-dropdown-menu {
        max-height: 400px;
        padding: 6px;
    }
}
/* ========== PAGE CATÉGORIES PUBLIQUES ========== */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: block;
    transition: all .18s;
    position: relative;
    overflow: hidden;
}
.category-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(6, 182, 212, .15);
}

.category-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.category-card h2 {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.category-count {
    background: rgba(6, 182, 212, .15);
    color: var(--accent);
    font-size: .78em;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    min-width: 32px;
    text-align: center;
}
.category-desc {
    color: var(--text-muted);
    font-size: .88em;
    margin-bottom: 12px;
    line-height: 1.4;
}
.category-link {
    color: var(--accent);
    font-size: .82em;
    font-weight: 600;
    display: inline-block;
    transition: transform .15s;
}
.category-card:hover .category-link { transform: translateX(4px); }

@media (max-width: 480px) {
    .categories-grid { grid-template-columns: 1fr; gap: 12px; }
    .category-card { padding: 16px; }
}
/* ========== SÉLECTEUR DE LANGUE ========== */
.nav-lang {
    display: flex;
    gap: 2px;
    margin-left: 6px;
    padding: 3px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    align-items: center;
}
.lang-btn {
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 1.1em;
    line-height: 1;
    transition: all .15s;
    opacity: .5;
}
.lang-btn:hover { opacity: 1; background: var(--bg); }
.lang-btn.active {
    opacity: 1;
    background: rgba(6, 182, 212, .15);
}

@media (max-width: 700px) {
    .nav-lang { margin-left: 0; align-self: flex-start; }
}
/* ========== LOGO AVEC SLOGAN ========== */
.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-name {
    font-size: 1em;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.3px;
}

.logo-tagline {
    font-size: .62em;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: .3px;
    margin-top: 2px;
    font-style: italic;
}

/* Responsive : cacher le slogan sur très petits écrans */
@media (max-width: 480px) {
    .logo-tagline {
        font-size: .58em;
    }
}
.logo {
    transition: opacity .15s;
}
.logo:hover {
    opacity: .85;
}