/* GitHub-inspired minimal CSS
   - System fonts
   - Neutral palette (grays) with subtle accents
   - Compact cards, flat buttons, code styling
*/

:root {
    --bg: #f6f8fa;
    /* GitHub page background */
    --surface: #ffffff;
    --muted: #6a737d;
    --text: #24292f;
    --border: #e1e4e8;
    --accent: #0366d6;
    /* blue link color */
    --success: #60a5fa;
    /* pastel blue replacement for success */
    --danger: #cb2431;
    /* Taille de police standard pour les boutons et le sélecteur de langue */
    --btn-font-size: 14px;
    --radius: 6px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.header {
    position: sticky;
    top: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 60;
    /* s'assurer que le header reste au-dessus des alertes */
}

.header-brand h1 {
    font-size: 1rem;
    margin: 0;
    font-weight: 600;
}

.header-nav {
    display: flex;
    gap: 8px;
    align-items: center
}

.header-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

.user-info {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 6px 8px;
}

.language-selector {
    position: relative;
}

.language-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.language-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-width: 140px;
    box-shadow: 0 6px 12px rgba(27, 31, 35, 0.08);
    display: none;
    z-index: 20;
}

.language-dropdown.show,
.language-dropdown.show {
    display: block;
}

.language-option {
    display: block;
    padding: 8px 10px;
    color: var(--text);
    text-decoration: none;
}

.language-option.active {
    background: #f1f8ff;
    color: var(--accent);
}

.logout-btn {
    margin-left: 8px;
}

.btn-outline.logout-btn {
    /* Rouge pastel (bouton déconnexion) */
    color: #7a1f1f;
    /* texte rouge foncé */
    background: #fff4f4;
    /* fond rouge pastel très clair */
    border: 1px solid #ffd6d6;
    /* bordure pastel */
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 600;
}

.btn-outline.logout-btn:hover {
    background: #ffecec;
    border-color: #ffc6c6;
}


.nav-link {
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 600
}

/* Uniform button sizing */
.btn {
    min-height: 34px;
    line-height: 20px;
    padding: 6px 12px;
}

/* Language selector sizing consistent with buttons */
.language-btn {
    min-height: 34px;
    line-height: 20px;
    padding: 6px 12px;
}

.language-option {
    padding: 8px 12px;
}

/* Footer improvements */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.footer-info {
    color: var(--muted);
    font-size: 0.95rem
}

.footer-stats {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    /* Par défaut en colonne (mobile-first) */
    flex-direction: column;
    justify-content: center;
}

/* Desktop: aligner les stats à droite en ligne, espacement régulier */
@media (min-width: 900px) {
    .footer-stats {
        flex-direction: row;
        justify-content: flex-end;
        gap: 20px;
    }

    .footer-stats .footer-stat {
        text-align: right;
        min-width: 120px;
    }
}

.footer-stat {
    color: var(--muted);
    font-size: 0.9rem
}

.nav-link.active {
    background: #f1f8ff;
    color: var(--accent)
}

.main-content {
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px
}

.btn {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: rgba(3, 102, 214, 0.15);
}

.btn-primary:hover {
    background: #0356b6;
}

.btn-secondary {
    background: #f6f8fa;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #eef3f6;
}

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

.btn-outline:hover {
    background: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #a21823;
}

/* Design system: unified interactions for all buttons */
.btn {
    transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease, background-color 120ms ease;
}

.btn:active {
    transform: translateY(1px) scale(0.997);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(3, 102, 214, 0.12);
}

.btn[disabled],
.btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

/* Ensure primary / success variants keep consistent focus ring colors */
.btn-primary:focus {
    box-shadow: 0 0 0 4px rgba(3, 102, 214, 0.16);
}

/* Small size and full-width helpers */
.btn-small {
    padding: 4px 8px;
    font-size: 13px;
}

/* Small flex helpers used in templates */
.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.align-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.py-1 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.border-dashed {
    border-bottom: 1px dashed #eee;
}

.list-unstyled {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Language flags */
.lang-flag {
    margin: 0 8px;
    text-decoration: none;
    font-size: 2rem;
    opacity: 0.4;
    color: inherit;
}

.lang-flag.active {
    font-weight: 700;
    color: #2980b9;
    opacity: 1;
}

.lang-flag.inactive {
    opacity: 0.4;
}

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

.font-bold {
    font-weight: 700;
}

.small-bold {
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-admin {
    background: #fff;
    color: var(--muted);
    border: 1px solid #e6e2d9;
}

.btn-admin:hover {
    background: #fbfbfb
}

.btn-warning {
    background: #fef3e6;
    color: #92400e;
    border: 1px solid #f5d0a9;
}

.btn-warning:hover {
    background: #fff4e6
}

.alert {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff
}

.alert-info {
    background: #eaf5ff;
    border-color: #b3d3f7;
}

.alert-warning {
    background: #fff8eb;
    border-color: #f1e7cd
}

/* Colored alert tiles */
.alert-success {
    background: rgba(40, 167, 69, 0.08);
    border-color: rgba(40, 167, 69, 0.18);
    color: var(--text);
}

.alert-danger {
    background: rgba(203, 36, 49, 0.06);
    border-color: rgba(203, 36, 49, 0.18);
    color: var(--text);
}

/* Message prefix styling */
.msg-prefix {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 0.5rem;
    font-weight: 700;
}

.msg-prefix.success {
    color: #1f7a32;
}

.msg-prefix.error {
    color: var(--danger);
}

.msg-prefix.warning {
    color: #d97706;
}

/* Utility spacing */
.mr-1 {
    margin-right: 0.25rem;
}

/* More spacing utilities */
.ml-1 {
    margin-left: 0.25rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

/* Outline muted variant for low-emphasis actions (outline + muted color) */
.btn-outline-muted {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

/* Spacing utilities (mobile-first sensible steps) */
.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

/* Form controls (replaces repeated inline input styles) */
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* monospace form control for hashed values */
.form-control.monospace {
    font-family: monospace;
}

/* Modal helpers to replace inline modal markup */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-overlay.show {
    display: block;
}

.modal-window {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
}

/* Small text helper */
.text-muted {
    color: #6b7280;
    font-size: 0.9rem;
}

/* Muted button style for secondary actions without full emphasis */
.btn-muted {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

/* Slightly more visible warning prefix background for emphasis */
.msg-prefix.warning {
    color: #d97706;
    background: #fff7ed;
}

.alert .alert-body {
    display: inline-block;
    vertical-align: middle;
}

/* Global alert wrapper used for notices that should align with main-content */
.global-alert-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 16px;
}

.global-alert-wrapper {
    /* Alerte globale affichée comme un bloc qui pousse le contenu.
       Les styles centraux sont ici pour s'appliquer sans position fixed. */
    position: relative;
    margin: 0 auto 1rem auto;
    width: min(1100px, calc(100% - 2rem));
    padding: 8px 16px;
    display: block;
}

.global-alert-wrapper>.alert {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
    z-index: 50;
    /* inférieur au header (60) pour éviter de le recouvrir */
}

.global-alert-wrapper .alert.small {
    padding: 8px 12px;
}

.global-alert {
    border-radius: 6px;
    padding: 0.75rem 1rem;
    box-sizing: border-box;
}

/* Inner layout for global alert */
.global-alert-content {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.global-alert-body {
    flex: 1;
}

.app-list {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.app-tile {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: linear-gradient(#fff, #fbfdff)
}

.app-title {
    font-weight: 600;
    margin: 0
}

.app-key {
    color: var(--muted);
    font-size: 0.9rem
}

.app-desc {
    color: var(--muted);
    font-size: 0.95rem
}

.app-status {
    display: none;
}

/* GitHub-like server checks */
.server-checks {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Filter buttons styling */
.filter-btn {
    border-radius: 6px;
    padding: 6px 10px;
    font-weight: 600;
}



.filter-btn:hover {
    background: #f9fafb;
    /* subtle hover for both */
}

.filter-btn.btn-primary {
    background: #f3f4f6;
    /* light gray background when selected */
    color: #111827;
    border: 1px solid var(--border);
    box-shadow: none;
}

/* Ensure hover doesn't override selected background */
.filter-btn.btn-primary:hover {
    background: #f3f4f6;
}

.check-item {
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(27, 31, 35, 0.03);
    border: 1px solid var(--border);
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--muted);
}

.check-badge {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
}

.check-badge.ok {
    background: rgba(40, 167, 69, 0.12);
    /* pastel green background */
    color: #1f7a32;
    /* darker green icon/text */
    border: 1px solid rgba(40, 167, 69, 0.18);
}

.check-badge.fail {
    background: rgba(203, 36, 49, 0.12);
    /* pastel red background */
    color: #8e1f25;
    /* darker red icon/text */
    border: 1px solid rgba(203, 36, 49, 0.18);
}

/* SVG icons inside badges should use currentColor for fill */
.check-badge svg {
    width: 12px;
    height: 12px;
    display: block;
    fill: currentColor;
}

.check-label {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.check-note {
    color: var(--muted);
    font-size: 0.82rem;
}

/* Ensure server checks title also matches muted color */
.footer-server-checks>strong {
    color: var(--muted);
}

/* code and pre styling similar to GitHub */
pre,
code {
    font-family: SFMono-Regular, Menlo, Monaco, 'Roboto Mono', 'Courier New', monospace;
    background: #f6f8fa;
    color: var(--text);
    border-radius: 6px;
    padding: 4px 6px;
    border: 1px solid var(--border)
}

pre {
    padding: 12px;
    overflow: auto
}

/* modal */
#appPreviewModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27, 31, 35, 0.5);
    align-items: center;
    justify-content: center
}

#appPreviewModal .modal-window {
    width: 95%;
    max-width: 900px;
    border-radius: 8px;
    overflow: hidden;
}

/* helpers */
.hidden {
    display: none
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0
}

/* responsive */
@media (max-width:768px) {
    .app-tile {
        flex-direction: column;
        align-items: stretch
    }

    /* S'assurer que le footer reste compact sur mobile */
    .footer-stats {
        align-items: center;
    }
}