/* ================================================================
   SOA API Tester — v1.0.0
   ================================================================ */

/* ── Variables ─────────────────────────────────────────────────── */
.soa-apt {
    --soa-purple:   #6c63ff;
    --soa-blue:     #4a90d9;
    --soa-green:    #27ae60;
    --soa-surface:  #1a1a2e;
    --soa-surface2: #141424;
    --soa-surface3: #0f0f1c;
    --soa-border:   rgba(108,99,255,.2);
    --soa-border2:  rgba(255,255,255,.07);
    --soa-text:     #e8e8f0;
    --soa-muted:    #8888aa;
    --soa-radius:   14px;
    --soa-radius-sm:8px;
    --soa-shadow:   0 8px 40px rgba(0,0,0,.55);

    /* Méthodes HTTP */
    --m-get:     #27ae60;
    --m-post:    #e67e22;
    --m-put:     #2980b9;
    --m-patch:   #8e44ad;
    --m-delete:  #e74c3c;
    --m-head:    #16a085;
    --m-options: #7f8c8d;

    /* Statuts HTTP */
    --s-2xx: #27ae60;
    --s-3xx: #f39c12;
    --s-4xx: #e74c3c;
    --s-5xx: #c0392b;

    /* Syntaxe JSON */
    --jk: #79b8ff;
    --js: #85e89d;
    --jn: #f8c555;
    --jb: #ff9e64;
    --jz: #a0a0b0;
    --jp: #8b8baa;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--soa-text);
    box-sizing: border-box;
}
.soa-apt *, .soa-apt *::before, .soa-apt *::after { box-sizing: inherit; }

/* ── Hero Card ─────────────────────────────────────────────────── */
.soa-apt__card {
    background: radial-gradient(ellipse at top left, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    border: 1px solid var(--soa-border);
    border-radius: var(--soa-radius);
    padding: 2.5rem 2.8rem 2.2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--soa-shadow);
    position: relative;
    overflow: hidden;
}
.soa-apt__card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 80% 20%, rgba(108,99,255,.12) 0%, transparent 60%);
    pointer-events: none;
}
.soa-apt__eyebrow {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--soa-purple);
    margin-bottom: .55rem;
}
.soa-apt__title {
    margin: 0 0 .5rem;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    background: linear-gradient(135deg, #fff 30%, var(--soa-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}
.soa-apt__subtitle {
    margin: 0;
    font-size: .9rem;
    color: var(--soa-muted);
    line-height: 1.55;
}

/* ── Workbench ─────────────────────────────────────────────────── */
.soa-apt__workbench {
    background: var(--soa-surface);
    border: 1px solid var(--soa-border);
    border-radius: var(--soa-radius);
    box-shadow: var(--soa-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ================================================================
   BARRE URL
   ================================================================ */
.soa-apt__urlbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    background: rgba(255,255,255,.025);
    border-bottom: 1px solid var(--soa-border);
    flex-wrap: wrap;
}

/* Sélecteur de méthode */
.soa-apt__method {
    padding: .45rem .6rem;
    border: 1px solid var(--soa-border);
    border-radius: var(--soa-radius-sm);
    background: rgba(0,0,0,.3);
    font-size: .82rem;
    font-weight: 800;
    font-family: 'Fira Code', Consolas, monospace;
    cursor: pointer;
    min-width: 100px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238888aa'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}
.soa-apt__method--get     { color: var(--m-get); }
.soa-apt__method--post    { color: var(--m-post); }
.soa-apt__method--put     { color: var(--m-put); }
.soa-apt__method--patch   { color: var(--m-patch); }
.soa-apt__method--delete  { color: var(--m-delete); }
.soa-apt__method--head    { color: var(--m-head); }
.soa-apt__method--options { color: var(--m-options); }

/* URL Input */
.soa-apt__url {
    flex: 1;
    min-width: 200px;
    padding: .45rem .8rem;
    border: 1px solid var(--soa-border);
    border-radius: var(--soa-radius-sm);
    background: rgba(0,0,0,.28);
    color: var(--soa-text);
    font-size: .85rem;
    font-family: 'Fira Code', Consolas, monospace;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}
.soa-apt__url:focus {
    border-color: var(--soa-purple);
    box-shadow: 0 0 0 2px rgba(108,99,255,.2);
}

/* Bouton Envoyer */
.soa-apt__btn-send {
    padding: .45rem 1.2rem;
    border: none;
    border-radius: var(--soa-radius-sm);
    background: var(--soa-purple);
    color: #fff;
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .1s;
    white-space: nowrap;
    flex-shrink: 0;
}
.soa-apt__btn-send:hover  { background: #5a52e0; }
.soa-apt__btn-send:active { transform: scale(.96); }
.soa-apt__btn-send--loading {
    background: #444 !important;
    cursor: not-allowed;
}

/* Groupe largeur */
.soa-apt__width-group {
    display: flex;
    align-items: center;
    gap: .3rem;
    flex-shrink: 0;
}
.soa-apt__topbar-lbl {
    font-size: .72rem;
    color: var(--soa-muted);
    white-space: nowrap;
}
.soa-apt__w-btn {
    padding: .28rem .52rem;
    border: 1px solid var(--soa-border);
    border-radius: 5px;
    background: rgba(255,255,255,.04);
    color: var(--soa-muted);
    font-size: .74rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .14s;
    min-width: 26px;
    text-align: center;
}
.soa-apt__w-btn:hover { background: rgba(108,99,255,.18); color: var(--soa-text); border-color: var(--soa-purple); }
.soa-apt__w-btn--active { background: rgba(108,99,255,.28) !important; border-color: var(--soa-purple) !important; color: #d0ccff !important; }

/* ================================================================
   PANNEAU DE REQUÊTE
   ================================================================ */
.soa-apt__req-section {
    border-bottom: 2px solid var(--soa-border);
}

/* Tab bar */
.soa-apt__req-tabbar {
    display: flex;
    background: rgba(0,0,0,.15);
    border-bottom: 1px solid var(--soa-border);
}
.soa-apt__req-tab {
    padding: .55rem 1.1rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--soa-muted);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    display: flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
}
.soa-apt__req-tab:hover { color: var(--soa-text); }
.soa-apt__req-tab--active {
    color: var(--soa-purple);
    border-bottom-color: var(--soa-purple);
}

/* Badge de comptage */
.soa-apt__tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background: rgba(108,99,255,.3);
    color: #c2bfff;
    font-size: .66rem;
    font-weight: 700;
    line-height: 1;
    display: none;
}
.soa-apt__tab-badge--visible { display: inline-flex; }

/* Contenu des onglets */
.soa-apt__req-content {
    padding: .65rem .85rem;
    min-height: 80px;
}

/* ================================================================
   KV TABLE (Params / Headers / Body form)
   ================================================================ */
.soa-apt__kv-row {
    display: grid;
    grid-template-columns: 18px 1fr 1fr 26px;
    gap: .35rem;
    align-items: center;
    margin-bottom: .3rem;
}
.soa-apt__kv-row input[type="checkbox"] {
    accent-color: var(--soa-purple);
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}
.soa-apt__kv-input {
    padding: .32rem .6rem;
    border: 1px solid var(--soa-border);
    border-radius: 5px;
    background: rgba(0,0,0,.22);
    color: var(--soa-text);
    font-size: .78rem;
    font-family: 'Fira Code', Consolas, monospace;
    outline: none;
    width: 100%;
    transition: border-color .15s;
}
.soa-apt__kv-input:focus { border-color: var(--soa-purple); }
.soa-apt__kv-input--disabled { opacity: .45; }
.soa-apt__kv-del {
    width: 22px;
    height: 22px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--soa-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, background .15s;
    padding: 0;
}
.soa-apt__kv-del:hover { color: #e74c3c; background: rgba(231,76,60,.12); border-color: rgba(231,76,60,.3); }

.soa-apt__kv-add {
    margin-top: .45rem;
    padding: .28rem .7rem;
    border: 1px dashed var(--soa-border);
    border-radius: 5px;
    background: transparent;
    color: var(--soa-muted);
    font-size: .76rem;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.soa-apt__kv-add:hover { color: var(--soa-purple); border-color: var(--soa-purple); }

/* ================================================================
   AUTH
   ================================================================ */
.soa-apt__auth-type-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .8rem;
}
.soa-apt__auth-lbl {
    font-size: .78rem;
    color: var(--soa-muted);
    white-space: nowrap;
}
.soa-apt__auth-type {
    padding: .32rem .6rem;
    border: 1px solid var(--soa-border);
    border-radius: var(--soa-radius-sm);
    background: rgba(0,0,0,.25);
    color: var(--soa-text);
    font-size: .8rem;
    cursor: pointer;
    outline: none;
}
.soa-apt__auth-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .5rem;
    margin-bottom: .6rem;
}
.soa-apt__auth-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.soa-apt__auth-field label {
    font-size: .72rem;
    color: var(--soa-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
}
.soa-apt__auth-field input,
.soa-apt__auth-field select {
    padding: .38rem .7rem;
    border: 1px solid var(--soa-border);
    border-radius: var(--soa-radius-sm);
    background: rgba(0,0,0,.25);
    color: var(--soa-text);
    font-size: .82rem;
    font-family: 'Fira Code', Consolas, monospace;
    outline: none;
    transition: border-color .15s;
}
.soa-apt__auth-field input:focus { border-color: var(--soa-purple); }
.soa-apt__auth-note {
    font-size: .74rem;
    color: var(--soa-muted);
    margin: .4rem 0 0;
    line-height: 1.45;
    font-style: italic;
}

/* ================================================================
   BODY
   ================================================================ */
.soa-apt__body-types {
    display: flex;
    gap: .3rem;
    flex-wrap: wrap;
    margin-bottom: .65rem;
}
.soa-apt__body-type {
    padding: .25rem .65rem;
    border: 1px solid var(--soa-border);
    border-radius: 20px;
    background: transparent;
    color: var(--soa-muted);
    font-size: .74rem;
    font-weight: 600;
    font-family: 'Fira Code', Consolas, monospace;
    cursor: pointer;
    transition: all .14s;
}
.soa-apt__body-type:hover { color: var(--soa-text); border-color: var(--soa-purple); }
.soa-apt__body-type--active {
    background: rgba(108,99,255,.2);
    border-color: var(--soa-purple);
    color: #c2bfff;
}
.soa-apt__body-hint {
    color: var(--soa-muted);
    font-size: .82rem;
    font-style: italic;
    margin: .5rem 0;
}
.soa-apt__body-raw-toolbar {
    display: flex;
    gap: .4rem;
    margin-bottom: .4rem;
}
.soa-apt__btn-beautify {
    padding: .22rem .6rem;
    border: 1px solid var(--soa-border);
    border-radius: 5px;
    background: rgba(255,255,255,.04);
    color: var(--soa-muted);
    font-size: .73rem;
    font-weight: 600;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.soa-apt__btn-beautify:hover { color: var(--soa-purple); border-color: var(--soa-purple); }

/* Éditeur raw */
.soa-apt__editor-wrap {
    display: flex;
    border: 1px solid var(--soa-border);
    border-radius: var(--soa-radius-sm);
    overflow: hidden;
    max-height: 240px;
}
.soa-apt__line-nums {
    width: 36px;
    flex-shrink: 0;
    background: rgba(0,0,0,.25);
    border-right: 1px solid var(--soa-border);
    padding: .7rem 0;
    overflow: hidden;
    text-align: right;
    user-select: none;
    font-family: 'Fira Code', Consolas, monospace;
    font-size: .76rem;
    line-height: 1.6;
    color: #555570;
}
.soa-apt__line-nums span { display: block; padding-right: 5px; }
.soa-apt__body-ta {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    background: rgba(0,0,0,.2);
    color: var(--soa-text);
    font-family: 'Fira Code', Consolas, monospace;
    font-size: .8rem;
    line-height: 1.6;
    padding: .7rem .8rem;
    min-height: 120px;
    overflow: auto;
    white-space: pre;
}

/* ================================================================
   PANNEAU DE RÉPONSE
   ================================================================ */
.soa-apt__resp-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 220px;
}

/* État vide */
.soa-apt__resp-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    color: var(--soa-muted);
    text-align: center;
}
.soa-apt__resp-empty-icon {
    font-size: 2.5rem;
    margin-bottom: .6rem;
    opacity: .3;
}
.soa-apt__resp-empty p { margin: 0; font-size: .88rem; }

/* Chargement */
.soa-apt__resp-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    color: var(--soa-muted);
    font-size: .88rem;
}
@keyframes soa-apt-spin { to { transform: rotate(360deg); } }
.soa-apt__spinner {
    width: 26px;
    height: 26px;
    border: 3px solid rgba(108,99,255,.25);
    border-top-color: var(--soa-purple);
    border-radius: 50%;
    animation: soa-apt-spin .75s linear infinite;
    flex-shrink: 0;
}

/* Erreur */
.soa-apt__resp-error {
    margin: .8rem 1rem;
    padding: .75rem 1rem;
    background: rgba(231,76,60,.1);
    border: 1px solid rgba(231,76,60,.35);
    border-left: 3px solid #e74c3c;
    border-radius: var(--soa-radius-sm);
    color: #fca5a5;
    font-size: .82rem;
    font-family: 'Fira Code', Consolas, monospace;
    line-height: 1.5;
}

/* Résultat */
.soa-apt__resp-result { flex: 1; display: flex; flex-direction: column; }

/* Méta-barre */
.soa-apt__resp-meta {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .55rem 1rem;
    background: rgba(0,0,0,.18);
    border-bottom: 1px solid var(--soa-border);
    flex-wrap: wrap;
}
.soa-apt__status-badge {
    display: inline-block;
    padding: .18rem .6rem;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 700;
    font-family: 'Fira Code', Consolas, monospace;
}
.soa-apt__status-badge--2xx { background: rgba(39,174,96,.18);  color: #4ade80; border: 1px solid rgba(39,174,96,.4); }
.soa-apt__status-badge--3xx { background: rgba(243,156,18,.15); color: #fbbf24; border: 1px solid rgba(243,156,18,.4); }
.soa-apt__status-badge--4xx { background: rgba(231,76,60,.15);  color: #f87171; border: 1px solid rgba(231,76,60,.4); }
.soa-apt__status-badge--5xx { background: rgba(192,57,43,.18);  color: #fc8181; border: 1px solid rgba(192,57,43,.5); }

.soa-apt__resp-time,
.soa-apt__resp-size {
    font-size: .77rem;
    color: var(--soa-muted);
    font-family: 'Fira Code', Consolas, monospace;
}
.soa-apt__resp-time strong,
.soa-apt__resp-size strong { color: var(--soa-text); }
.soa-apt__resp-meta-space { flex: 1; }

.soa-apt__btn-copy-resp {
    padding: .22rem .7rem;
    border: 1px solid var(--soa-border);
    border-radius: var(--soa-radius-sm);
    background: rgba(255,255,255,.05);
    color: var(--soa-muted);
    font-size: .74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.soa-apt__btn-copy-resp:hover { background: rgba(108,99,255,.22); color: var(--soa-text); border-color: var(--soa-purple); }
.soa-apt__btn-copy-resp--copied { color: #34d399 !important; border-color: rgba(52,211,153,.4) !important; background: rgba(52,211,153,.1) !important; }

/* Tab bar réponse */
.soa-apt__resp-tabbar {
    display: flex;
    align-items: center;
    padding: .3rem .8rem 0;
    background: rgba(0,0,0,.1);
    border-bottom: 1px solid var(--soa-border);
    gap: .1rem;
}
.soa-apt__resp-tab {
    padding: .38rem .85rem;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--soa-radius-sm) var(--soa-radius-sm) 0 0;
    background: transparent;
    color: var(--soa-muted);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: color .15s;
}
.soa-apt__resp-tab:hover { color: var(--soa-text); }
.soa-apt__resp-tab--active {
    color: var(--soa-purple);
    border-color: var(--soa-border);
    border-bottom-color: var(--soa-surface);
    background: var(--soa-surface);
}
.soa-apt__resp-tabbar-space { flex: 1; }

/* Toggle Pretty/Raw */
.soa-apt__resp-view-toggle {
    display: flex;
    gap: .2rem;
    padding-bottom: .3rem;
}
.soa-apt__view-btn {
    padding: .2rem .55rem;
    border: 1px solid var(--soa-border);
    border-radius: 4px;
    background: transparent;
    color: var(--soa-muted);
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .14s;
}
.soa-apt__view-btn:hover { color: var(--soa-text); }
.soa-apt__view-btn--active {
    background: rgba(108,99,255,.2);
    border-color: var(--soa-purple);
    color: #c2bfff;
}

/* Body de réponse */
.soa-apt__resp-body-section {
    flex: 1;
    overflow: auto;
    max-height: 440px;
    min-height: 120px;
}
.soa-apt__resp-pre {
    margin: 0;
    padding: 1rem 1.2rem;
}
.soa-apt__resp-code {
    display: block;
    font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
    font-size: .8rem;
    line-height: 1.65;
    color: var(--soa-text);
    white-space: pre;
}

/* Headers de réponse */
.soa-apt__resp-hdr-section {
    overflow: auto;
    max-height: 440px;
}
.soa-apt__resp-hdr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}
.soa-apt__resp-hdr-table th {
    text-align: left;
    padding: .45rem 1rem;
    background: rgba(0,0,0,.2);
    color: var(--soa-muted);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    border-bottom: 1px solid var(--soa-border);
}
.soa-apt__resp-hdr-table td {
    padding: .38rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.04);
    font-family: 'Fira Code', Consolas, monospace;
    vertical-align: top;
    word-break: break-all;
}
.soa-apt__resp-hdr-table td:first-child {
    color: var(--jk);
    white-space: nowrap;
    font-weight: 600;
    width: 35%;
}
.soa-apt__resp-hdr-table td:last-child { color: var(--soa-text); }
.soa-apt__resp-hdr-table tr:hover td { background: rgba(255,255,255,.025); }

/* ── Syntaxe JSON ───────────────────────────────────────────────── */
.apt-jk  { color: var(--jk); }
.apt-js  { color: var(--js); }
.apt-jn  { color: var(--jn); }
.apt-jb  { color: var(--jb); }
.apt-jz  { color: var(--jz); }
.apt-jp  { color: var(--jp); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 680px) {
    .soa-apt__urlbar { flex-wrap: wrap; }
    .soa-apt__url    { min-width: 100%; order: 2; }
    .soa-apt__method { order: 1; }
    .soa-apt__btn-send { order: 3; flex: 1; }
    .soa-apt__width-group { order: 4; }
    .soa-apt__kv-row { grid-template-columns: 18px 1fr 1fr 26px; }
    .soa-apt__auth-fields { grid-template-columns: 1fr; }
}
