/* =============================================================================
   PAGE CONFIGURATION — Style GitHub Settings
   =============================================================================
   À inclure dans header.php après widgets.css :
     <link rel="stylesheet" href="assets/css/configuration.css">
   ============================================================================= */


/* -----------------------------------------------------------------------------
   SHELL (carte externe)
   ----------------------------------------------------------------------------- */

.cfg-shell {
    background: var(--color-bg, #fff);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    border-radius: 8px;
    overflow: hidden;
}


/* -----------------------------------------------------------------------------
   QUICKSEARCH STICKY
   ----------------------------------------------------------------------------- */

.cfg-search {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--color-bg, #fff);
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
}

.cfg-search-icon {
    display: inline-flex;
    color: var(--color-text-light, #888);
    flex-shrink: 0;
}

.cfg-search input[type="search"] {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    outline: none;
    color: var(--color-text, #1a1a1a);
    padding: 4px 0;
}

.cfg-search input[type="search"]::placeholder {
    color: var(--color-text-light, #999);
}

.cfg-search-shortcut {
    font-size: 11px;
    color: var(--color-text-light, #888);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.10));
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    flex-shrink: 0;
}


/* -----------------------------------------------------------------------------
   TABS HORIZONTALES (NIVEAU 1)
   -----------------------------------------------------------------------------
   Note : pas de overflow:auto en desktop (sinon scrollbar fantôme).
   Le scroll horizontal ne s'active qu'en responsive (cf. media query).
   ----------------------------------------------------------------------------- */

.cfg-tabs {
    display: flex;
    gap: 0;
    padding: 0 18px;
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    flex-wrap: wrap;
}

.cfg-tab {
    background: transparent;
    border: none;
    padding: 12px 14px;
    margin-right: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.cfg-tab:hover {
    color: var(--color-text, #1a1a1a);
}

.cfg-tab.is-active {
    color: var(--color-text, #1a1a1a);
    border-bottom-color: var(--color-text, #1a1a1a);
    font-weight: 600;
}


/* -----------------------------------------------------------------------------
   LAYOUT 2 COLONNES
   ----------------------------------------------------------------------------- */

.cfg-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 480px;
}


/* -----------------------------------------------------------------------------
   SIDEBAR GAUCHE (SECTIONS / NIVEAU 2)
   ----------------------------------------------------------------------------- */

.cfg-sidebar {
    border-right: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    padding: 14px 0;
    background: var(--color-bg-soft, #fafafa);
}

.cfg-sidebar-group[hidden] {
    display: none;
}

.cfg-section {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 8px 18px;
    font-size: 13px;
    color: var(--color-text-secondary, #4b5563);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.cfg-section:hover {
    background: rgba(0, 0, 0, 0.03);
    color: var(--color-text, #1a1a1a);
}

.cfg-section.is-active {
    background: var(--color-bg, #fff);
    color: var(--color-text, #1a1a1a);
    font-weight: 600;
    border-left-color: var(--color-text, #1a1a1a);
}


/* -----------------------------------------------------------------------------
   ZONE CENTRALE (PANNEAUX D'ÉDITION)
   ----------------------------------------------------------------------------- */

.cfg-main {
    padding: 24px 28px;
    background: var(--color-bg, #fff);
}

.cfg-panel[hidden] {
    display: none;
}

.cfg-panel-header {
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.06));
}

.cfg-panel-title {
    margin: 0 0 4px 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text, #1a1a1a);
}

.cfg-panel-sub {
    margin: 0;
    font-size: 12px;
    color: var(--color-text-muted, #6b7280);
}

.cfg-panel-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
}


/* -----------------------------------------------------------------------------
   CHAMPS (label + input)
   ----------------------------------------------------------------------------- */

.cfg-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cfg-field-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
}

.cfg-field-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
}

.cfg-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text, #1a1a1a);
}

.cfg-required {
    color: #dc2626;
    font-weight: 700;
}

.cfg-help {
    font-size: 12px;
    color: var(--color-text-muted, #6b7280);
}

.cfg-help code {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.05);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
}


/* -----------------------------------------------------------------------------
   INPUTS / TEXTAREAS / SELECTS
   ----------------------------------------------------------------------------- */

.cfg-input,
.cfg-textarea,
select.cfg-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--color-text, #1a1a1a);
    background: var(--color-bg, #fff);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.cfg-input:focus,
.cfg-textarea:focus,
select.cfg-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

select.cfg-input[multiple] {
    padding: 6px;
    min-height: 88px;
}

.cfg-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.cfg-textarea-mono {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
}

.cfg-input[type="file"] {
    padding: 6px 8px;
    cursor: pointer;
}


/* -----------------------------------------------------------------------------
   INPUT GROUP (input + boutons d'action à droite)
   ----------------------------------------------------------------------------- */

.cfg-input-group {
    display: flex;
    align-items: stretch;
    gap: 4px;
}

.cfg-input-group .cfg-input {
    flex: 1;
}

.cfg-input-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    background: var(--color-bg-soft, #fafafa);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
    border-radius: 6px;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    flex-shrink: 0;
}

.cfg-input-action:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--color-text, #1a1a1a);
}


/* -----------------------------------------------------------------------------
   COLOR PICKER (tag form)
   ----------------------------------------------------------------------------- */

.cfg-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cfg-color-input {
    width: 44px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
    border-radius: 6px;
    background: var(--color-bg, #fff);
    cursor: pointer;
}

.cfg-tag-preview {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}


/* -----------------------------------------------------------------------------
   SWITCH (toggle on/off)
   ----------------------------------------------------------------------------- */

.cfg-switch {
    display: inline-flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.cfg-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.cfg-switch-track {
    width: 38px;
    height: 22px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 11px;
    position: relative;
    transition: background 0.18s ease;
}

.cfg-switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.18s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.cfg-switch input:checked + .cfg-switch-track {
    background: #2563eb;
}

.cfg-switch input:checked + .cfg-switch-track::after {
    transform: translateX(16px);
}

.cfg-switch-wide {
    gap: 10px;
}

.cfg-switch-labels {
    font-size: 12px;
    color: var(--color-text-muted, #6b7280);
    user-select: none;
}

.cfg-switch-label-on { display: none; }
.cfg-switch-label-off { display: inline; }

.cfg-switch input:checked ~ .cfg-switch-labels .cfg-switch-label-on { display: inline; color: #2563eb; font-weight: 600; }
.cfg-switch input:checked ~ .cfg-switch-labels .cfg-switch-label-off { display: none; }


/* -----------------------------------------------------------------------------
   BLOCS DE SECTION INTERNES
   ----------------------------------------------------------------------------- */

.cfg-section-block {
    padding: 16px;
    background: var(--color-bg-soft, #fafafa);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.06));
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cfg-section-title {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted, #6b7280);
}


/* -----------------------------------------------------------------------------
   ACTIONS (boutons)
   ----------------------------------------------------------------------------- */

.cfg-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.cfg-btn {
    background: var(--color-bg, #fff);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15));
    color: var(--color-text, #1a1a1a);
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.cfg-btn:hover {
    background: var(--color-bg-soft, #f5f5f5);
    border-color: var(--color-border, rgba(0, 0, 0, 0.25));
}

.cfg-btn-primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.cfg-btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}


/* -----------------------------------------------------------------------------
   TABLES
   ----------------------------------------------------------------------------- */

.cfg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.cfg-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted, #6b7280);
    background: var(--color-bg-soft, #fafafa);
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.10));
}

.cfg-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.06));
    color: var(--color-text, #1a1a1a);
}

.cfg-table tbody tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

.cfg-th-actions { width: 120px; text-align: right; }

.cfg-table-empty td {
    text-align: center;
    padding: 28px 12px;
    color: var(--color-text-light, #999);
    font-style: italic;
}

.cfg-table-empty:hover td { background: transparent !important; }


/* -----------------------------------------------------------------------------
   ACTIONS DE LIGNE (crayon, poubelle)
   ----------------------------------------------------------------------------- */

.cfg-cell-actions {
    text-align: right;
    white-space: nowrap;
}

.cfg-cell-muted {
    color: var(--color-text-light, #999);
    font-style: italic;
}

.cfg-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: 4px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.cfg-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text, #1a1a1a);
    border-color: var(--color-border, rgba(0, 0, 0, 0.10));
}

.cfg-icon-btn-danger:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.20);
}


/* -----------------------------------------------------------------------------
   BADGES (Manuel / Sync VF dans les tableaux)
   ----------------------------------------------------------------------------- */

.cfg-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-muted, #6b7280);
}

.cfg-badge-vf {
    background: rgba(37, 99, 235, 0.10);
    color: #1d4ed8;
}


/* -----------------------------------------------------------------------------
   CHAMPS VERROUILLÉS (entités Sync VF : nom / adresse / ID en lecture seule)
   ----------------------------------------------------------------------------- */

.cfg-input.is-locked,
.cfg-textarea.is-locked {
    background: var(--color-bg-soft, #fafafa);
    color: var(--color-text-muted, #6b7280);
    cursor: not-allowed;
    border-color: var(--color-border, rgba(0, 0, 0, 0.08));
}

.cfg-field.is-locked .cfg-label::after {
    content: ' 🔒';
    font-size: 11px;
    opacity: 0.6;
}


/* -----------------------------------------------------------------------------
   DIAGNOSTIC SERVEUR
   ----------------------------------------------------------------------------- */

.cfg-diag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.cfg-diag-card {
    padding: 14px 16px;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.10));
    border-radius: 6px;
    background: var(--color-bg, #fff);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cfg-diag-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted, #6b7280);
}

.cfg-diag-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text, #1a1a1a);
}

.cfg-diag-hint {
    font-size: 11px;
    color: var(--color-text-light, #999);
}

.cfg-diag-card.is-ok .cfg-diag-value {
    color: #0F6E56;
}

.cfg-diag-card.is-alert {
    border-color: rgba(163, 45, 45, 0.30);
    background: rgba(163, 45, 45, 0.04);
}

.cfg-diag-card.is-alert .cfg-diag-value {
    color: #A32D2D;
}


/* -----------------------------------------------------------------------------
   FORMULAIRES DANS LE DRAWER (templates new-user, new-tag)
   -----------------------------------------------------------------------------
   .cfg-drawer-form    → conteneur form injecté dans .right-drawer-body
   .cfg-drawer-section → bloc avec séparateur (ex. "SMTP personnel")
   .cfg-drawer-actions → footer du formulaire (Annuler / Créer)
   ----------------------------------------------------------------------------- */

.cfg-drawer-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0;
}

.cfg-drawer-section {
    padding-top: 16px;
    margin-top: 4px;
    border-top: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cfg-drawer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
}


/* -----------------------------------------------------------------------------
   RESPONSIVE
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {

    .cfg-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .cfg-layout {
        grid-template-columns: 1fr;
    }

    .cfg-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.08));
        padding: 8px 0;
        display: flex;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .cfg-sidebar-group {
        display: flex;
        gap: 4px;
        padding: 0 12px;
    }

    .cfg-section {
        padding: 6px 12px;
        border-left: none;
        border-bottom: 2px solid transparent;
        white-space: nowrap;
        border-radius: 4px;
        width: auto;
    }

    .cfg-section.is-active {
        border-left: none;
        border-bottom-color: var(--color-text, #1a1a1a);
        background: transparent;
    }

    .cfg-main {
        padding: 18px;
    }

    .cfg-field-grid {
        grid-template-columns: 1fr;
    }
}
