:root {
    --md-sys-primary: #0061a4;
    --md-sys-on-primary: #ffffff;
    --md-sys-primary-container: #d1e4ff;
    --md-sys-on-primary-container: #001d36;
    --md-sys-secondary: #535f70;
    --md-sys-surface: #fdfcff;
    --md-sys-surface-container-highest: #e1e2e6;
    --md-sys-on-surface: #1a1c1e;
    --md-sys-on-surface-variant: #43474e;
    --md-sys-outline: #73777f;
    --font-family: 'Google Sans', sans-serif;
}
body {
    font-family: var(--font-family);
    background-color: var(--md-sys-surface);
    color: var(--md-sys-on-surface);
    margin: 0;
    overflow: hidden;
}
.app-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100vh;
}
.sidebar {
    background-color: #f4f7fb;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--md-sys-surface-container-highest);
}
.sidebar h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--md-sys-primary);
    margin: 0 0 32px 0;
}
.step { margin-bottom: 24px; }
.step-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}
.step-number {
    background-color: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 12px;
}
.step-title { font-size: 18px; font-weight: 700; }
.workflow-selector { display: flex; flex-direction: column; gap: 12px; }
.workflow-option {
    padding: 16px;
    border: 1px solid var(--md-sys-outline);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.workflow-option.active {
    border-color: var(--md-sys-primary);
    background-color: var(--md-sys-primary-container);
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--md-sys-on-surface-variant);
}
.form-group select, .form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--md-sys-outline);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
}
/* Custom File Input */
.file-input-wrapper {
    border: 2px dashed var(--md-sys-outline);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s;
}
.file-input-wrapper:hover { border-color: var(--md-sys-primary); }
.file-input-wrapper span {
    display: block;
    color: var(--md-sys-on-surface-variant);
}
input[type="file"] { display: none; }

.content-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.main-content {
    flex-grow: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    /* overflow-y: auto; */ /* Retiré pour que le conteneur principal ne scrolle plus */
    min-height: 0;
}
.stats-area {
    flex-shrink: 0;
}
.progress-visualization {
    flex-shrink: 0;
}
.results-card {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}
.server-logs-card {
    flex-shrink: 0;
    max-height: 250px;
    margin: 0 24px 24px 24px;
    display: flex;
    flex-direction: column;
}
.card {
    background-color: #fff;
    border-radius: 16px;
    border: 1px solid var(--md-sys-surface-container-highest);
}
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    border-bottom: 1px solid var(--md-sys-surface-container-highest);
}
.results-tabs { display: flex; }
.results-actions { display: flex; gap: 12px; }
.tab {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    color: var(--md-sys-on-surface-variant);
}
.tab.active { color: var(--md-sys-primary); border-bottom-color: var(--md-sys-primary); }
.tab-content { 
    padding: 24px; 
    line-height: 1.7; 
    overflow-y: auto; /* Ajout du scroll ici */
    flex-grow: 1; /* Permet au contenu de prendre la place disponible */
    min-height: 0; /* Correction pour le flexbox scroll */
}
.btn {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 100px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}
.btn-primary { background-color: var(--md-sys-primary); color: var(--md-sys-on-primary); }
.btn-primary:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.btn-tonal { background-color: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container); }
.btn-secondary {
    width: 100%;
    background-color: transparent;
    color: var(--md-sys-secondary);
    border: 1px solid var(--md-sys-outline);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--md-sys-surface-container-highest);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.copyright {
    font-size: 12px;
    color: var(--md-sys-on-surface-variant);
    text-align: center;
    margin-top: 16px;
}

/* Stats */
#main-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 colonnes */
    gap: 16px;
    margin-bottom: 16px;
}
#file-info-card .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 colonnes pour les infos fichier */
    gap: 16px;
}
.chart-card {
    max-height: 150px;
}
.stat-card {
    background-color: #f4f7fb;
    padding: 16px;
    border-radius: 12px;
}
.stat-card-title {
    font-size: 14px;
    color: var(--md-sys-on-surface-variant);
    margin-bottom: 8px;
}
.stat-card-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--md-sys-primary);
}
.chart-placeholder {
    height: 150px;
    background-color: #f4f7fb;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-on-surface-variant);
}
.placeholder {
    padding: 24px;
    text-align: center;
    color: var(--md-sys-on-surface-variant);
}

/* --- Progress Visualization --- */
.progress-visualization {
    background-color: #f4f7fb;
    border-radius: 12px;
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
}
.chunks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16px, 1fr));
    gap: 6px;
}
.chunk {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    transition: background-color 0.5s ease;
}
.chunk.pending {
    background-color: #e0e0e0; /* Gray */
}
.chunk.processing {
    background-color: #64b5f6; /* Blue */
    animation: pulse 1.5s infinite;
}
.chunk.retrying {
    background-color: #ffa726; /* Orange */
    animation: pulse 1s infinite;
}
.chunk.completed {
    background-color: #81c784; /* Green */
}
.chunk.error {
    background-color: #e57373; /* Red */
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* --- Server Logs --- */
.server-logs-header {
    padding: 16px;
    font-weight: 700;
    border-bottom: 1px solid var(--md-sys-surface-container-highest);
}
.server-logs-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    color: var(--md-sys-on-surface-variant);
    white-space: pre-line; /* Permet le retour à la ligne automatique */
    word-break: break-all; /* Casse les mots longs si nécessaire */
}
.server-logs-content p {
    margin: 0 0 4px 0;
}

/* --- Markdown Content Styling --- */
.tab-content p {
    margin-top: 0;
}
.tab-content h1, .tab-content h2, .tab-content h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 700;
}
.tab-content ul, .tab-content ol {
    padding-left: 2em;
}
.tab-content li {
    margin-bottom: 0.5em;
}
.tab-content strong {
    font-weight: 700;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal-content {
    background-color: #fff;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--md-sys-surface-container-highest);
    padding-bottom: 16px;
    margin-bottom: 16px;
}
.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--md-sys-primary);
}
.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--md-sys-on-surface-variant);
}
.modal-body h3 {
    font-size: 16px;
    font-weight: 700;
    margin-top: 24px;
    margin-bottom: 8px;
}
.modal-body a {
    color: var(--md-sys-primary);
    text-decoration: none;
    font-weight: 500;
}
.modal-body a:hover {
    text-decoration: underline;
}
.modal-body ol, .modal-body ul {
    padding-left: 20px;
}
