/* =================== RESET / BASE =================== */
*, *::before, *::after { 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: #f5f7fa;
    color: #0f172a;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.45;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }

:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #e0f2fe;
    --positive: #16a34a;
    --positive-bg: #dcfce7;
    --negative: #dc2626;
    --negative-bg: #fee2e2;
    --neutral: #64748b;
    --neutral-bg: #f1f5f9;
    --border: #e2e8f0;
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
    --shadow: 0 4px 16px -4px rgba(15,23,42,0.08);
    --shadow-lg: 0 12px 36px -12px rgba(15,23,42,0.18);
    --max: 560px;
}

/* =================== LAYOUT =================== */
.shell {
    max-width: var(--max);
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.topbar .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text);
}
.topbar .brand .dot {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1rem;
}
.topbar .spacer { flex: 1; }
.topbar a.link {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
}
.topbar a.link:hover { color: var(--primary); }

.content {
    flex: 1;
    padding: 1rem;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer {
    text-align: center;
    padding: 1.5rem 1rem 2rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* =================== LOADER =================== */
.loader {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =================== HOME =================== */
.hero {
    text-align: center;
    padding: 2rem 0.5rem 1rem;
}
.hero h1 {
    font-size: 1.7rem;
    margin: 0 0 0.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.hero p {
    margin: 0 auto;
    color: var(--text-muted);
    max-width: 420px;
    font-size: 0.95rem;
}

.search-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.search-row {
    display: flex;
    gap: 0.5rem;
}
.search-input {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    font-size: 1rem;
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.15);
}
.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.2rem;
    font-weight: 700;
    font-size: 0.9rem;
    background: var(--primary);
    color: white;
    transition: transform 0.06s ease, background 0.15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
    background: white;
    color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: #f8fafc; border-color: var(--primary); color: var(--primary); }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    font-weight: 600;
}
.btn-ghost:hover { color: var(--primary); background: var(--primary-light); }
.btn-full { width: 100%; }

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.85rem;
}
.chip {
    background: var(--neutral-bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.chip:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.feature-grid {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.feature {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border);
}
.feature .ico { font-size: 1.6rem; }
.feature .lbl { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.4rem; font-weight: 600; }
.feature strong { font-size: 1rem; }

/* =================== NUMBER PAGE =================== */
.fiche {
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    border-radius: var(--radius);
    padding: 1.6rem 1.2rem;
    color: white;
    box-shadow: var(--shadow-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
}
.fiche::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 0%, rgba(255,255,255,0.2), transparent 50%);
    pointer-events: none;
}
.fiche .icon-big {
    font-size: 2.4rem;
    margin-bottom: 0.4rem;
    display: inline-block;
    background: rgba(255,255,255,0.18);
    width: 64px; height: 64px;
    line-height: 64px;
    border-radius: 50%;
    backdrop-filter: blur(8px);
}
.fiche .number {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    margin-bottom: 0.3rem;
    word-break: break-all;
}
.fiche .area {
    opacity: 0.92;
    font-size: 0.9rem;
    font-weight: 500;
}
.fiche .badges {
    display: inline-flex;
    gap: 0.35rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}
.fiche .badge {
    background: rgba(255,255,255,0.22);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.fiche .action-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.1rem;
    justify-content: center;
}
.fiche .action-row .pill {
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(6px);
    color: white;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
}
.fiche .action-row .pill:hover { background: rgba(255,255,255,0.28); }

.section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0.75rem 0.2rem 0.5rem;
}

/* Cards-grid type "Truecaller" */
.cards-grid {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background-color: #e2e8f0;
}
.cards-grid .cell {
    background: var(--bg-card);
    padding: 1.1rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    text-align: center;
    min-height: 96px;
}
.cards-grid .cell .ico {
    font-size: 1.4rem;
    color: var(--primary);
    line-height: 1;
}
.cards-grid .cell .lbl {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}
.cards-grid .cell .val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

/* Sentiment bar */
.sentiment-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow);
}
.sent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.55rem;
}
.sent-total {
    font-size: 0.82rem;
    color: var(--text-muted);
}
.sent-bar {
    display: flex;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--neutral-bg);
    margin-bottom: 0.55rem;
}
.sent-bar .seg-pos { background: var(--positive); }
.sent-bar .seg-neu { background: var(--neutral); }
.sent-bar .seg-neg { background: var(--negative); }
.sent-legend {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.sent-legend .dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-right: 0.3rem;
    vertical-align: middle;
}

/* Vote buttons */
.vote-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow);
}
.vote-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}
.vote-btn {
    border: 1.5px solid var(--border);
    background: white;
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.5rem;
    font-weight: 700;
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s;
    color: var(--text);
}
.vote-btn .ico { font-size: 1.5rem; }
.vote-btn:hover { transform: translateY(-1px); }
.vote-btn.pos:hover, .vote-btn.pos.active { background: var(--positive-bg); border-color: var(--positive); color: var(--positive); }
.vote-btn.neu:hover, .vote-btn.neu.active { background: var(--neutral-bg); border-color: var(--neutral); color: var(--neutral); }
.vote-btn.neg:hover, .vote-btn.neg.active { background: var(--negative-bg); border-color: var(--negative); color: var(--negative); }

.category-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}
.cat-chip {
    background: var(--neutral-bg);
    border: 1.5px solid transparent;
    color: var(--text);
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.cat-chip:hover, .cat-chip.active { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary); }

textarea.comment-input {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
    background: white;
    margin-bottom: 0.6rem;
}
textarea.comment-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.15);
}

/* Graph (SVG) */
.graph-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow);
}
.graph-card .head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}
.graph-card .title {
    font-weight: 700;
    font-size: 0.95rem;
}
.graph-card .subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.graph-card .legend {
    display: flex;
    gap: 0.85rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}
.graph-card .legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.3rem; vertical-align: middle; }

.graph-svg {
    width: 100%;
    height: 140px;
    display: block;
    margin-top: 0.4rem;
}

/* Comments list */
.comments-list {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.comment {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.comment:last-child { border-bottom: none; }
.comment .meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}
.comment .meta .pill-sent {
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.7rem;
}
.comment .meta .pill-sent.positive { background: var(--positive-bg); color: var(--positive); }
.comment .meta .pill-sent.neutral  { background: var(--neutral-bg); color: var(--neutral); }
.comment .meta .pill-sent.negative { background: var(--negative-bg); color: var(--negative); }
.empty-comments {
    text-align: center;
    color: var(--text-muted);
    padding: 1.4rem 1rem;
    font-size: 0.85rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: white;
    padding: 0.7rem 1.1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--negative); }
.toast.success { background: var(--positive); }

/* Error / not found */
.notice {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.4rem 1.2rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.notice .ico { font-size: 2rem; margin-bottom: 0.4rem; }
.notice h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.notice p { margin: 0 0 0.85rem; color: var(--text-muted); font-size: 0.9rem; }

/* Desktop adjustments */
@media (min-width: 720px) {
    .shell { max-width: 640px; }
    .hero h1 { font-size: 2.1rem; }
    .cards-grid .cell { min-height: 110px; }
    .cards-grid .cell .ico { font-size: 1.65rem; }
    .cards-grid .cell .val { font-size: 1.05rem; }
    .fiche .number { font-size: 2rem; }
}
