/* ============================================================
   Feuille de style principale — main
   Thème sombre, zéro dépendance externe
   ============================================================ */

/* --- Variables -------------------------------------------- */
:root {
    --bg-base      : #0d1117;
    --bg-surface   : #1c2128;
    --bg-elevated  : #2d333b;
    --bg-hover     : #373e47;

    --accent       : #00d4aa;
    --accent-dim   : #00a884;
    --accent-glow  : rgba(0,212,170,.15);

    --danger       : #f85149;
    --warning      : #e3b341;
    --info         : #58a6ff;
    --success      : #56d364;

    --text-primary : #f0f6fc;
    --text-secondary:#b1bac4;
    --text-muted   : #768390;

    --border       : #30363d;

    --radius-sm    : 6px;
    --radius-md    : 10px;
    --radius-lg    : 16px;

    --shadow-sm    : 0 1px 3px rgba(0,0,0,.4);
    --shadow-md    : 0 4px 16px rgba(0,0,0,.5);
    --shadow-lg    : 0 8px 32px rgba(0,0,0,.6);

    --sidebar-w    : 220px;
    --font         : 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* --- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family    : var(--font);
    background     : var(--bg-base);
    color          : var(--text-primary);
    min-height     : 100vh;
    display        : flex;
    flex-direction : row;
    line-height    : 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dim); }
img { display: block; }
button { font-family: var(--font); cursor: pointer; }

/* --- Sidebar ---------------------------------------------- */
.vc-sidebar {
    position       : fixed;
    top: 0; left: 0; bottom: 0;
    width          : var(--sidebar-w);
    background     : var(--bg-surface);
    border-right   : 1px solid var(--border);
    display        : flex;
    flex-direction : column;
    z-index        : 1000;
    overflow-y     : auto;
}
.vc-brand {
    display        : flex;
    align-items    : center;
    gap            : 10px;
    font-size      : 1.1rem;
    font-weight    : 700;
    color          : var(--accent);
    padding        : 20px 16px 16px;
    border-bottom  : 1px solid var(--border);
    white-space    : nowrap;
}
.vc-brand:hover { color: var(--accent); }

.vc-sidebar-nav {
    display        : flex;
    flex-direction : column;
    gap            : 2px;
    padding        : 12px 8px;
    flex           : 1;
}
.vc-nav-link {
    display        : flex;
    align-items    : center;
    gap            : 10px;
    padding        : 9px 12px;
    border-radius  : var(--radius-sm);
    color          : var(--text-secondary);
    font-size      : .9rem;
    transition     : background .15s, color .15s;
}
.vc-nav-link:hover,
.vc-nav-link--active {
    background     : var(--bg-hover);
    color          : var(--text-primary);
}
.vc-nav-link--active {
    color          : var(--accent);
}
.vc-nav-link { position: relative; }
button.vc-nav-link {
    width          : 100%;
    background     : transparent;
    border         : none;
    cursor         : pointer;
    text-align     : left;
    font-family    : inherit;
}
.vc-nav-alert-badge {
    margin-left    : auto;
    display        : inline-flex;
    align-items    : center;
    justify-content: center;
    min-width      : 18px;
    height         : 18px;
    padding        : 0 5px;
    border-radius  : 9px;
    font-size      : .7rem;
    font-weight    : 700;
    background     : var(--danger, #f85149);
    color          : #fff;
    line-height    : 1;
}

.vc-sidebar-bottom {
    border-top     : 1px solid var(--border);
    padding        : 12px 8px;
    display        : flex;
    flex-direction : column;
    gap            : 4px;
}
.vc-sidebar-user {
    display        : flex;
    align-items    : center;
    gap            : 8px;
    padding        : 8px 12px;
    border-radius  : var(--radius-sm);
    color          : var(--text-secondary);
    font-size      : .88rem;
}
.vc-logout-btn {
    display        : flex;
    align-items    : center;
    gap            : 8px;
    width          : 100%;
    padding        : 8px 12px;
    background     : transparent;
    border         : none;
    border-radius  : var(--radius-sm);
    color          : var(--danger);
    font-size      : .88rem;
    text-align     : left;
    transition     : background .12s;
}
.vc-logout-btn:hover { background: rgba(248,81,73,.1); }

/* --- Navbar pagination ------------------------------------ */
.vc-nav-page {
    display        : none;
    flex-direction : column;
    gap            : 2px;
}
.vc-nav-page--active {
    display        : flex;
    animation      : vc-page-in .18s ease;
}
@keyframes vc-page-in {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}
.vc-nav-pager {
    display        : flex;
    align-items    : center;
    justify-content: center;
    gap            : 6px;
    padding        : 5px 0 2px;
}
.vc-pager-btn {
    background     : transparent;
    border         : none;
    color          : var(--text-muted);
    font-size      : 1.15rem;
    line-height    : 1;
    padding        : 1px 5px;
    border-radius  : var(--radius-sm);
    cursor         : pointer;
    transition     : color .12s, background .12s;
}
.vc-pager-btn:hover:not(:disabled) {
    color          : var(--text-primary);
    background     : var(--bg-hover);
}
.vc-pager-btn:disabled { opacity: .25; cursor: default; }
.vc-pager-dots {
    display        : flex;
    gap            : 5px;
    align-items    : center;
}
.vc-pager-dot {
    width          : 5px;
    height         : 5px;
    border-radius  : 50%;
    background     : var(--text-muted);
    cursor         : pointer;
    transition     : background .15s, transform .15s;
}
.vc-pager-dot:hover { background: var(--text-secondary); }
.vc-pager-dot--active {
    background     : var(--accent);
    transform      : scale(1.4);
}

/* --- Sidebar collapse (desktop) --------------------------- */
.vc-sidebar {
    transition     : transform .25s ease;
}
.vc-sidebar--collapsed {
    transform      : translateX(-100%);
}
.vc-sidebar-collapse-btn {
    display        : flex;
    align-items    : center;
    justify-content: center;
    width          : 100%;
    padding        : 7px 12px;
    background     : transparent;
    border         : none;
    border-top     : 1px solid var(--border);
    color          : var(--text-muted);
    font-size      : .8rem;
    gap            : 6px;
    cursor         : pointer;
    transition     : color .15s, background .15s;
    font-family    : inherit;
}
.vc-sidebar-collapse-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* Bouton flottant pour ré-ouvrir le sidebar (desktop) */
.vc-sidebar-open-btn {
    display        : none;
    position       : fixed;
    top            : 12px;
    left           : 8px;
    z-index        : 1100;
    background     : var(--bg-surface);
    border         : 1px solid var(--border);
    border-radius  : var(--radius-sm);
    padding        : 6px 8px;
    color          : var(--text-primary);
    cursor         : pointer;
}
.vc-sidebar-open-btn:hover { background: var(--bg-hover); }
.vc-main-wrap { transition: margin-left .25s ease; }

/* --- Hamburger (mobile) ----------------------------------- */
.vc-sidebar-toggle {
    display        : none;
    position       : fixed;
    top            : 12px;
    left           : 12px;
    z-index        : 1100;
    background     : var(--bg-surface);
    border         : 1px solid var(--border);
    border-radius  : var(--radius-sm);
    padding        : 6px 8px;
    color          : var(--text-primary);
}

/* --- Layout wrapper --------------------------------------- */
.vc-main-wrap {
    flex           : 1;
    display        : flex;
    flex-direction : column;
    min-height     : 100vh;
    min-width      : 0;
}
.vc-main-wrap--with-sidebar {
    margin-left    : var(--sidebar-w);
}

/* --- Main / layout ---------------------------------------- */
.vc-main { flex: 1; }
.vc-container { max-width: 1280px; margin: 0 auto; padding: 32px 24px; }
.vc-container--narrow { max-width: 900px; }
.vc-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* --- En-tête de page -------------------------------------- */
.vc-page-header {
    display        : flex;
    align-items    : center;
    justify-content: space-between;
    margin-bottom  : 28px;
    gap            : 16px;
    flex-wrap      : wrap;
}
.vc-page-header h2 { font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.vc-page-header h2 svg { color: var(--accent); }
.vc-header-actions { display: flex; gap: 8px; }

/* --- Cartes ----------------------------------------------- */
.vc-card {
    background     : var(--bg-surface);
    border         : 1px solid var(--border);
    border-radius  : var(--radius-lg);
    padding        : 24px;
    margin-bottom  : 20px;
}
.vc-card-title {
    font-size      : 1rem;
    font-weight    : 600;
    margin-bottom  : 16px;
    display        : flex;
    align-items    : center;
    gap            : 8px;
}
.vc-card-title svg { color: var(--accent); }

/* --- Boutons ---------------------------------------------- */
.vc-btn {
    display        : inline-flex;
    align-items    : center;
    justify-content: center;
    gap            : 7px;
    padding        : 8px 18px;
    border-radius  : var(--radius-sm);
    font-size      : .9rem;
    font-weight    : 500;
    line-height    : 1.4;
    border         : 1px solid transparent;
    transition     : all .15s;
    white-space    : nowrap;
    text-decoration: none;
}
.vc-btn:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.vc-btn--primary { background: var(--accent); color: #0d1117; border-color: var(--accent); }
.vc-btn--primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); color: #0d1117; }
.vc-btn--ghost { background: var(--bg-surface); color: var(--text-primary); border-color: #6e7681; }
.vc-btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: #8b949e; }
.vc-btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.vc-btn--danger:hover { background: var(--danger); color: #fff; }
.vc-btn--large { padding: 12px 28px; font-size: 1rem; }
.vc-btn--block { width: 100%; }
.vc-btn--sm { padding: 5px 10px; font-size: .82rem; }

/* --- Formulaires ------------------------------------------ */
.vc-form-group { margin-bottom: 18px; }
.vc-form-group label {
    display        : flex;
    align-items    : center;
    gap            : 6px;
    font-size      : .85rem;
    font-weight    : 500;
    color          : var(--text-secondary);
    margin-bottom  : 6px;
}
.vc-form-group input[type="text"],
.vc-form-group input[type="email"],
.vc-form-group input[type="password"],
.vc-form-group input[type="number"],
.vc-form-group textarea,
.vc-form-group select {
    width          : 100%;
    padding        : 9px 12px;
    background     : var(--bg-elevated);
    border         : 1px solid var(--border);
    border-radius  : var(--radius-sm);
    color          : var(--text-primary);
    font-size      : .9rem;
    font-family    : var(--font);
    transition     : border-color .15s, box-shadow .15s;
}
.vc-form-group input:focus,
.vc-form-group textarea:focus,
.vc-form-group select:focus {
    outline        : none;
    border-color   : var(--accent);
    box-shadow     : 0 0 0 3px var(--accent-glow);
}
.vc-form-group input::placeholder,
.vc-form-group textarea::placeholder { color: var(--text-muted); }
.vc-field-error { color: var(--danger); font-size: .82rem; margin-top: 4px; }
.vc-field-hint  { color: var(--text-muted); font-size: .8rem; margin-top: 4px; }
.vc-form-actions {
    display        : flex;
    gap            : 10px;
    justify-content: flex-end;
    padding-top    : 16px;
    border-top     : 1px solid var(--border);
    margin-top     : 20px;
}

/* --- Badges ----------------------------------------------- */
.vc-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
}
.vc-badge--success { background: rgba(63,185,80,.15);  color: var(--success); }
.vc-badge--danger  { background: rgba(248,81,73,.15);  color: var(--danger); }
.vc-badge--info    { background: rgba(56,139,253,.15); color: var(--info); }
.vc-badge--warning { background: rgba(210,153,34,.15); color: var(--warning); }

/* --- Messages système ------------------------------------- */
.vc-messages {
    position       : fixed;
    top            : 12px;
    right          : 16px;
    z-index        : 2000;
    display        : flex;
    flex-direction : column;
    gap            : 8px;
    max-width      : 360px;
}
.vc-alert {
    display        : flex;
    align-items    : center;
    justify-content: space-between;
    gap            : 12px;
    padding        : 12px 16px;
    border-radius  : var(--radius-md);
    background     : var(--bg-elevated);
    border-left    : 4px solid var(--accent);
    box-shadow     : var(--shadow-md);
    font-size      : .88rem;
}
.vc-alert--error   { border-color: var(--danger); }
.vc-alert--warning { border-color: var(--warning); }
.vc-alert--info    { border-color: var(--info); }
.vc-alert button { background: none; border: none; color: var(--text-muted); font-size: .9rem; padding: 2px; flex-shrink: 0; }
.vc-alert button:hover { color: var(--text-primary); }

/* --- Authentification ------------------------------------- */
.vc-auth-wrap {
    min-height     : 100vh;
    display        : flex;
    align-items    : center;
    justify-content: center;
    padding        : 32px 16px;
    background     : radial-gradient(ellipse at 60% 30%, rgba(0,212,170,.06) 0%, transparent 70%);
}
.vc-auth-card {
    width          : 100%;
    max-width      : 420px;
    background     : var(--bg-surface);
    border         : 1px solid var(--border);
    border-radius  : var(--radius-lg);
    padding        : 40px 36px;
    box-shadow     : var(--shadow-lg);
}
.vc-auth-header { text-align: center; margin-bottom: 28px; }
.vc-auth-icon {
    width          : 56px; height: 56px;
    border-radius  : 50%;
    background     : var(--accent-glow);
    border         : 1px solid var(--accent);
    display        : flex;
    align-items    : center;
    justify-content: center;
    margin         : 0 auto 16px;
    color          : var(--accent);
}
.vc-auth-header h1 { font-size: 1.6rem; margin-bottom: 6px; }
.vc-auth-header p  { color: var(--text-secondary); font-size: .88rem; }

/* --- Table générique -------------------------------------- */
.vc-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.vc-table th {
    text-align: left; padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary); font-weight: 600; font-size: .8rem;
    text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.vc-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.vc-table tr:last-child td { border-bottom: none; }
.vc-table tr:hover td { background: var(--bg-elevated); }

/* --- État vide -------------------------------------------- */
.vc-empty-state { text-align: center; padding: 72px 24px; }
.vc-empty-state svg { color: var(--bg-elevated); display: block; margin: 0 auto 16px; }
.vc-empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }
.vc-empty-state p  { color: var(--text-muted); margin-bottom: 16px; }

/* --- Dashboard grille ------------------------------------- */
.vc-dashboard-grid {
    display        : grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows : 120px;
    gap            : 12px;
    padding        : 24px;
    align-items    : start;
}
.vc-widget {
    background     : var(--bg-surface);
    border         : 1px solid var(--border);
    border-radius  : var(--radius-lg);
    overflow       : hidden;
    display        : flex;
    flex-direction : column;
    transition     : border-color .2s, box-shadow .2s;
    height         : 100%;
}
.vc-widget:hover { border-color: var(--accent); box-shadow: 0 4px 20px rgba(0,212,170,.08); }
.vc-widget--dragging {
    opacity        : .5;
    border-color   : var(--accent);
}
.vc-widget--drag-over {
    border-color   : var(--accent);
    box-shadow     : 0 0 0 2px var(--accent-glow);
}
.vc-widget[draggable="true"] { cursor: grab; }
.vc-widget[draggable="true"]:active { cursor: grabbing; }
.vc-widget-header {
    display        : flex;
    align-items    : center;
    justify-content: space-between;
    padding        : 10px 14px;
    border-bottom  : 1px solid var(--border);
    font-size      : .85rem;
    font-weight    : 600;
    flex-shrink    : 0;
    gap            : 8px;
}
.vc-widget-header svg { color: var(--accent); flex-shrink: 0; }
.vc-widget-body {
    padding        : 14px;
    flex           : 1;
    overflow       : hidden;
}

/* Widget : texte / boîte */
.vc-widget-text {
    font-size      : .9rem;
    line-height    : 1.7;
    color          : var(--text-secondary);
    word-break     : break-word;
}

/* Widget : Grafana iframe */
.vc-widget-iframe {
    width          : 100%;
    height         : 100%;
    border         : none;
    display        : block;
}
.vc-widget-body--iframe {
    padding        : 0;
}

/* Widget : placeholder (caméra / device) */
.vc-widget-placeholder {
    height         : 100%;
    display        : flex;
    flex-direction : column;
    align-items    : center;
    justify-content: center;
    gap            : 8px;
    color          : var(--text-muted);
    font-size      : .82rem;
}
.vc-widget-placeholder svg { color: var(--bg-elevated); }

/* Widget : grille imbriquée */
.vc-widget-grid {
    display        : grid;
    grid-template-columns: 1fr 1fr;
    gap            : 8px;
    height         : 100%;
}
.vc-widget-grid-cell {
    background     : var(--bg-elevated);
    border-radius  : var(--radius-sm);
    display        : flex;
    align-items    : center;
    justify-content: center;
    color          : var(--text-muted);
    font-size      : .8rem;
}

/* --- Footer ----------------------------------------------- */
.vc-footer {
    background     : var(--bg-surface);
    border-top     : 1px solid var(--border);
    padding        : 12px 24px;
    font-size      : .8rem;
    color          : var(--text-muted);
    display        : flex;
    align-items    : center;
    gap            : 12px;
}
.vc-footer a { color: var(--text-muted); }
.vc-footer a:hover { color: var(--accent); }

/* --- Texte utilitaire ------------------------------------- */
.vc-text-muted { color: var(--text-muted); font-size: .88rem; display: flex; align-items: center; gap: 6px; }
.vc-section-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin: 0 0 16px; display: flex; align-items: center; gap: 8px; }
.vc-section-title svg { color: var(--accent); }

/* --- Stats système sidebar --------------------------------- */
.vc-sidebar-stats {
    padding        : 10px 12px 8px;
    border-bottom  : 1px solid var(--border);
    display        : flex;
    flex-direction : column;
    gap            : 6px;
}
.vc-stat-row {
    display        : flex;
    align-items    : center;
    gap            : 7px;
    color          : var(--text-muted);
    cursor         : default;
}
.vc-stat-icon {
    width          : 13px;
    height         : 13px;
    flex-shrink    : 0;
    color          : var(--text-secondary);
}
.vc-stat-track {
    flex           : 1;
    height         : 3px;
    background     : var(--bg-elevated);
    border-radius  : 2px;
    overflow       : hidden;
}
.vc-stat-fill {
    height         : 100%;
    width          : 0%;
    border-radius  : 2px;
    transition     : width .6s ease;
}
.vc-stat-fill--cpu  { background: #6366f1; }
.vc-stat-fill--mem  { background: #f97316; }
.vc-stat-fill--disk { background: #eab308; }
.vc-stat-fill--warn { background: #ef4444; }
.vc-stat-pct {
    width          : 30px;
    text-align     : right;
    font-size      : 10px;
    font-variant-numeric: tabular-nums;
    color          : var(--text-muted);
    flex-shrink    : 0;
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 1200px) {
    .vc-dashboard-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}
@media (max-width: 768px) {
    .vc-sidebar {
        transform      : translateX(-100%);
        transition     : transform .25s ease;
    }
    .vc-sidebar--open {
        transform      : translateX(0);
    }
    .vc-sidebar-toggle { display: flex; align-items: center; }
    .vc-sidebar-collapse-btn { display: none; }
    .vc-sidebar-open-btn { display: none !important; }
    .vc-main-wrap--with-sidebar { margin-left: 0; }
    .vc-grid-2col { grid-template-columns: 1fr; }
    .vc-container { padding: 16px; }
    .vc-auth-card { padding: 28px 20px; }
    .vc-page-header { flex-direction: column; align-items: flex-start; }
    .vc-dashboard-grid {
        grid-template-columns: repeat(4, 1fr);
        padding: 12px;
        gap: 8px;
    }
}
