/* ═══════════════════════════════
   style.css — REFONTE TOTALE
═══════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --bg:       #f0f4ff;
    --card:     #ffffff;
    --card2:    #f8faff;
    --border:   #e4e8f5;
    --text:     #111827;
    --muted:    #6b7280;
    --green:    #16a34a;
    --green2:   #22c55e;
    --cyan:     #0891b2;
    --r:        12px;
}

.dark-mode {
    --bg:       #0b0b10;
    --card:     #13131a;
    --card2:    #1a1a24;
    --border:   #252535;
    --text:     #e2e4f0;
    --muted:    #7070a0;
}

/* BODY */
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background .3s, color .3s;
}

/* WRAPPER CENTRAL */
.container {
    width: min(1000px, 94vw);
    margin: 28px auto 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: clamp(20px, 4vw, 44px);
    box-shadow: 0 8px 40px rgba(0,0,0,.09);
    flex: 1;
}

.dark-mode .container {
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

/* ═══ TITRE ANIMÉ ═══ */
.site-title {
    text-align: center;
    margin-bottom: 30px;
}

.site-title h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -1px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    line-height: 1;
}

.title-emoji {
    display: inline-block;
    animation: bounce 2.5s ease-in-out infinite;
}

@keyframes bounce {
    0%,100% { transform: translateY(0) scale(1);   }
    40%      { transform: translateY(-8px) scale(1.1); }
    60%      { transform: translateY(-4px) scale(1.05); }
}

.title-words {
    background: linear-gradient(100deg,
        #16a34a 0%,
        #22c55e 25%,
        #0891b2 50%,
        #6366f1 75%,
        #22c55e 100%
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-move 4s linear infinite;
}

@keyframes gradient-move {
    0%   { background-position: 0%   center; }
    100% { background-position: 300% center; }
}

.title-underline {
    display: block;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #22c55e, #0891b2);
    border-radius: 2px;
    margin: 8px auto 0;
    animation: underline-grow .8s .3s ease forwards;
}

@keyframes underline-grow {
    to { width: 120px; }
}

/* ═══ IP HERO ═══ */
.ip-hero {
    background: linear-gradient(135deg, #f0fdf4, #ecfeff);
    border: 1px solid #bbf7d0;
    border-radius: var(--r);
    padding: 22px 16px;
    text-align: center;
    margin-bottom: 20px;
    animation: fade-up .5s ease;
}

.dark-mode .ip-hero {
    background: linear-gradient(135deg, #0a1f12, #071a24);
    border-color: #1a4a2a;
}

.ip-hero-label {
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}

.ip-hero-value {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 700;
    color: var(--green);
    font-variant-numeric: tabular-nums;
    letter-spacing: .5px;
    word-break: break-all;
}

.dark-mode .ip-hero-value { color: #4ade80; }

/* ═══ IP CARDS ═══ */
.ip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin-bottom: 22px;
}

.ip-card {
    background: var(--card2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--green2);
    border-radius: 10px;
    padding: 13px 15px;
    display: flex;
    align-items: center;
    gap: 11px;
    animation: fade-up .4s ease both;
    transition: transform .2s, box-shadow .2s;
}

.ip-card:nth-child(1) { animation-delay: .05s }
.ip-card:nth-child(2) { animation-delay: .10s }
.ip-card:nth-child(3) { animation-delay: .15s }
.ip-card:nth-child(4) { animation-delay: .20s }
.ip-card:nth-child(5) { animation-delay: .25s }

.ip-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(34,197,94,.13);
}

.ip-card-icon {
    font-size: 1.35rem;
    flex-shrink: 0;
}

.ip-card-body {
    overflow: hidden;
    flex: 1;
}

.ip-card-label {
    display: block;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 3px;
}

.ip-card-value {
    display: block;
    font-size: .88rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

/* ═══ SECTIONS (additional-info) ═══ */
.section {
    background: var(--card2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 20px;
    margin-bottom: 14px;
    animation: fade-up .4s ease;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.section-head span:first-child { font-size: 1.1rem; }

/* ═══ STATS ═══ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.stat-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
}

.stat-label {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-val {
    font-size: 1rem;
    font-weight: 700;
}

/* ═══ BADGES ═══ */
.badge {
    display: inline-block;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: .8rem;
    font-weight: 700;
}

.bg  { background:#dcfce7; color:#15803d }
.bo  { background:#ffedd5; color:#c2410c }
.br  { background:#fee2e2; color:#b91c1c }
.bb  { background:#dbeafe; color:#1d4ed8 }
.bc  { background:#cffafe; color:#0e7490 }

.dark-mode .bg { background:#14532d; color:#4ade80 }
.dark-mode .bo { background:#431407; color:#fb923c }
.dark-mode .br { background:#450a0a; color:#f87171 }
.dark-mode .bb { background:#1e3a5f; color:#60a5fa }
.dark-mode .bc { background:#0c3a45; color:#22d3ee }

/* ═══ GEO ROWS ═══ */
.geo-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
}

.geo-row:last-child { margin-bottom: 0; }

.geo-icon { flex-shrink: 0; font-size: 1rem; }

.geo-label {
    flex-shrink: 0;
    width: 80px;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--muted);
}

.geo-val {
    font-size: .88rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ═══ TRACEROUTE TABLE ═══ */
.trace-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 14px;
}

.trace-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    min-width: 480px;
}

.trace-table thead tr {
    background: var(--card);
}

.trace-table th {
    padding: 9px 12px;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    text-align: left;
}

.trace-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.trace-table tbody tr:last-child td { border-bottom: none; }
.trace-table tbody tr:hover { background: var(--card2); }

.hop-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--green2);
    color: #fff;
    border-radius: 50%;
    font-size: .72rem;
    font-weight: 700;
}

.td-host {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted);
    font-size: .8rem;
}

.td-ip code {
    background: var(--card2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: .78rem;
    font-family: monospace;
    white-space: nowrap;
    color: var(--text);
}

.bar-bg {
    background: var(--border);
    border-radius: 4px;
    height: 5px;
    min-width: 50px;
}

.bar-fg {
    background: linear-gradient(90deg, #22c55e, #0891b2);
    border-radius: 4px;
    height: 100%;
    transition: width .5s ease;
}

/* ═══ CHART ═══ */
.chart-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

/* ═══ LOADING ═══ */
.loading-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0;
    gap: 14px;
}

.loading {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--green2);
    border-right-color: var(--cyan);
    border-radius: 50%;
    animation: spin .85s linear infinite;
}

.loading-text {
    font-size: .82rem;
    color: var(--muted);
}

@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0);    }
}

/* ═══ FOOTER ═══ */
footer {
    background: linear-gradient(135deg, #15803d, #22c55e);
    color: #f0fdf4;
    padding: 13px 20px;
    font-size: .8rem;
}

.dark-mode footer {
    background: #0b0b10;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

.footer-inner {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

/* ═══ TOP-BAR (contient le switch) ═══ */
.top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 18px;
}

/* ═══ THEME SWITCH ═══ */
.theme-switch { /* in-layout, plus de position: fixed */ }

.theme-switch input { display: none; }

.theme-switch label {
    display: block;
    width: 52px;
    height: 28px;
    background: #d1d5db;
    border-radius: 50px;
    cursor: pointer;
    position: relative;
    transition: background .3s;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.theme-switch input:checked + label { background: #22c55e; }

.slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform .3s;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.theme-switch input:checked + label .slider { transform: translateX(24px); }

.theme-switch label::after {
    content: '☀️';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    pointer-events: none;
}

.theme-switch input:checked + label::after {
    content: '🌙';
    left: 6px;
    right: auto;
}

/* ═══ CARTE GÉO ═══ */
.geo-map {
    height: 320px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.geo-map-note {
    font-size: .68rem;
    color: var(--muted);
    text-align: center;
    margin-top: 8px;
}

.map-marker {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}

/* override Leaflet popup pour le thème */
.leaflet-popup-content-wrapper {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.leaflet-popup-tip { background: var(--card); }

.leaflet-popup-content { margin: 10px 14px; font-size: .84rem; }

@media (max-width: 600px) {
    .geo-map { height: 240px; }
}

/* ═══ LIENS ═══ */
a { color: var(--green); text-decoration: none; font-weight: 500; transition: color .2s; }
a:hover { color: #15803d; }
.dark-mode a { color: #4ade80; }
.dark-mode a:hover { color: #86efac; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 600px) {
    body { padding: 0; }

    .container {
        width: 100%;
        margin: 0 0 10px;
        border-radius: 0;
        padding: 18px 14px;
        border-left: none;
        border-right: none;
        border-top: none;
    }

    h1 { font-size: 1.5rem; }

    .site-title { margin-bottom: 18px; }
    .ip-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }

    .geo-label { width: 65px; }

    .footer-inner { flex-direction: column; gap: 5px; text-align: center; }

    .top-bar { margin-bottom: 10px; }
}

@media (min-width: 601px) and (max-width: 860px) {
    .container { width: 96vw; padding: 24px 20px; }
    .ip-grid { grid-template-columns: 1fr 1fr; }
}
