/**
 * NcStatusCheck - Surveillance centralisée et simplifiée d'instances Nextcloud
 * 
 * Feuille de style spécifique à l'interface d'administration.
 * Inclut les styles pour la configuration des versions, la gestion
 * des serveurs, les notifications et les dialogues de confirmation.
 */

/* === SECTIONS D'ADMINISTRATION === */

.admin-section {
    background: var(--gray-50);
    border: 1px solid var(--gray-100);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

/* === TABLEAU RÉCAPITULATIF DES MODES DE COLLECTE === */

.probe-modes-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.9rem;
}

.probe-modes-table th,
.probe-modes-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
}

.probe-modes-table thead th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.probe-modes-table tbody tr:last-child td {
    border-bottom: none;
}

.probe-modes-table code {
    font-size: 0.8rem;
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 3px;
}

/* === CONFIGURATION DES VERSIONS === */

/* Grille de configuration des versions */
.version-config {
    display: grid;
    grid-template-columns: 1fr 200px 200px 150px 100px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #e8eaed;
    border-left: 3px solid transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s ease, border-left-color 0.2s ease;
}

.version-config:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.09);
    border-left-color: #0082c9;
}

.version-config input, 
.version-config select {
    padding: 8px;
    border: 1px solid var(--gray-100);
    border-radius: 4px;
    font-size: 0.875rem;
}

/* En-tête de la grille de configuration */
.config-header {
    display: grid;
    grid-template-columns: 1fr 200px 200px 150px 100px;
    gap: 12px;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-100);
    margin-bottom: 16px;
}

/* Bouton d'ajout de version */
.add-version {
    background: none;
    border: 2px dashed var(--gray-100);
    border-radius: 6px;
    padding: 12px;
    color: var(--gray-500);
    cursor: pointer;
    text-align: center;
    font-size: 0.875rem;
}

.add-version:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* === APERÇUS DES STATUTS === */

.status-preview {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

.status-dev { 
    background: linear-gradient(135deg, #a855f7, #7c3aed); 
    color: white; 
}

.status-stable { 
    background: #059669; 
    color: white; 
}

.status-oldstable { 
    background: #10b981; 
    color: white; 
}

.status-deprecated { 
    background: #f59e0b; 
    color: white; 
}

.status-eol { 
    background: #ef4444; 
    color: white; 
}

/* === ACTIONS DE FORMULAIRE === */

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
}

/* === GESTION DES SERVEURS === */

.server-add-form {
    margin-bottom: 24px;
}

.input-group {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.input-group input[type="url"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-100);
    border-radius: 6px;
    font-size: 0.875rem;
}

.servers-list h3 {
    margin: 16px 0 8px 0;
    font-size: 1rem;
    color: var(--gray-700);
}

/* === RECHERCHE DE SERVEURS === */

.servers-search-bar {
    margin-bottom: 14px;
}

.servers-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.servers-search-input-wrap input {
    width: 100%;
    padding: 8px 36px 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    color: var(--gray-800);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.servers-search-input-wrap input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 130, 201, 0.12);
}

.servers-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    font-size: 0.85rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
}

.servers-search-clear:hover {
    color: var(--gray-700);
    background: var(--gray-100);
}

.servers-search-count {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--gray-500);
}

.servers-no-result {
    padding: 12px 16px;
    color: var(--gray-500);
    font-style: italic;
    font-size: 0.875rem;
    text-align: center;
    background: var(--gray-50);
    border: 1px dashed var(--gray-200);
    border-radius: 8px;
    margin-top: 8px;
}

/* === CARTES DE SERVEUR === */

.server-card {
    background: white;
    border: 1px solid #e8eaed;
    border-left: 3px solid transparent; /* remplace le bord gauche — couleur selon état au hover */
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-left-color 0.2s ease;
}

/* === HOVER CARTES SERVEUR === */

.server-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
}

/* Couleur de la bordure gauche selon l'état de santé */
.server-card[data-health="none"]:hover  { border-left-color: #0082c9; }
.server-card[data-health="ok"]:hover    { border-left-color: var(--success-color); }
.server-card[data-health="warn"]:hover  { border-left-color: var(--warning-color); }
.server-card[data-health="error"]:hover { border-left-color: var(--error-color, #ef4444); }

/* Bouton "Configurer les tokens" : discret au repos, plein au survol de la carte */
.server-card .btn-token-open {
    opacity: 0.6;
    transition: background 0.15s, color 0.15s, opacity 0.2s ease, border-color 0.15s;
}

.server-card:hover .btn-token-open {
    opacity: 1;
}

.server-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #eaecf0;
}

.server-card-header .server-url {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-card-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.server-card-tokens {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.token-zone {
    padding: 12px 16px;
}

.token-zone + .token-zone {
    border-left: 1px solid #eaecf0;
}

.token-zone-serverinfo {
    background: #f8f9fc;
}

.token-zone-push {
    background: #f8f9fc;
}

.token-zone-title {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-700);
    margin-bottom: 2px;
}

.token-zone-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-bottom: 10px;
}

.token-display-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.token-masked {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.82rem;
    color: #444;
    background: #d8dde5;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.08em;
    word-break: break-all;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

.token-script-row {
    margin-top: 8px;
}

.btn-tiny {
    padding: 2px 8px;
    font-size: 0.78rem;
    line-height: 1.6;
}

.btn-ghost {
    background: none;
    border: 1px solid var(--gray-200);
    color: var(--gray-400);
}

.btn-ghost:hover {
    border-color: var(--error-color);
    color: var(--error-color);
    background: #fee2e2;
}

/* Lien discret sur l'URL du serveur (mode Étendu ou Push) */
a.server-url-link {
    color: var(--primary-dark);
    text-decoration: none;
}

a.server-url-link:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

/* Barre de toggle tokens — toujours visible, sépare le header de la zone */
.token-zone-bar {
    padding: 5px 16px;
    background: #f8f9fc;
    border-top: 1px solid #eaecf0;
    display: flex;
    align-items: center;
}

/* Bouton toggle tokens */
.btn-token-toggle {
    background: none;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.12s, color 0.12s;
}

/* État replié : bouton sobre pour inviter au clic */
.btn-token-open {
    color: #666;
    border: 1px solid #dde0e6;
    background: #f8f9fc;
}

.btn-token-open:hover {
    background: #eef0f4;
    color: #444;
    border-color: #c8cdd4;
}

/* État déplié : lien discret à droite */
.btn-token-collapse {
    margin-left: auto;
    color: var(--gray-400);
}

.btn-token-collapse:hover {
    color: var(--gray-600);
    background: var(--gray-100);
}

/* Ancien .server-item conservé pour rétro-compat potentielle */
.server-item {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--gray-100);
    border-radius: 6px;
    margin-bottom: 8px;
}

.server-url {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.8125rem;
    color: var(--primary-dark);
}

@media (max-width: 600px) {
    .server-card-tokens {
        grid-template-columns: 1fr;
    }

    .token-zone + .token-zone {
        border-left: none;
        border-top: 1px solid var(--gray-100);
    }

    .server-card-header {
        flex-wrap: wrap;
    }
}

/* === BOUTONS SPÉCIALISÉS === */

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

.btn-danger:hover {
    background-color: #b91c1c;
}

/* === RÉSULTATS DE TESTS === */

.test-result {
    padding: 12px;
    border-radius: 6px;
    margin-top: 8px;
    font-size: 0.875rem;
}

.test-result.success {
    background-color: #dcfce7;
    color: #059669;
    border: 1px solid #bbf7d0;
}

.test-result.error {
    background-color: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

/* === SYSTÈME DE NOTIFICATIONS === */

#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 350px;
}

.notification {
    background: #10b981;
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.4s ease-out;
    font-size: 0.9rem;
    line-height: 1.4;
    border-left: 4px solid rgba(255, 255, 255, 0.3);
}

.notification.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.notification.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.notification.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.notification.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.notification.removing {
    animation: slideOut 0.3s ease-in forwards;
}

/* === ANIMATIONS === */

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* === AIDE CONTEXTUELLE TOKEN SERVERINFO === */

.token-help {
    margin-top: 12px;
    border: 1px solid var(--gray-100);
    border-radius: 6px;
    background: white;
    font-size: 0.85rem;
}

.token-help summary {
    padding: 10px 14px;
    cursor: pointer;
    color: var(--gray-600);
    font-weight: 500;
    user-select: none;
    list-style: none; /* masque le triangle par défaut sur certains navigateurs */
}

.token-help summary::-webkit-details-marker {
    display: none;
}

.token-help summary::before {
    content: '▶ ';
    font-size: 0.7em;
    vertical-align: middle;
    transition: transform 0.15s;
    display: inline-block;
}

.token-help[open] summary::before {
    transform: rotate(90deg);
}

.token-help summary:hover {
    color: var(--primary-color);
}

.token-help-body {
    padding: 0 14px 14px;
    border-top: 1px solid var(--gray-100);
}

.token-help-note {
    margin: 10px 0 14px;
    padding: 8px 12px;
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    border-radius: 0 4px 4px 0;
    color: var(--gray-700);
    font-size: 0.8rem;
    line-height: 1.5;
}

.token-help-cmd {
    margin-bottom: 12px;
}

.token-help-cmd:last-child {
    margin-bottom: 0;
}

.token-help-cmd-label {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.token-help-cmd-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.token-help-cmd-row pre {
    flex: 1;
    margin: 0;
    padding: 10px 12px;
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
}

.token-copy-btn {
    flex-shrink: 0;
    margin-top: 2px;
}

.token-copy-btn--copied {
    background-color: #059669 !important;
    color: white !important;
    border-color: #059669 !important;
}

/* === DIALOGUES DE CONFIRMATION === */

.confirm-overlay {
    position: fixed;
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-dialog {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.2s ease-out;
}

.confirm-message {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--gray-700);
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* === MODE PUSH — STYLES ADMIN === */

.badge-push {
    background: #0e7490;
    color: white;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 500;
}

.btn-info {
    background: #0891b2;
    color: white;
    border: none;
}

.btn-info:hover {
    background: #0e7490;
}

/* Modale Push */
.push-overlay {
    z-index: 10000;
}

.push-dialog {
    max-width: 780px !important;
    width: 95% !important;
    max-height: 90vh;
    overflow-y: auto;
}

.push-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.push-dialog-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--gray-800);
}

.push-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.push-form-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
}

.push-form-row-inline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.push-form-row-inline label {
    margin: 0;
}

.push-server-display {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--gray-700);
    background: var(--gray-50);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}

.push-token-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.push-result-section {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 12px;
}

.push-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.push-code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.78rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
    max-height: 320px;
    overflow-y: auto;
    margin: 0;
}
