:root {
    /* Color Palette - Vibrant Dark Mode Base */
    --bg-base: #0f172a;
    --bg-surface: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-stack);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    /* overflow: hidden; Removed to allow infinite scroll */
}

/* Typography */
h1,
h2,
h3,
h4 {
    color: var(--text-main);
    font-weight: 600;
}

.text-primary {
    color: var(--primary);
}

.text-muted {
    color: var(--text-muted);
}

/* Layout Grid */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

.sidebar {
    width: 320px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    z-index: 10;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
}

.search-box {
    margin: 1rem;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.numbers-list-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 1rem 1rem 1rem;
}

.numbers-list {
    list-style: none;
}

.number-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.number-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.number-item.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Allows the entire page to scroll */
    overflow-x: hidden;
    position: relative;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 400px),
        radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.15), transparent 400px);
}

.top-bar {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.selected-client h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-outline {
    border: 1px solid var(--primary);
    color: var(--primary);
}

.api-key-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.5);
    padding: 0.25rem 0.25rem 0.25rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
}

.api-key-input i {
    color: var(--text-muted);
}

.api-key-input input {
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    width: 250px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    min-height: calc(100vh - 85px);
    /* No fixed height, allows content to stretch the layout as needed */
}

.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.panel-header h3 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Logs Container */
.logs-container {
    flex-grow: 1;
    overflow-y: auto;
    /* Scroll interne : les messages récents sont en bas */
    max-height: 70vh;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 1rem;
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.5;
}

.log-entry {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 1rem;
    border-left: 3px solid var(--primary);
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.log-entry.bot {
    border-left-color: var(--accent);
    background: rgba(139, 92, 246, 0.05);
}

.log-entry.user {
    border-left-color: var(--info);
    background: rgba(14, 165, 233, 0.05);
}

/* Analysis Panel */
.action-buttons {
    padding: 1rem 1.25rem;
    display: flex;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-glass);
}

.analysis-result-container {
    flex-grow: 1;
    overflow-y: visible;
    /* LIBERE LE DEFILEMENT QUI ETAIT BLOQUE ICI */
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.ai-response {
    background: rgba(15, 23, 42, 0.6);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.6;
    height: auto;
    min-height: 60vh;
    overflow-y: visible;
    overflow-wrap: anywhere;
}

.ai-response.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
    min-height: 200px;
    /* Force minimum height when empty */
}

.deployment-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    flex-shrink: 0;
    /* Prevent shrinking when answer is long */
}

.deployment-section h4 {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--success);
}

.feedback-group {
    margin-bottom: 1rem;
}

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

.rating-buttons {
    display: flex;
    gap: 0.5rem;
}

.deploy-action {
    display: flex;
    gap: 0.5rem;
    flex-grow: 1;
    justify-content: flex-end;
}

/* Inputs & Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: var(--font-stack);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-md);
    width: 36px;
    height: 36px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-accent:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-warning {
    background: var(--warning);
    color: #1e293b;
}

.btn-warning:hover {
    filter: brightness(1.1);
}

.btn-info {
    background: var(--info);
    color: white;
}

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

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-outline-success {
    background: transparent;
    border: 1px solid var(--success);
    color: var(--success);
}

.btn-outline-success:hover {
    background: rgba(16, 185, 129, 0.1);
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.select-input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    outline: none;
    font-family: var(--font-stack);
    cursor: pointer;
}

.textarea-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    outline: none;
    font-family: var(--font-stack);
    resize: vertical;
}

.textarea-input:focus {
    border-color: var(--primary);
}

.hidden {
    display: none !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform: translateY(0);
    opacity: 1;
}

.toast.hidden {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

/* Animations */
@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.loading-text {
    animation: pulse 1.5s infinite;
}

/* Markdown Styles dans AI Response */
.ai-response h1,
.ai-response h2,
.ai-response h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.ai-response p {
    margin-bottom: 1rem;
}

.ai-response ul,
.ai-response ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.ai-response code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

.ai-response pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.ai-response blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--text-muted);
}

/* Progress Bar */
.progress-container {
    width: 100%;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--info));
    background-size: 200% 100%;
    animation: progress-gradient 1.5s ease infinite;
    transition: width 0.3s ease;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

@keyframes progress-gradient {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.progress-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-percent {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.9rem;
}

.progress-steps {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all 0.3s;
}

.progress-step.active {
    color: var(--text-main);
}

.progress-step.done {
    color: var(--success);
}

.progress-step i {
    width: 16px;
    text-align: center;
}.inline-feedback { display: flex; gap: 0.5rem; } .btn-log-thumb { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
