/* X3 Patch Watch — design unifié (user + admin) */
:root {
    --x3-navbar-h: 56px;
    --x3-sidebar-bg: #0f172a;
    --x3-sidebar-hover: #1e293b;
    --x3-sidebar-active: #14532d;
    /* Couleur d’action unique (boutons principaux, onglet actif) */
    --x3-accent: #16a34a;
    --x3-accent-hover: #15803d;
    --x3-accent-soft: #dcfce7;
    --x3-surface: #f8fafc;
    --x3-card-border: #e2e8f0;
    --x3-text-muted: #64748b;
    --x3-radius: 0.75rem;
}

body {
    background-color: var(--x3-surface);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ——— Barre du haut fixe (ne défile plus avec la page) ——— */
body.app-body-auth {
    padding-top: var(--x3-navbar-h);
    overflow: hidden;
    height: 100vh;
}

.app-navbar {
    background: #0f172a !important;
    min-height: var(--x3-navbar-h);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
}

.app-flash-stack {
    position: fixed;
    top: var(--x3-navbar-h);
    left: 0;
    right: 0;
    z-index: 1035;
}

.app-navbar .nav-link.active {
    color: #86efac !important;
    font-weight: 600;
}

.app-navbar-brand {
    font-weight: 700;
}

/* ——— Structure page : seul le contenu central défile ——— */
.app-with-sidebar {
    display: flex;
    height: calc(100vh - var(--x3-navbar-h));
    min-height: 0;
    overflow: hidden;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.app-topbar {
    background: #fff;
    border-bottom: 1px solid var(--x3-card-border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    flex-shrink: 0;
    z-index: 20;
}

.app-content {
    padding: 1rem 1.25rem 1.5rem;
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

/* Recherche PatchFinder : filtres fixes, tableau dans une zone qui défile seule */
.app-content--split-scroll {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-search-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.app-search-filters {
    flex-shrink: 0;
    overflow: visible;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--x3-card-border);
    background: var(--x3-surface);
}

/* Formulaire recherche PatchFinder — compact, sans ascenseur */
.app-filter-panel--compact {
    margin-bottom: 0;
    padding: 0.5rem 0.65rem;
}

.pf-search-form .pf-search-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.35rem;
}

.pf-search-form .pf-search-row:last-of-type {
    margin-bottom: 0;
}

.pf-search-row--main {
    align-items: flex-end;
}

.pf-mini-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--x3-text-muted);
    margin-bottom: 0.1rem;
    font-weight: 600;
}

.pf-search-range {
    flex: 1 1 140px;
    min-width: 120px;
    max-width: 200px;
}

.pf-search-arrow {
    flex: 0 0 auto;
    padding-bottom: 0.35rem;
    font-size: 0.85rem;
}

.pf-search-stats {
    flex: 1 1 auto;
    min-width: 100px;
    white-space: nowrap;
}

.pf-search-actions {
    display: flex;
    gap: 0.35rem;
    flex: 0 0 auto;
    margin-left: auto;
}

.pf-search-keyword {
    flex: 1 1 200px;
    min-width: 160px;
}

.pf-search-scope {
    flex: 0 1 110px;
    min-width: 95px;
}

.pf-search-mini {
    flex: 0 1 100px;
    min-width: 85px;
}

.pf-search-advanced {
    margin-top: 0.35rem;
    font-size: 0.8rem;
}

.pf-search-advanced summary {
    cursor: pointer;
    color: var(--x3-text-muted);
    padding: 0.15rem 0;
    user-select: none;
}

.pf-search-advanced__body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
    padding-top: 0.35rem;
}

@media (max-width: 768px) {
    .pf-search-advanced__body {
        grid-template-columns: 1fr;
    }

    .pf-search-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
    }
}

.pf-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
    gap: 0.1rem 0.35rem;
}

.pf-check-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    font-size: 0.75rem;
    color: #334155;
    cursor: pointer;
}

.pf-check-item input {
    margin: 0;
    flex-shrink: 0;
}

.pf-check-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-search-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-top: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.app-search-results .app-data-table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f1f5f9;
}

@media (min-width: 992px) {
    .app-content {
        padding: 1.25rem 1.5rem 1.75rem;
    }
}

.app-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.app-page-subtitle {
    color: var(--x3-text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

/* ——— Sidebar admin (sous le menu du haut) ——— */
.app-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--x3-sidebar-bg) 0%, #020617 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

.app-sidebar-nav {
    padding: 1rem 0.75rem 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.app-sidebar-nav__section {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0.75rem 0.75rem 0.35rem;
    font-weight: 600;
}

.app-sidebar-nav__link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
    transition: background 0.15s, color 0.15s;
}

.app-sidebar-nav__link:hover {
    background: var(--x3-sidebar-hover);
    color: #fff;
}

.app-sidebar-nav__link.is-active {
    background: var(--x3-sidebar-active);
    color: #86efac;
    font-weight: 600;
}

.app-sidebar-nav__link .bi {
    font-size: 1.1rem;
}

/* ——— Cartes & tableaux ——— */
.app-card {
    background: #fff;
    border: 1px solid var(--x3-card-border);
    border-radius: var(--x3-radius);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    width: 100%;
}

/* Menu Actions dans les tableaux : ne pas couper le dropdown */
.app-card:has(.app-list-table-wrap .dropdown-menu.show),
.app-card:has(.table-servers-wrap .dropdown-menu.show) {
    overflow: visible;
}

.app-list-table-wrap,
.table-servers-wrap {
    overflow-x: auto;
    overflow-y: visible;
}

.app-list-table-wrap .dropdown-menu,
.table-servers-wrap .dropdown-menu {
    max-height: none;
    overflow: visible;
}

.app-list-table td:last-child,
.table-servers td:last-child {
    overflow: visible;
}

.app-data-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.app-data-table-wrap .table {
    width: max-content;
    min-width: 100%;
    margin-bottom: 0;
}

/* En-tête de tableau collant (pages avec défilement global du contenu) */
.app-content:not(.app-content--split-scroll) .app-data-table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f1f5f9;
}

.app-card .table {
    margin-bottom: 0;
}

.app-card .table thead th {
    background: #f1f5f9;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--x3-text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--x3-card-border);
    padding: 0.75rem 1rem;
}

.app-card .table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

.app-card .table tbody tr:hover {
    background: #f8fafc;
}

.app-card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--x3-card-border);
    background: #f8fafc;
}

.app-card__header h2 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--x3-text-muted);
    margin: 0;
}

.app-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--x3-text-muted);
    margin: 1.5rem 0 0.75rem;
}

/* ——— KPI / stats ——— */
.app-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.app-stat-card {
    background: #fff;
    border: 1px solid var(--x3-card-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, border-color 0.2s;
    display: block;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.app-stat-card:hover {
    border-color: var(--x3-accent);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.12);
    color: inherit;
}

.app-stat-card--warning {
    border-top: 3px solid #f59e0b;
}

.app-stat-card--info {
    border-top: 3px solid var(--x3-accent);
}

.app-stat-card--neutral {
    border-top: 3px solid var(--x3-card-border);
}

.app-stat-card__label {
    font-size: 0.875rem;
    color: var(--x3-text-muted);
    margin-bottom: 0.35rem;
}

.app-stat-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.app-stat-card__icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    background: #dcfce7;
    color: var(--x3-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

/* ——— Boutons icônes ——— */
.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

.btn-icon .bi {
    font-size: 1rem;
}

.app-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ——— Formulaires ——— */
.app-form-card {
    background: #fff;
    border: 1px solid var(--x3-card-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    max-width: 720px;
}

.app-form-card--wide {
    max-width: 900px;
}

.app-form-card__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--x3-card-border);
    background: #f8fafc;
}

.app-form-card__body {
    padding: 1.5rem;
}

.app-form-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.app-form-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.app-form-section__title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--x3-text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-form-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--x3-card-border);
    margin-top: 0.5rem;
}

/* ——— Liste sociétés (dashboard) ——— */
.app-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.app-list-item:last-child {
    border-bottom: none;
}

.app-list-item__icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--x3-text-muted);
}

/* ——— Sous-navigation (ex. section Patchs) ——— */
.app-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.35rem;
    background: #fff;
    border: 1px solid var(--x3-card-border);
    border-radius: var(--x3-radius);
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.app-subnav__link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    color: var(--x3-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.app-subnav__link:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.app-subnav__link.is-active {
    background: var(--x3-accent);
    color: #fff;
}

/* ——— Panneau de statut (une seule zone d’info, pas 3 alertes) ——— */
.app-status-panel {
    background: #fff;
    border: 1px solid var(--x3-card-border);
    border-radius: var(--x3-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.app-status-panel--warning {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}

.app-status-panel__title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--x3-text-muted);
    margin: 0 0 0.75rem;
}

.app-status-panel__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem 1.25rem;
}

.app-status-panel__item dt {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--x3-text-muted);
    margin-bottom: 0.15rem;
}

.app-status-panel__item dd {
    margin: 0;
    font-size: 0.9rem;
    color: #0f172a;
}

/* ——— Formulaire de recherche / filtres ——— */
.app-filter-panel {
    background: #fff;
    border: 1px solid var(--x3-card-border);
    border-radius: var(--x3-radius);
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.app-filter-panel__section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.app-filter-panel__section:last-child {
    border-bottom: none;
}

.app-filter-panel__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--x3-text-muted);
    margin-bottom: 0.5rem;
}

.app-filter-panel__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border-radius: 0 0 var(--x3-radius) var(--x3-radius);
}

.app-hint {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--x3-radius);
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    color: #0c4a6e;
    margin-bottom: 1.5rem;
}

.app-hint--warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

/* ——— Boutons : une hiérarchie claire ——— */
.btn-primary,
.btn-success {
    --bs-btn-bg: var(--x3-accent);
    --bs-btn-border-color: var(--x3-accent);
    --bs-btn-hover-bg: var(--x3-accent-hover);
    --bs-btn-hover-border-color: var(--x3-accent-hover);
}

.app-toolbar .btn {
    white-space: nowrap;
}

/* ——— Alertes dans listes ——— */
.app-alert-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.app-alert-item:last-child {
    border-bottom: none;
}

.app-alert-item--unread {
    background: #fffbeb;
}

.app-alert-item--read {
    opacity: 0.65;
}

.app-scroll-panel {
    max-height: 400px;
    overflow-y: auto;
}

.app-scroll-panel--short {
    max-height: 220px;
}

/* ——— Cartes synthèse (tableau de bord + vue patchs) ——— */
.app-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.app-overview-card {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 1rem 1.1rem;
    background: #fff;
    border: 1px solid var(--x3-card-border);
    border-radius: var(--x3-radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

a.app-overview-card:hover {
    border-color: #86efac;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.app-overview-card--ok {
    border-left: 4px solid #22c55e;
}

.app-overview-card--warn {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
}

.app-overview-card--info {
    border-left: 4px solid #3b82f6;
}

.app-overview-card--neutral {
    border-left: 4px solid #94a3b8;
}

.app-overview-card__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--x3-text-muted);
    font-weight: 600;
}

.app-overview-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.1;
}

.app-overview-card__value--sm {
    font-size: 1.1rem;
}

.app-overview-card__hint {
    font-size: 0.75rem;
    color: var(--x3-text-muted);
}

/* ——— Alertes groupées (vue patchs) ——— */
.app-alert-group {
    padding: 0;
    overflow: hidden;
}

.app-alert-group--unread {
    border-color: #fde68a;
    box-shadow: inset 0 0 0 1px #fef3c7;
}

.app-alert-group__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--x3-card-border);
}

.app-alert-group__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.app-alert-group__list li {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.app-alert-group__list li:last-child {
    border-bottom: none;
}

.app-alert-group__list li.is-unread {
    background: #fffbeb;
}

.app-alert-group__list li.is-read {
    opacity: 0.7;
}

.app-cve-list li:last-child {
    margin-bottom: 0 !important;
}

.app-cve-list .badge {
    font-size: 0.65rem;
    vertical-align: middle;
}
