/* Pokemon GO Manager — feuille de style globale */
:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #21262d;
    --border: #30363d;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --radius: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: #f0f6fc; }
h1 { font-size: 1.8em; margin: 1em 0 .5em; }
h2 { font-size: 1.4em; margin: 1.2em 0 .6em; }
p { margin: .5em 0; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px 40px; }
.muted { color: var(--text-muted); }
.error { color: var(--danger); }

/* Header */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 1em;
    padding: 12px 20px;
}
.logo {
    font-weight: 700;
    font-size: 1.1em;
    color: #f0f6fc;
}
.main-nav, .user-nav { display: flex; gap: 1em; align-items: center; }
.main-nav { margin-left: auto; }
.user-nav { margin-left: auto; }
.main-nav a { color: var(--text); }
.main-nav a:hover { color: #f0f6fc; }

/* Menus déroulants du header */
.dropdown { position: relative; display: inline-block; }
.dropdown-summary {
    list-style: none; cursor: pointer; color: var(--text);
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px;
}
.dropdown-summary::-webkit-details-marker { display: none; }
.dropdown-summary:hover { color: #f0f6fc; }
.caret { font-size: .7em; opacity: .7; }
.dropdown[open] .dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 8px; min-width: 180px; padding: 6px; z-index: 1100;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.dropdown-item {
    display: block; width: 100%; text-align: left; padding: 8px 10px;
    background: none; border: none; color: var(--text); border-radius: 6px;
    font: inherit; cursor: pointer; text-decoration: none; box-sizing: border-box;
}
.dropdown-item:hover { background: var(--surface); color: #f0f6fc; }
.dropdown-sep { border-top: 1px solid var(--border); margin: 6px 4px; }

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: .9em;
}

/* Flash */
.flash {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin: 16px 0;
    border: 1px solid;
}
.flash-success { background: rgba(22,163,74,.1); border-color: var(--success); color: #4ade80; }
.flash-error { background: rgba(220,38,38,.1); border-color: var(--danger); color: #f87171; }

/* Boutons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .95em;
    text-decoration: none;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: .85em; }
.btn-link { background: transparent; color: var(--primary); }
.btn-link:hover { background: transparent; text-decoration: underline; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .95em;
}
.form-group textarea { font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: 2px solid var(--primary);
    border-color: var(--primary);
}
.form-check label, .checkbox { display: flex; align-items: center; gap: 6px; }
.form-narrow { max-width: 400px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.form-inline input, .form-inline select { flex: 1; min-width: 150px; }

/* Périodes multiples d'un événement */
.period-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.period-set { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.period-row .period-remove { flex: 0 0 auto; }
.period-date { width: auto; min-width: 132px; }
.period-time { display: inline-flex; gap: 3px; align-items: center; white-space: nowrap; }
.period-time .period-select { width: auto; min-width: 56px; padding: 7px 4px; text-align: center; }
.period-time b { color: var(--text-muted); }
.period-sep { color: var(--text-muted); font-weight: 600; }
.period-list { list-style: none; padding: 0; margin: 0; }
.period-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }

/* Coordonnées d'un événement */
.coord-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.coord-value { font-family: monospace; background: var(--surface-2); padding: 6px 10px; border-radius: var(--radius); border: 1px solid var(--border); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }

/* Générateur de chaîne de recherche */
.search-result {
    width: 100%;
    min-height: 72px;
    font-family: monospace;
    font-size: .95em;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    resize: vertical;
}

.pokemon-list-box { display: flex; flex-wrap: wrap; gap: 10px; }
.pokemon-card {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface-2); min-width: 76px; text-align: center;
}
.pokemon-sprite { width: 64px; height: 64px; object-fit: contain; display: block; }
.pokemon-card.clickable { cursor: pointer; transition: border-color .15s; }
.pokemon-card.clickable:hover { border-color: var(--primary); }
.pokemon-card-name { font-size: .82em; color: var(--text); line-height: 1.1; }
.pokemon-card-stats {
    font-size: .7em; color: var(--text-muted); line-height: 1.25; text-align: center;
    word-break: break-word; max-width: 100%;
}
.pokemon-stat-line { display: block; white-space: nowrap; }
.pokemon-stat-niv { color: var(--text-muted); font-size: .9em; }
/* Code couleur des niveaux */
.niv-00 { color: #FF0000; }   /* 00-19 → rouge vif */
.niv-20 { color: #FF8C00; }   /* 20-29 → orange */
.niv-30 { color: #FFD700; }   /* 30-34 → jaune */
.niv-35 { color: #90EE90; }   /* 35-39 → vert clair */
.niv-40 { color: #7DD3FC; }   /* 40-49 → bleu clair */
.niv-50 { color: #C77DFF; }   /* 50-80 → mauve */
/* Code couleur des valeurs IV */
.iv-100 { color: #16a34a; font-weight: 700; }        /* 100 → vert */
.iv-90  { color: #7dd3fc; font-weight: 600; }        /* 90-99 → bleu clair */
.iv-80  { color: #1d6fd6; font-weight: 600; }        /* 80-89 → bleu foncé */
.iv-67  { color: #ffffff; }                          /* 67-79 → noir (lisible sur fond sombre) */
.iv-34  { color: #f97316; }                          /* 34-66 → orange */
.iv-low { color: #ef4444; }                          /* <34 → rouge */
.pokemon-chip {
    display: inline-block;
    background: var(--primary)1a;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: .85em;
}
.pokemon-chip-remove {
    background: none; border: none; color: inherit;
    font-size: 1em; line-height: 1; margin-left: 4px; cursor: pointer; padding: 0;
}
.pokemon-picker { display: flex; flex-direction: column; gap: 8px; }
.pokemon-picker-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pokemon-picker-add { position: relative; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pokemon-picker-add input[type="text"] { flex: 1; min-width: 220px; }
.pokemon-suggestions {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    max-height: 240px; overflow-y: auto; margin-top: 2px;
}
.pokemon-suggestion { padding: 6px 10px; cursor: pointer; font-size: .9em; }
.pokemon-suggestion:hover { background: var(--surface); }
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    position: relative; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: var(--text-muted); font-size: 1.6em; cursor: pointer; }
.inline-edit { display: inline-block; }
.inline-edit summary { cursor: pointer; list-style: none; }
.inline-edit summary::-webkit-details-marker { display: none; }
.inline-edit[open] .form-inline { flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.home-view-toggle { display: flex; gap: 8px; margin: 18px 0 8px; }
.home-view-toggle .btn { border-radius: 6px; }
.home-view-toggle .btn-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.category-block { margin-bottom: 26px; }
.category-block h2 { border-bottom: 2px solid currentColor; padding-bottom: 6px; }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th { background: var(--surface-2); color: #f0f6fc; font-weight: 600; }
.data-table tr:hover { background: var(--surface-2); }

/* Champs numériques "Mes Pokémon" : largeur adaptée au contenu de la colonne */
.pkm-number {
    width: 6ch;
    min-width: 0;
    box-sizing: border-box;
    text-align: center;
    padding: 4px 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9em;
    -moz-appearance: textfield;
}
.pkm-number::-webkit-outer-spin-button,
.pkm-number::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* Cellule IV : IV (ligne 1) + niveau (ligne 2) empilés.
   Le <td> RESTE une cellule de tableau (pas de display:flex qui casse l'alignement). */
.pkm-iv-cell { text-align: center; white-space: nowrap; }
.pkm-iv-cell .pkm-number { display: block; margin: 0 auto; width: 5ch; }
.pkm-iv { font-size: .7em; color: var(--text-muted); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
}
.stat-card, .stats-row { display: inline-flex; flex-direction: column; }
.stats-row { flex-direction: row; gap: 16px; margin: 20px 0; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    align-items: center;
    min-width: 120px;
}
.stat-num { font-size: 1.8em; font-weight: 700; color: #f0f6fc; }
.stat-label { color: var(--text-muted); font-size: .85em; text-transform: uppercase; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: .8em;
    background: var(--surface-2);
    color: var(--text);
}
.badge-published { background: rgba(59,130,246,.2); color: #60a5fa; }
.badge-ongoing { background: rgba(22,163,74,.2); color: #4ade80; }
.badge-ending-soon { background: rgba(217,119,6,.2); color: #fbbf24; }
.badge-ended { background: rgba(139,148,158,.2); color: #8b949e; }
.badge-draft { background: rgba(217,119,6,.2); color: #fbbf24; }
.badge-cancelled { background: rgba(220,38,38,.2); color: #f87171; }

/* Events */
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.event-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text);
    background-size: cover;
    background-position: center;
    min-height: 120px;
}
.event-card:hover { border-color: var(--primary); text-decoration: none; }
.event-card.ongoing { border-color: var(--success); }
.event-card.ending-soon { border-color: var(--warning); }
.event-card-overlay h3, .event-card-overlay p { color: #f0f6fc; text-shadow: 0 2px 4px rgba(0,0,0,.8); }
.event-header {
    padding: 40px 20px;
    border-radius: var(--radius);
    margin: 16px 0;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border);
}
.event-header h1 { color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.9); margin: 0 0 8px; }
.event-header p { color: #e0e0e0; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.event-thumb { width: 60px; height: 40px; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: 8px; }

/* Cover picker */
.cover-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.cover-option { cursor: pointer; display: inline-block; }
.cover-option img { width: 100px; height: 70px; object-fit: cover; border-radius: 4px; border: 3px solid transparent; display: block; }
.cover-option input[type="radio"] { display: none; }
.cover-option input[type="radio"]:checked + img { border-color: var(--primary); }

/* Gallery */
.gallery { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.gallery-item {
    display: inline-block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}
.gallery-item img { display: block; max-width: 200px; max-height: 150px; object-fit: cover; }

/* Calendar */
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th, .calendar td { border: 1px solid var(--border); padding: 4px; vertical-align: top; width: 14.28%; }
.calendar th { background: var(--surface-2); padding: 8px; text-align: center; }
.calendar td.empty { background: var(--surface); opacity: .5; }
.cal-day { min-height: 90px; height: 90px; overflow: hidden; }
.cal-num { font-weight: 600; color: var(--text-muted); margin-bottom: 4px; font-size: .85em; }
.cal-event { display: block; padding: 2px 6px; margin: 2px 0; border-radius: 4px; font-size: .78em; background: var(--surface-2); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event-start { border-left: 3px solid var(--primary); }
.cal-event-end { border-right: 3px solid var(--primary); }
.cal-event-mid { opacity: .8; border-left: 3px solid var(--text-muted); }
.cal-status-ongoing { color: #4ade80 !important; }
.cal-status-ending-soon { color: #fbbf24 !important; }
.cal-status-ended { color: #f87171 !important; }
.cal-status-upcoming { color: #60a5fa !important; }
.cal-event-child { font-style: italic; opacity: .85; }

/* Map */
#map-view { height: 70vh; border-radius: var(--radius); border: 1px solid var(--border); }
#map { height: 70vh; border-radius: var(--radius); border: 1px solid var(--border); }
.map-filters { display: flex; gap: 16px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
#event-map { height: 300px; border-radius: var(--radius); }

/* POI markers */
.poi-marker { background: transparent; border: none; }
.poi-picto { display: inline-flex; align-items: center; }

/* Active button */
.btn-active { background: var(--primary-hover); }

/* POI table */
.poi-icon-cell { text-align: center; }

/* Lignes cliquables */
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--surface-2); }

/* Tri des tableaux */
table.sortable th[data-sort] { cursor: pointer; user-select: none; }
table.sortable th[data-sort]:hover { color: var(--primary); }
table.sortable th.sort-asc::after { content: " ▲"; font-size: .8em; color: var(--primary); }
table.sortable th.sort-desc::after { content: " ▼"; font-size: .8em; color: var(--primary); }

/* Lignes événements selon le statut */
tr.row-ongoing td { color: #4ade80; }
tr.row-ending-soon td { color: #fbbf24; }
tr.row-ended td { color: #f87171; }
tr.row-upcoming td { color: #60a5fa; }
tr.row-cancelled td { color: #8b949e; text-decoration: line-through; }
tr.row-ongoing td a, tr.row-ending-soon td a, tr.row-ended td a, tr.row-upcoming td a { color: inherit; }
tr.muted-italic td { color: var(--text-muted); font-style: italic; }
td.bold { font-weight: 700; }

/* Études */
.steps-list { padding-left: 20px; }
.steps-list li { margin-bottom: 12px; }
.step-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.badge-active { background: rgba(22,163,74,.2); color: #4ade80; }
.badge-completed { background: rgba(59,130,246,.2); color: #60a5fa; }
.badge-archived { background: rgba(139,148,158,.2); color: #8b949e; }

/* Pokédex */
.species-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.species-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    text-align: center;
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.species-card:hover { border-color: var(--primary); text-decoration: none; }
.species-img { width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; }
.species-img img { max-width: 80px; max-height: 80px; }
.species-num { font-size: .8em; color: var(--text-muted); }
.species-name { font-weight: 600; margin: 4px 0; }

/* Type badges */
.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: .75em;
    color: #fff;
    text-transform: capitalize;
}
.type-normal { background: #a8a878; }
.type-fire { background: #f08030; }
.type-water { background: #6890f0; }
.type-electric { background: #f8d030; color: #000; }
.type-grass { background: #78c850; }
.type-ice { background: #98d8d8; color: #000; }
.type-fighting { background: #c03028; }
.type-poison { background: #a040a0; }
.type-ground { background: #e0c068; color: #000; }
.type-flying { background: #a890f0; }
.type-psychic { background: #f85888; }
.type-bug { background: #a8b820; }
.type-rock { background: #b8a038; }
.type-ghost { background: #705898; }
.type-dragon { background: #7038f8; }
.type-dark { background: #705848; }
.type-steel { background: #b8b8d0; color: #000; }
.type-fairy { background: #ee99ac; }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 0; }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: 8px; }
.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-form input, .search-form select { padding: 6px 10px; }
.checkbox-inline { display: inline-flex; gap: 4px; align-items: center; }

/* Pagination */
.pagination nav, .pagination { margin: 16px 0; }
.pagination ul { display: flex; gap: 4px; list-style: none; padding: 0; }
.pagination li a, .pagination li span {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
.pagination li.active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination li.ellipsis span { border: none; background: transparent; }

/* Admin */
.admin-menu { list-style: none; padding: 0; }
.admin-menu li { padding: 8px 0; }
.admin-menu a, .admin-menu button {
    display: inline-block;
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
}
