/* ============================================================
   Styles — Test API ROMEO
   Palette : bleu France Travail + gris neutres
   ============================================================ */

/* --- Variables CSS ----------------------------------------- */
:root {
    --color-primary:     #005fcc;
    --color-primary-dk:  #004499;
    --color-danger:      #c0392b;
    --color-success:     #27ae60;
    --color-warning:     #e67e22;
    --color-text:        #1a1a2e;
    --color-text-muted:  #6c757d;
    --color-border:      #dee2e6;
    --color-bg:          #f0f4f8;
    --color-card:        #ffffff;
    --color-rank1:       #fff8e1;
    --color-rank2:       #f9f9f9;
    --radius:            6px;
    --shadow:            0 1px 4px rgba(0, 0, 0, 0.10);
}

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

/* --- Page de connexion ------------------------------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-box {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: 0.3rem;
}

.login-subtitle {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* --- En-tête application ----------------------------------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.header-left h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.header-subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.8);
}

.app-version {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    margin-left: 0.5rem;
}

/* --- Layout principal -------------------------------------- */
.app-main {
    max-width: 1000px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* --- Carte (section) --------------------------------------- */
.card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-bg);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-bg);
}

.section-header .card-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* --- Formulaires ------------------------------------------- */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
    color: var(--color-text);
}

.required-star { color: var(--color-danger); }

.mode-selector    { display: flex; flex-direction: column; gap: 0.5rem; }
.mode-option      { display: flex; align-items: flex-start; gap: 0.5rem; cursor: pointer; padding: 0.5rem 0.75rem;
                    border: 1px solid var(--color-border); border-radius: 6px; }
.mode-option:has(input:checked) { border-color: var(--color-primary); background: rgba(0,85,179,0.04); }
.mode-option input { margin-top: 3px; flex-shrink: 0; }
.type-comp        { font-size: 0.78rem; color: var(--color-text-muted); }

/* Bouton code compétence cliquable */
.btn-code-comp {
    background: none; border: 1px solid var(--color-primary); border-radius: 4px;
    color: var(--color-primary); cursor: pointer; font-family: monospace;
    font-size: 0.85rem; padding: 2px 6px;
}
.btn-code-comp:hover { background: var(--color-primary); color: white; }

/* Modale */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-box {
    background: white; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: 90%; max-width: 860px; max-height: 85vh;
    display: flex; flex-direction: column;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border);
}
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-close {
    background: none; border: none; cursor: pointer; font-size: 1.4rem;
    color: var(--color-text-muted); line-height: 1;
}
.modal-close:hover { color: var(--color-danger); }
.modal-body { padding: 1.25rem; overflow-y: auto; }

.label-hint {
    font-weight: 400;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-left: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--color-text);
    background: #fff;
    transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.12);
}

input:disabled {
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

/* Ligne de paramètres côte à côte */
.params-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.params-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.form-group-narrow {
    flex: 1;
    min-width: 160px;
    max-width: 240px;
    margin-bottom: 0;
}

.form-group-narrow input {
    width: 100%;
}

/* --- Textarea ----------------------------------------------- */
textarea#competences {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 180px;
    color: var(--color-text);
}

textarea#competences:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.12);
}

textarea#competences:disabled {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.textarea-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.3rem;
    margin-bottom: 1rem;
}

.counter {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.counter.warning {
    color: var(--color-warning);
    font-weight: 600;
}

/* --- Boutons ----------------------------------------------- */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, opacity 0.15s;
}

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

.btn-primary {
    background: var(--color-primary);
    color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dk); }

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.5);
}
.btn-secondary:hover { background: rgba(255,255,255,0.3); }

.btn-danger {
    background: var(--color-danger);
    color: white;
}
.btn-danger:hover { background: #a93226; }

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}
.btn-outline:hover { background: rgba(0, 95, 204, 0.06); }

.btn-small {
    padding: 0.3rem 0.75rem;
    font-size: 0.82rem;
}

.btn-full { width: 100%; }

.actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --- Alertes ----------------------------------------------- */
.alert {
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error   { background: #fdecea; color: #c0392b; border-left: 4px solid #c0392b; }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid #e67e22; }
.alert-info    { background: #e8f0fe; color: #004499; border-left: 4px solid #005fcc; }

/* --- Barre de progression ----------------------------------- */
.progress-track {
    height: 8px;
    background: var(--color-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-label {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Log de statut ----------------------------------------- */
.status-log {
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.82rem;
    line-height: 1.6;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem;
    background: #fafafa;
}

.status-msg {
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--color-bg);
}
.status-msg:last-child { border-bottom: none; }

.status-info    { color: var(--color-text); }
.status-success { color: var(--color-success); }
.status-warning { color: var(--color-warning); }
.status-error   { color: var(--color-danger); }
.status-debug   { color: var(--color-text); font-size: 0.8rem; }
.debug-pre      { background: #f4f4f4; border: 1px solid #ddd; border-radius: 4px; padding: 0.5rem;
                  max-height: 200px; overflow: auto; white-space: pre-wrap; word-break: break-all;
                  font-size: 0.75rem; margin-top: 0.25rem; }

/* --- Tableau de résultats ----------------------------------- */
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.results-table th {
    background: var(--color-primary);
    color: white;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.results-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

/* Alternance de couleur pour les 2 premiers rangs */
.result-row.rank-1 td { background: var(--color-rank1); }
.result-row.rank-2 td { background: var(--color-rank2); }

.results-table td.rank {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-primary);
    text-align: center;
    width: 2rem;
}

.results-table td.code-rome {
    font-family: monospace;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
}

.results-table td.libelle {
    font-weight: 500;
}

.results-table td.score {
    text-align: right;
    font-family: monospace;
    white-space: nowrap;
}

.results-table td.count {
    text-align: center;
    white-space: nowrap;
}

.results-table td.link a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}
.results-table td.link a:hover { text-decoration: underline; }

.results-legend {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    padding: 0.4rem 0;
}

/* --- Utilitaires ------------------------------------------- */
.text-muted { color: var(--color-text-muted); font-style: italic; }

/* --- Responsive -------------------------------------------- */
@media (max-width: 600px) {
    .app-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .params-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-group-narrow {
        max-width: 100%;
    }

    .results-table {
        font-size: 0.78rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.4rem 0.4rem;
    }
}
