/* ============= VARIABLES ============= */

:root {
    --primary: #7c3aed;
    --primary-dark: #6d28d9;
    --success: #059669;
    --danger: #dc2626;
    --text: #1e1b4b;
    --text-light: #6b7280;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px rgba(124, 58, 237, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    --code-bg: #0f172a;
}

/* ============= RESET & BASE ============= */

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

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: linear-gradient(135deg, #ddd6fe 0%, #e0f2fe 55%, #fce7f3 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* ============= LAYOUT ============= */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ============= HEADER ============= */

header {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px 16px 12px;
}

header h1 {
    font-size: 2em;
    font-weight: 700;
    background: linear-gradient(135deg, #7c3aed, #0ea5e9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.header-tagline {
    font-size: 0.75em;
    color: var(--text-light);
    font-family: 'Courier New', monospace;
    opacity: 0.8;
}

/* ============= TABS NAVIGATION ============= */

.tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 12px;
    box-shadow: var(--glass-shadow);
}

.tab-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-right: 10px;
    border-right: 1px solid var(--glass-border);
}

.tab-group:last-child {
    border-right: none;
    padding-right: 0;
}

.tab-group-label {
    font-size: 0.6em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-light);
    padding: 0 4px;
    opacity: 0.65;
}

.tab-group-btns {
    display: flex;
    gap: 3px;
}

.form-section-label {
    font-size: 0.65em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-light);
    opacity: 0.65;
    margin: 4px 0 0;
    padding-top: 8px;
    border-top: 1px solid var(--glass-border);
}

.tab-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 0.875em;
    font-weight: 500;
    color: var(--text-light);
    transition: color 0.2s ease, background 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover:not([disabled]) {
    color: var(--primary);
    background: rgba(124, 58, 237, 0.08);
}

.tab-btn.active {
    background: rgba(124, 58, 237, 0.15);
    color: var(--primary);
    font-weight: 600;
}

.tab-btn--soon {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ============= TAB CONTENT ============= */

.tab-content {
    display: none;
    animation: fadeIn 0.15s ease;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ============= TAB ACTIONS ============= */

.tab-actions {
    display: none;
    flex-direction: column;
    gap: 10px;
}

.tab-actions.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============= SPLIT LAYOUT ============= */

.split-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 14px;
    align-items: start;
}

/* ============= COLONNE GAUCHE ============= */

.split-left {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--glass-shadow);
    position: sticky;
    top: 16px;
}

/* Formulaire vertical */

#birthForm {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-weight: 700;
    font-size: 0.7em;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 8px;
    font-size: 0.875em;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-group input:hover {
    border-color: rgba(124, 58, 237, 0.4);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
    background: rgba(255, 255, 255, 0.9);
}

/* Bouton principal */

.btn-call {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    color: white;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
    transition: all 0.2s ease;
    margin-top: 4px;
}

.btn-call:not(:disabled):hover {
    background: linear-gradient(135deg, #6d28d9, #4f46e5);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
    transform: translateY(-1px);
}

.btn-call:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Lien effacer */

.btn-clear-link {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.75em;
    cursor: pointer;
    text-decoration: underline;
    text-align: center;
    padding: 2px;
    transition: color 0.2s ease;
}

.btn-clear-link:hover {
    color: var(--danger);
}

/* ============= SPINNER ============= */

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

.btn-spinner {
    display: none;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.btn-call.loading .btn-spinner {
    display: inline-block;
}

/* ============= STATUS DISPLAY ============= */

.status-display {
    padding: 8px 12px;
    border-radius: 8px;
    display: none;
    font-weight: 500;
    font-size: 0.8em;
    border: 1px solid transparent;
}

.status-display.success {
    display: block;
    background: rgba(5, 150, 105, 0.12);
    color: #065f46;
    border-color: rgba(5, 150, 105, 0.3);
}

.status-display.error {
    display: block;
    background: rgba(220, 38, 38, 0.10);
    color: #991b1b;
    border-color: rgba(220, 38, 38, 0.25);
}

.status-display.loading {
    display: block;
    background: rgba(2, 132, 199, 0.10);
    color: #075985;
    border-color: rgba(2, 132, 199, 0.25);
}

/* ============= COLONNE DROITE ============= */

.split-right {
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
}

.result-pane {
    border-top: 1px solid var(--glass-border);
}

.result-pane:first-child {
    border-top: none;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.result-header:hover {
    background: rgba(255, 255, 255, 0.85);
}

.result-header h4 {
    font-size: 0.875em;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

.chevron {
    margin-left: auto;
    font-size: 0.75em;
    color: var(--text-light);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    line-height: 1;
}

.result-pane.collapsed .chevron {
    transform: rotate(-90deg);
}

.result-pane.collapsed .result-header {
    border-bottom: none;
}

/* ============= JSON DISPLAY ============= */

.json-display {
    background: var(--code-bg);
    color: #d4d4d4;
    padding: 14px;
    font-family: 'Courier New', 'Monaco', 'Consolas', monospace;
    font-size: 0.75em;
    line-height: 1.65;
    max-height: 450px;
    min-height: 200px;
    overflow: auto;
    white-space: pre-wrap;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease;
    word-break: break-word;
    scrollbar-width: thin;
    scrollbar-color: #334155 #1e293b;
}

.prompt-display {
    background: rgba(248, 250, 252, 0.85);
    color: var(--text);
    padding: 14px;
    font-family: 'Courier New', 'Monaco', 'Consolas', monospace;
    font-size: 0.75em;
    line-height: 1.65;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.result-pane.collapsed .prompt-display {
    max-height: 0;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.result-pane.collapsed .json-display {
    max-height: 0;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.json-display::-webkit-scrollbar { width: 8px; height: 8px; }
.json-display::-webkit-scrollbar-track { background: #1e293b; }
.json-display::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.json-display::-webkit-scrollbar-thumb:hover { background: #475569; }

.json-display:empty::before {
    content: 'En attente…';
    color: #4b5563;
    font-style: italic;
}

/* PDF Output */
.pdf-output {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: opacity 0.2s;
}

.btn-download:hover { opacity: 0.85; }

/* JSON Syntax Coloring */

.json-key     { color: #ce9178; }
.json-string  { color: #6a9955; }
.json-number  { color: #b5cea8; }
.json-boolean { color: #569cd6; font-weight: bold; }
.json-null    { color: #c586c0; font-weight: bold; }

/* ============= COPY BUTTON ============= */

.btn-copy {
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.3);
    color: var(--text-light);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.65);
    color: var(--primary);
    border-color: rgba(124, 58, 237, 0.3);
}

.btn-copy.copied {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* ============= SECTION CLAUDE ============= */

.claude-section {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.claude-status-badge {
    font-size: 0.75em;
    color: var(--text-light);
    font-style: italic;
}

.claude-section.error .claude-status-badge {
    color: var(--danger);
    font-style: normal;
}

.claude-output {
    padding: 16px;
    font-size: 0.85em;
    color: var(--text);
    line-height: 1.6;
    max-height: 60000px;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.4s ease;
}

.result-pane.collapsed .claude-output {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.claude-output:empty {
    display: none;
}

.claude-output h2,
.claude-output h3 {
    color: var(--primary);
    font-size: 0.95em;
    font-weight: 700;
    margin: 20px 0 8px;
}

.claude-output h2:first-child,
.claude-output h3:first-child {
    margin-top: 0;
}

.claude-output table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 0.9em;
}

.claude-output th {
    background: rgba(124, 58, 237, 0.1);
    color: var(--primary);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    border: 1px solid rgba(124, 58, 237, 0.15);
    white-space: nowrap;
}

.claude-output td {
    padding: 7px 12px;
    border: 1px solid rgba(124, 58, 237, 0.08);
    vertical-align: top;
}

.claude-output tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.4);
}

.claude-output ol {
    padding-left: 20px;
    margin-bottom: 16px;
}

.claude-output li {
    margin-bottom: 6px;
}

.claude-output p {
    margin-bottom: 10px;
}

/* ============= RESPONSIVE ============= */

@media (max-width: 900px) {
    .split-layout {
        grid-template-columns: 220px 1fr;
    }
}

@media (max-width: 768px) {
    .split-layout {
        grid-template-columns: 1fr;
    }

    .split-left {
        position: static;
    }

    .json-display {
        height: 400px;
        min-height: unset;
    }

    .tabs-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
}

@media (max-width: 480px) {
    header h1 { font-size: 1.5em; }
    .form-group input { font-size: 16px; } /* empêche le zoom iOS */
    .json-display { height: 320px; font-size: 0.7em; }
}
