/* WS Portail — design system clair/sombre, calqué sur l'identité HYBER */

:root {
    /* Marque — constante quel que soit le thème */
    --ws-orange: rgb(242, 113, 31);
    --ws-orange-hover: rgb(255, 138, 61);
    --ws-red: rgb(216, 30, 44);
    --ws-btn-text-on-brand: rgb(17, 17, 17);

    /* Échelle de rayons / transitions communes */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;
    --transition: 150ms ease;
}

/* Thème sombre (par défaut) */
:root, [data-theme="dark"] {
    --ws-link: rgb(139, 147, 255);
    --ws-link-hover: rgb(165, 171, 255);

    --ws-bg: rgb(13, 13, 15);
    --ws-surface: rgb(23, 23, 27);
    --ws-card: rgb(27, 27, 31);
    --ws-card-hover: rgb(32, 32, 37);
    --ws-line: rgb(42, 42, 48);
    --ws-text: rgb(242, 242, 243);
    --ws-slate: rgb(154, 154, 162);
    --ws-muted: rgb(110, 110, 118);
    --ws-label: rgb(201, 138, 74);
    --ws-ink: rgb(30, 30, 34);

    --ws-success: rgb(63, 182, 104);
    --ws-success-bg: rgba(63, 182, 104, 0.14);
    --ws-danger: rgb(229, 72, 77);
    --ws-danger-bg: rgba(229, 72, 77, 0.14);
    --ws-danger-border: rgba(229, 72, 77, 0.35);
    --ws-warning-bg: rgba(242, 113, 31, 0.14);

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.28);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Thème clair — palette initiale du projet */
[data-theme="light"] {
    --ws-link: rgb(90, 95, 209);
    --ws-link-hover: rgb(70, 75, 189);

    --ws-bg: rgb(250, 249, 247);
    --ws-surface: rgb(255, 255, 255);
    --ws-card: rgb(241, 239, 234);
    --ws-card-hover: rgb(234, 231, 224);
    --ws-line: rgb(227, 224, 217);
    --ws-text: rgb(23, 23, 23);
    --ws-slate: rgb(110, 106, 99);
    --ws-muted: rgb(139, 135, 126);
    --ws-label: rgb(181, 101, 29);
    --ws-ink: rgb(30, 30, 34);

    --ws-success: rgb(46, 125, 70);
    --ws-success-bg: rgba(46, 125, 70, 0.12);
    --ws-danger: rgb(194, 43, 43);
    --ws-danger-bg: rgba(194, 43, 43, 0.1);
    --ws-danger-border: rgba(194, 43, 43, 0.3);
    --ws-warning-bg: rgba(242, 113, 31, 0.12);

    --shadow-card: 0 1px 2px rgba(23, 23, 23, 0.06), 0 4px 14px rgba(23, 23, 23, 0.05);
    --shadow-soft: 0 1px 2px rgba(23, 23, 23, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--ws-bg);
    color: var(--ws-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3 {
    font-family: inherit;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 6px;
    color: var(--ws-text);
}

a { color: var(--ws-link); text-decoration: none; }
a:hover { color: var(--ws-link-hover); text-decoration: underline; }

.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    border: 1px solid var(--ws-line);
    background: var(--ws-card);
    color: var(--ws-text);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color var(--transition), border-color var(--transition);
}
.theme-toggle:hover { background: var(--ws-card-hover); }
.theme-icon-sun { display: none; }
.theme-icon-moon { display: inline-flex; }
[data-theme="light"] .theme-icon-sun { display: inline-flex; }
[data-theme="light"] .theme-icon-moon { display: none; }

.auth-page { position: relative; }
.auth-page .theme-toggle { position: absolute; top: 20px; right: 20px; }

/* ---------- Pages d'authentification ---------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ws-bg);
    padding: 24px;
}

.auth-card {
    background: var(--ws-surface);
    border: 1px solid var(--ws-line);
    border-radius: 14px;
    box-shadow: var(--shadow-card);
    width: 100%;
    max-width: 380px;
    padding: 36px 32px 32px;
}

.auth-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.auth-logo img { width: 104px; height: 104px; }

.auth-title { text-align: center; font-size: 1.25rem; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--ws-slate); font-size: 0.86rem; margin-bottom: 24px; }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ws-label);
}
.field input, .field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--ws-line);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--ws-bg);
    color: var(--ws-text);
}
.field input::placeholder { color: var(--ws-muted); }
.field input:focus, .field select:focus {
    outline: 2px solid var(--ws-orange);
    outline-offset: 1px;
    border-color: var(--ws-orange);
}

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--ws-orange);
    color: var(--ws-bg);
}
.btn-primary:hover { background: var(--ws-orange-hover); }
.btn-primary.full { width: 100%; padding: 12px 18px; }
.btn-secondary {
    background: var(--ws-card);
    color: var(--ws-text);
    border: 1px solid var(--ws-line);
}
.btn-secondary:hover { background: var(--ws-card-hover); }
.btn-danger {
    background: var(--ws-danger-bg);
    color: var(--ws-danger);
    border: 1px solid var(--ws-danger-border);
}
.btn-danger:hover { background: var(--ws-danger-bg); filter: brightness(0.92); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-error { background: var(--ws-danger-bg); color: var(--ws-danger); border-color: var(--ws-danger-border); }
.alert-success { background: var(--ws-success-bg); color: var(--ws-success); border-color: rgba(63,182,104,0.3); }
.alert-info { background: var(--ws-warning-bg); color: var(--ws-orange); border-color: rgba(242,113,31,0.3); }

/* ---------- Layout applicatif : sidebar façon HYBER ---------- */

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--ws-bg);
    border-right: 1px solid var(--ws-line);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 40;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 4px 4px;
}
.brand-logo { width: 46px; height: 46px; display: block; }
.brand-logo-sm { width: 34px; height: 34px; display: block; }
.brand-logo-wrap { display: inline-flex; }
.theme-logo-light { display: none; }
.theme-logo-dark { display: block; }
[data-theme="light"] .theme-logo-light { display: block; }
[data-theme="light"] .theme-logo-dark { display: none; }
.sidebar-collapse-btn {
    background: none; border: none; color: var(--ws-slate);
    cursor: pointer; padding: 4px; display: flex; border-radius: 6px;
}
.sidebar-collapse-btn:hover { background: var(--ws-card); color: var(--ws-text); }

.sidebar-user {
    padding: 10px 6px 14px;
    color: var(--ws-slate);
    font-size: 0.82rem;
    border-bottom: 1px solid var(--ws-line);
    margin-bottom: 12px;
}
.sidebar-user strong { color: var(--ws-text); font-weight: 600; }

.sidebar-search { position: relative; margin-bottom: 12px; }
.sidebar-search .icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--ws-muted); pointer-events: none;
}
.sidebar-search input {
    width: 100%;
    padding: 8px 10px 8px 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--ws-line);
    background: var(--ws-surface);
    color: var(--ws-text);
    font-size: 0.85rem;
    font-family: inherit;
}
.sidebar-search input::placeholder { color: var(--ws-muted); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--ws-slate);
    font-size: 0.88rem;
    font-weight: 500;
    position: relative;
}
.nav-link:hover { background: var(--ws-card); color: var(--ws-text); text-decoration: none; }
.nav-link.active { background: var(--ws-orange); color: #fff; font-weight: 600; }
.nav-link.active:hover { background: var(--ws-orange); }

.nav-badge-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ws-orange);
    margin-left: auto;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--ws-bg);
}
.nav-link.active .nav-badge-dot { background: #fff; box-shadow: 0 0 0 2px var(--ws-orange); }

.sidebar-footer {
    border-top: 1px solid var(--ws-line);
    padding-top: 10px;
    margin-top: 10px;
}
.sidebar-footer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px 0;
}
.sidebar-version {
    color: var(--ws-muted);
    font-size: 0.74rem;
}

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--ws-bg);
    border-bottom: 1px solid var(--ws-line);
    position: sticky;
    top: 0;
    z-index: 30;
}
.mobile-topbar-actions { display: flex; align-items: center; gap: 8px; }
.mobile-toggle {
    background: none; border: 1px solid var(--ws-line); border-radius: var(--radius-sm);
    color: var(--ws-text); padding: 6px; display: flex; cursor: pointer;
}

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 35;
}
.sidebar-backdrop.visible { display: block; }

.main-col {
    margin-left: 250px;
    flex: 1;
    min-width: 0;
}

.app-main {
    width: 95%;
    max-width: 95%;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

.page-title { margin-bottom: 22px; }
.page-title p { color: var(--ws-slate); margin: 4px 0 0; font-size: 0.92rem; }

/* Sidebar repliée en mode icônes (desktop) */
.app-shell.sidebar-collapsed .sidebar { width: 72px; }
.app-shell.sidebar-collapsed .sidebar-brand { justify-content: center; flex-direction: column; gap: 8px; }
.app-shell.sidebar-collapsed .sidebar-user,
.app-shell.sidebar-collapsed .sidebar-search,
.app-shell.sidebar-collapsed .sidebar-version,
.app-shell.sidebar-collapsed .nav-link span { display: none; }
.app-shell.sidebar-collapsed .nav-link { justify-content: center; }
.app-shell.sidebar-collapsed .sidebar-footer-meta { justify-content: center; }
.app-shell.sidebar-collapsed .nav-badge-dot { position: absolute; top: 6px; right: 6px; margin-left: 0; }
.app-shell.sidebar-collapsed .sidebar-collapse-btn .icon { transform: rotate(180deg); }
.app-shell.sidebar-collapsed .main-col { margin-left: 72px; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-col { margin-left: 0; }
    .app-shell.sidebar-collapsed .main-col { margin-left: 0; }
    .mobile-topbar { display: flex; }
    .app-main { padding: 24px 18px 48px; }
}

/* ---------- Avatar / menu utilisateur ---------- */

.avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--ws-orange);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

/* ---------- Cartes ---------- */

.card {
    background: var(--ws-surface);
    border: 1px solid var(--ws-line);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-card);
}
.card h2 { font-size: 0.98rem; margin-bottom: 16px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 180px; }

.file-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-input {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.file-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--ws-line);
    background: var(--ws-card);
    color: var(--ws-text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition);
}
.file-label:hover { background: var(--ws-card-hover); }
.file-name { font-size: 0.82rem; color: var(--ws-slate); }

/* ---------- Tableaux (admin) ---------- */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--ws-surface);
    border: 1px solid var(--ws-line);
    border-radius: var(--radius);
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 11px 14px;
    text-align: left;
    font-size: 0.87rem;
    border-bottom: 1px solid var(--ws-line);
    color: var(--ws-text);
}
.data-table th {
    background: var(--ws-card);
    font-weight: 600;
    color: var(--ws-slate);
    font-size: 0.76rem;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.74rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    appearance: none;
    -webkit-appearance: none;
}
.badge-actif { background: var(--ws-success-bg); color: var(--ws-success); }
.badge-suspendu { background: var(--ws-danger-bg); color: var(--ws-danger); }
.badge-admin { background: var(--ws-warning-bg); color: var(--ws-orange); }
.badge-utilisateur { background: var(--ws-card); color: var(--ws-slate); }

.status-toggle {
    cursor: pointer;
    transition: filter var(--transition), opacity var(--transition);
}
.status-toggle:hover { filter: brightness(1.15); }
.status-toggle:focus-visible { outline: 2px solid var(--ws-orange); outline-offset: 2px; }
.status-toggle-loading { opacity: 0.55; pointer-events: none; }

/* ---------- Arborescence des groupes ---------- */

.group-tree { display: flex; flex-direction: column; gap: 2px; }
.group-tree details { margin: 0; }
.group-tree summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
}
.group-tree summary::-webkit-details-marker { display: none; }
.group-tree summary:hover { background: var(--ws-card); }
.group-tree summary .group-row-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.group-chevron { transition: transform 0.15s ease; color: var(--ws-muted); flex-shrink: 0; }
.group-tree details[open] > summary .group-chevron { transform: rotate(90deg); }

.group-children {
    margin-left: 20px;
    padding-left: 14px;
    border-left: 1px dashed var(--ws-line);
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.group-leaf-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px 9px 30px;
    border-radius: var(--radius-sm);
}
.group-leaf-row:hover { background: var(--ws-card); }

.group-name { font-weight: 600; font-size: 0.9rem; }
.group-count { color: var(--ws-muted); font-size: 0.78rem; font-weight: 500; }

.actions-cell { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.btn-icon { padding: 6px 10px; }
.btn-icon .btn-label { white-space: nowrap; }

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--ws-line);
    -webkit-overflow-scrolling: touch;
}
.table-responsive .data-table { border: none; border-radius: 0; }

@media (max-width: 760px) {
    .btn-icon .btn-label { display: none; }
    .btn-icon { padding: 7px; width: 32px; height: 32px; }
}

.empty-state {
    text-align: center;
    color: var(--ws-slate);
    padding: 48px 20px;
    background: var(--ws-surface);
    border: 1px dashed var(--ws-line);
    border-radius: var(--radius);
}

.footer-note {
    text-align: center;
    color: var(--ws-muted);
    font-size: 0.78rem;
    margin-top: 40px;
}

/* ---------- Tableau de bord : grille d'URLs (2 / 3 / 4 colonnes) ---------- */

.group-block { margin-bottom: 30px; }
.group-block h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--ws-slate);
    margin-bottom: 14px;
}
.group-block h2 .icon { color: var(--ws-orange); }

.url-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr;
}
@media (min-width: 600px) {
    .url-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
    .url-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
    .url-grid { grid-template-columns: repeat(4, 1fr); }
}

.url-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    background: var(--ws-surface);
    border: 1px solid var(--ws-line);
    border-radius: var(--radius);
    padding: 16px 16px;
    color: var(--ws-text);
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.url-card:hover {
    border-color: var(--ws-orange);
    background: var(--ws-card);
    text-decoration: none;
    transform: translateY(-1px);
}
.url-card .url-card-text { min-width: 0; }
.url-card .url-card-name {
    font-weight: 600;
    font-size: 0.94rem;
    display: block;
    margin-bottom: 4px;
    color: var(--ws-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.url-card .url-card-link {
    font-size: 0.78rem;
    color: var(--ws-slate);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.url-card .icon { color: var(--ws-muted); margin-top: 2px; }
.url-card:hover .icon { color: var(--ws-orange); }
