/* ============================================================
   HTML Analyser — Design System
   Thème : Industriel / Terminal — sombre, typographie mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

/* ── Variables ────────────────────────────────────────────── */
:root {
    /* Palette principale (style.css) */
    --bg: #0b0d12;
    --surface: #12151e;
    --surface-2: #171b26;

    --border: #2a3042;
    --border-2: #353c52;

    --text: #e6ebff;
    --text-muted: #a0a8c5;
    --text-dim: #6c7493;

    --accent: #5f8cff;
    --accent-glow: rgba(95, 140, 255, .22);
    --accent-dim: rgba(95, 140, 255, .13);
    /* issu index.php, adapté à la palette */

    --red: #ff6b6b;
    --red-bg: rgba(255, 107, 107, .10);

    --orange: #ff9b50;
    --orange-bg: rgba(255, 155, 80, .10);

    --blue: #5fb0ff;
    --blue-bg: rgba(95, 176, 255, .10);

    --green: #4be0a3;
    --green-bg: rgba(75, 224, 163, .10);

    --purple: #a78bfa;

    --mono: 'IBM Plex Mono', 'Courier New', monospace;
    --sans: 'IBM Plex Sans', system-ui, sans-serif;

    /* Alias pour la compatibilité avec index.php */
    --font-mono: var(--mono);
    --font-ui: var(--sans);

    --radius: 6px;
    --radius-lg: 10px;
    --radius-sm: 6px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.65;
    overflow-x: hidden;
}

::selection {
    background: var(--accent);
    color: white;
}

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    padding: .9rem 0;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    font-size: .85rem;
    color: #fff;
    font-family: var(--mono);
    font-weight: 700;
    flex-shrink: 0;
}

.logo-text {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}

.logo-sub {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-badge {
    margin-left: auto;
    font-family: var(--mono);
    font-size: .7rem;
    color: var(--text-muted);
    border: 1px solid var(--border-2);
    border-radius: 99px;
    padding: .2rem .65rem;
}

/* ── Main grid ────────────────────────────────────────────── */
.main-content {
    padding: 2rem 0 3rem;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
    grid-template-areas: "editor results" "preview preview";
    transition: grid-template-columns .3s ease;
}

.editor-grid.has-preview {
    grid-template-areas: "editor results" "preview preview";
}

/* ── Panel ────────────────────────────────────────────────── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.panel-title {
    font-family: var(--mono);
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.panel-dots {
    display: flex;
    gap: .3rem;
    margin-left: auto;
}

.panel-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-2);
}

/* ── Editor panel ─────────────────────────────────────────── */
.editor-area {
    grid-area: editor;
    position: relative;
}

.editor-container {
    position: relative;
    flex: 1;
    display: flex;
    overflow: hidden;
}

.line-numbers {
    width: 42px;
    min-width: 42px;
    padding: .8rem 0;
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    text-align: right;
    font-family: var(--mono);
    font-size: .82rem;
    line-height: 1.6;
    color: var(--text-muted);
    user-select: none;
    overflow: hidden;
}

.line-numbers span {
    display: flex;
    align-items: flex-start;
    /* numéro ancré en haut quand la ligne wrappe */
    justify-content: flex-end;
    padding: 0 8px 0 4px;
    min-height: 1em;
    /* sécurité : jamais plus petit qu'une ligne */
}

/* Highlight layer */
.highlight-layer {
    position: absolute;
    top: 0;
    left: 42px;
    right: 0;
    padding: .8rem;
    font-family: var(--mono);
    font-size: .82rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    pointer-events: none;
    overflow: hidden;
    color: transparent;
}

.hl-err {
    background: rgba(255, 107, 107, .15);
    border-bottom: 2px solid rgba(255, 107, 107, .5);
    border-radius: 2px;
}

.hl-warn {
    background: rgba(255, 155, 80, .12);
    border-bottom: 2px solid rgba(255, 155, 80, .45);
    border-radius: 2px;
}

.hl-info {
    background: rgba(95, 176, 255, .10);
    border-bottom: 2px solid rgba(95, 176, 255, .35);
    border-radius: 2px;
}

/* ── Textarea ─────────────────────────────────────────────── */
.code-textarea {
    flex: 1;
    resize: none;
    padding: .8rem;
    font-family: var(--mono);
    font-size: .82rem;
    line-height: 1.6;
    background: transparent;
    color: var(--text);
    border: none;
    outline: none;
    caret-color: var(--accent);
    position: relative;
    z-index: 1;
    overflow-y: hidden;
    overflow-wrap: break-word;
    min-height: 260px;
}

.code-textarea::placeholder {
    color: var(--text-dim);
    opacity: .5;
}

/* ── Controls bar ─────────────────────────────────────────── */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: .8rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

/* Toggle switch */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: .55rem;
    cursor: pointer;
    user-select: none;
}

.toggle-input {
    display: none;
}

.toggle-track {
    width: 36px;
    height: 20px;
    background: var(--border-2);
    border-radius: 99px;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: left .2s, background .2s;
}

.toggle-input:checked+.toggle-track {
    background: var(--accent);
}

.toggle-input:checked+.toggle-track::after {
    left: 19px;
    background: #fff;
}

.toggle-label {
    font-size: .82rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 1rem;
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all .15s;
    letter-spacing: .02em;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 0 var(--accent-glow);
}

.btn-primary:hover {
    background: #6b91ff;
    box-shadow: 0 0 14px var(--accent-glow);
}

.btn-primary:active {
    transform: scale(.97);
}

.btn-primary:disabled,
.btn:disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary.loading {
    animation: pulse 1s ease-in-out infinite;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-2);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: var(--surface-2);
}

.btn-sm {
    padding: .3rem .7rem;
    font-size: .72rem;
}

/* ── Results panel ────────────────────────────────────────── */
.results-panel {
    grid-area: results;
    position: relative;
}

.results-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    min-height: 200px;
}

/* Status banner */
.status-banner {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .9rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-family: var(--mono);
    font-size: .82rem;
    font-weight: 700;
}

.status-banner.valid {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(61, 220, 151, .2);
}

.status-banner.invalid {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(255, 92, 92, .2);
}

/* Counters */
.counters {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .6rem;
    margin-bottom: 1rem;
}

.counter-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem .8rem;
    text-align: center;
}

.counter-num {
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.counter-lbl {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: .2rem;
    font-family: var(--mono);
}

.counter-card.err .counter-num {
    color: var(--red);
}

.counter-card.warn .counter-num {
    color: var(--orange);
}

.counter-card.inf .counter-num {
    color: var(--blue);
}

/* Issue items */
.issue-section {
    margin-bottom: 1rem;
}

.issue-section-title {
    font-family: var(--mono);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: .35rem .6rem;
    border-radius: var(--radius) var(--radius) 0 0;
    margin-bottom: 1px;
}

.issue-section-title.err {
    color: var(--red);
    background: var(--red-bg);
}

.issue-section-title.warn {
    color: var(--orange);
    background: var(--orange-bg);
}

.issue-section-title.inf {
    color: var(--blue);
    background: var(--blue-bg);
}

.issue-list {
    list-style: none;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

.issue-item {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .55rem .8rem;
    font-size: .82rem;
    border-bottom: 1px solid var(--border);
    line-height: 1.45;
}

.issue-item:last-child {
    border-bottom: none;
}

.issue-item.err {
    border-left: 2px solid var(--red);
}

.issue-item.warn {
    border-left: 2px solid var(--orange);
}

.issue-item.inf {
    border-left: 2px solid var(--blue);
}

.issue-icon {
    flex-shrink: 0;
    font-size: .75rem;
    margin-top: .1rem;
    font-family: var(--mono);
}

.issue-item.err .issue-icon {
    color: var(--red);
}

.issue-item.warn .issue-icon {
    color: var(--orange);
}

.issue-item.inf .issue-icon {
    color: var(--blue);
}

.issue-msg {
    flex: 1;
    color: var(--text);
}

.issue-pos {
    flex-shrink: 0;
    font-family: var(--mono);
    font-size: .7rem;
    color: var(--text-dim);
    background: var(--surface-2);
    padding: .1rem .35rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    white-space: nowrap;
    align-self: flex-start;
    margin-top: .1rem;
}

/* Export bar */
.export-bar {
    display: flex;
    gap: .5rem;
    align-items: center;
    padding: .65rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.export-label {
    font-family: var(--mono);
    font-size: .7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-right: auto;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    gap: .8rem;
    color: var(--text-dim);
}

.empty-state-icon {
    font-size: 2.5rem;
    opacity: .35;
}

.empty-state-text {
    font-family: var(--mono);
    font-size: .8rem;
}

/* ── Preview panel ────────────────────────────────────────── */
.preview-panel {
    grid-area: preview;
    display: none;
}

.preview-panel.visible {
    display: flex;
}

.preview-body {
    flex: 1;
    padding: 1.2rem 1.5rem;
    overflow-y: auto;
    font-family: var(--sans);
    font-size: .95rem;
    line-height: 1.7;
    color: var(--text);
}

.preview-body h1 {
    font-size: 2em;
    font-weight: 700;
    margin: .6em 0 .3em;
    color: #f1f5f9;
    border-bottom: 1px solid var(--border);
    padding-bottom: .2em;
}

.preview-body h2 {
    font-size: 1.5em;
    font-weight: 700;
    margin: .6em 0 .25em;
    color: #e2e8f0;
}

.preview-body h3 {
    font-size: 1.17em;
    font-weight: 600;
    margin: .5em 0 .2em;
    color: #cbd5e1;
}

.preview-body h4 {
    font-size: 1em;
    font-weight: 600;
    margin: .5em 0 .2em;
    color: #94a3b8;
}

.preview-body h5 {
    font-size: .9em;
    font-weight: 600;
    margin: .4em 0 .15em;
    color: #94a3b8;
}

.preview-body h6 {
    font-size: .8em;
    font-weight: 600;
    margin: .4em 0 .15em;
    color: #64748b;
}

.preview-body p {
    margin: .35em 0;
}

.preview-body strong,
.preview-body b {
    font-weight: 700;
    color: #f1f5f9;
}

.preview-body em,
.preview-body i {
    font-style: italic;
    color: #c4b5fd;
}

.preview-body u {
    text-decoration: underline;
}

.preview-body s,
.preview-body strike,
.preview-body del {
    text-decoration: line-through;
    opacity: .7;
}

.preview-body ul {
    margin: .3em 0 .3em 1.5em;
    padding: 0;
}

.preview-body ol {
    margin: .3em 0 .3em 1.5em;
    padding: 0;
}

.preview-body li {
    margin: .1em 0;
}

.preview-body a {
    color: var(--blue);
    text-decoration: underline;
}

.preview-body a:hover {
    color: var(--purple);
}

.preview-body blockquote {
    border-left: 3px solid var(--accent);
    margin: .5em 0;
    padding: .3em .8em;
    color: var(--text-dim);
    font-style: italic;
}

.preview-body code {
    font-family: var(--mono);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: .1em .3em;
    font-size: .85em;
}

.preview-body pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .8em 1em;
    overflow-x: auto;
    margin: .5em 0;
}

.preview-body pre code {
    background: none;
    border: none;
    padding: 0;
}

.preview-body table {
    border-collapse: collapse;
    width: 100%;
    margin: .5em 0;
}

.preview-body th,
.preview-body td {
    border: 1px solid var(--border-2);
    padding: .4em .7em;
    text-align: left;
}

.preview-body th {
    background: var(--surface-2);
    font-weight: 600;
}

.preview-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: .8em 0;
}

.preview-body img {
    max-width: 100%;
    border-radius: 4px;
}

.preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    color: var(--text-muted);
    font-size: .85rem;
    gap: .4rem;
    opacity: .6;
}

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    flex-shrink: 0;
}

.btn.loading .spinner {
    display: block;
}

.btn.loading .btn-text {
    opacity: .6;
}

.panel .panel-info {
    display: block;
    padding: .75rem 1rem;
    font-family: var(--mono);
    font-size: .8rem;
    color: var(--orange);
    background: var(--orange-bg);
    border-left: 4px solid #f97316;
    border-radius: .25rem;
    margin-bottom: .75rem;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    padding: .9rem 0;
    text-align: center;
    font-family: var(--mono);
    font-size: .72rem;
    color: var(--text-dim);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 99px;
}

/* ── Animations ───────────────────────────────────────────── */
.fade-in {
    animation: fadeIn .25s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .6;
    }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
    .editor-grid.has-corrected .corrected-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {

    .editor-grid,
    .editor-grid.has-preview {
        grid-template-columns: 1fr;
        grid-template-areas: "editor" "results" "preview";
    }
}

@media (max-width: 800px) {

    .editor-grid,
    .editor-grid.has-corrected {
        grid-template-columns: 1fr;
    }

    .editor-grid.has-corrected .corrected-panel {
        grid-column: auto;
    }
}

/* ── Tab navigation ───────────────────────────────────────── */
.tab-nav {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    padding: 0;
}

.tab-list {
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .75rem 1.25rem;
    font-family: var(--mono);
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    letter-spacing: .04em;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-icon {
    font-size: .9rem;
    opacity: .8;
}

/* ── Tab panels ───────────────────────────────────────────── */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ── Excel layout ─────────────────────────────────────────── */
.excel-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}

.excel-upload-panel {
    grid-column: 1;
}

.excel-results-panel {
    grid-column: 2;
}

.excel-upload-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--border-2);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.drop-zone-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    line-height: 1;
}

.drop-zone-text {
    font-family: var(--mono);
    font-size: .85rem;
    color: var(--text-muted);
}

.drop-zone-sub {
    font-size: .75rem;
    color: var(--text-dim);
}

/* File info row */
.excel-file-info {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.excel-file-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.excel-file-details {
    flex: 1;
    min-width: 0;
}

.excel-file-name {
    font-family: var(--mono);
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.excel-file-size {
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: .1rem;
}

/* Info box */
.excel-info-box {
    background: var(--blue-bg);
    border: 1px solid rgba(95, 176, 255, .2);
    border-left: 3px solid var(--blue);
    border-radius: var(--radius);
    padding: .7rem .9rem;
    font-size: .8rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.excel-info-box em {
    color: var(--blue);
    font-style: normal;
}

/* Results body */
.excel-results-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    min-height: 260px;
}

/* Download hint */
.excel-download-hint {
    margin-top: 1rem;
    padding: .75rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .8rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.excel-download-hint strong {
    color: var(--text);
    font-family: var(--mono);
}

/* ── Responsive Excel ─────────────────────────────────────── */
@media (max-width: 900px) {
    .excel-layout {
        grid-template-columns: 1fr;
    }

    .excel-upload-panel,
    .excel-results-panel {
        grid-column: 1;
    }
}