/* =========================================================
   VisionEdge Stock - Style SaaS moderne
   ========================================================= */

:root {
    --ve-primary: #0f3764;
    --ve-primary-2: #1e5a96;
    --ve-success: #15803d;
    --ve-warning: #d97706;
    --ve-danger: #dc2626;
    --ve-light: #f5f7fb;
    --ve-border: #e5e9f2;
    --ve-text: #1f2937;
    --ve-muted: #6b7280;
}

* { box-sizing: border-box; }

body {
    background: var(--ve-light);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .92rem;
    color: var(--ve-text);
    margin: 0;
}

/* =========================================================
   NAVBAR
   ========================================================= */
.topbar {
    background: linear-gradient(90deg, var(--ve-primary), var(--ve-primary-2));
    min-height: 60px;
    box-shadow: 0 2px 8px rgba(15,55,100,.15);
    z-index: 1030;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    min-height: 60px;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 1.1rem;
    min-width: 0;
}
.brand-link i {
    font-size: 1.6rem;
    color: #fff;
}
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-accent { color: #4ade80; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.user-btn {
    background: rgba(255,255,255,.18);
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 30px;
    padding: 5px 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.user-btn:hover, .user-btn:focus, .user-btn.show {
    background: rgba(255,255,255,.3);
    color: #fff;
    border-color: #fff;
}

/* =========================================================
   LAYOUT
   ========================================================= */
.app-wrapper {
    display: flex;
    min-height: calc(100vh - 60px);
}

.app-content {
    flex: 1;
    min-width: 0;
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
    width: 260px;
    flex: 0 0 260px;
    background: #fff;
    border-right: 1px solid var(--ve-border);
    display: flex;
    flex-direction: column;
}

.sidebar-head {
    padding: 16px;
    border-bottom: 1px solid var(--ve-border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-head i { font-size: 1.8rem; color: var(--ve-primary); }
.sidebar-brand { font-weight: 800; color: var(--ve-primary); font-size: 1rem; line-height: 1; }
.sidebar-sous { color: var(--ve-muted); font-size: .7rem; letter-spacing: .5px; margin-top: 2px; }

.sidebar .nav-link {
    color: #4b5563;
    padding: .75rem 1.2rem;
    border-left: 3px solid transparent;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all .15s ease;
}
.sidebar .nav-link:hover {
    background: #eff6ff;
    color: var(--ve-primary-2);
}
.sidebar .nav-link.active {
    background: #e0eaff;
    color: var(--ve-primary);
    font-weight: 600;
    border-left-color: var(--ve-primary-2);
}
.sidebar .nav-link i { font-size: 1.1rem; width: 22px; }

.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--ve-border); }

/* Mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 60px 0 0 0;
    background: rgba(0,0,0,.45);
    z-index: 1035;
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 60px; bottom: 0; left: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .25s ease;
        overflow-y: auto;
    }
    .sidebar.show { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
}

@media (min-width: 992px) {
    .sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
}

/* =========================================================
   CARTES
   ========================================================= */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    transition: transform .15s ease;
    height: 100%;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-emoji { font-size: 1.6rem; margin-bottom: 6px; }
.stat-num { font-size: 1.6rem; font-weight: 800; color: var(--ve-primary); line-height: 1.1; }
.stat-label { color: var(--ve-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

/* =========================================================
   TABLEAUX
   ========================================================= */
.table > :not(caption) > * > * { padding: .65rem .6rem; vertical-align: middle; }
.table thead th {
    background: #f1f5fb;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #475569;
    white-space: nowrap;
}

/* =========================================================
   BOUTONS
   ========================================================= */
.btn-primary {
    background: var(--ve-primary-2);
    border-color: var(--ve-primary-2);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--ve-primary);
    border-color: var(--ve-primary);
}
.btn-success { background: var(--ve-success); border-color: var(--ve-success); }
.btn-success:hover { background: #126030; border-color: #126030; }

/* =========================================================
   AUTH (login + register)
   ========================================================= */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f3764 0%, #1e5a96 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.auth-wrapper { width: 100%; max-width: 440px; }

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 20px 50px rgba(15,55,100,.35);
    text-align: center;
}

.auth-logo {
    width: 70px; height: 70px;
    margin: 0 auto 14px;
    background: linear-gradient(135deg, #0f3764, #1e5a96);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 8px 20px rgba(15,55,100,.3);
}

.auth-logo-img {
    width: 130px;
    height: 130px;
    margin: 0 auto 18px auto;
    display: block;
    text-align: center;
}

.auth-logo-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.auth-title {
    text-align: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--ve-primary);
    margin-bottom: 4px;
}
.auth-title span { color: var(--ve-success); }
.auth-subtitle {
    text-align: center;
    color: var(--ve-muted);
    font-size: .85rem;
    margin-bottom: 24px;
}
.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: .85rem;
    color: var(--ve-muted);
}
.auth-footer a { color: var(--ve-primary-2); font-weight: 700; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.auth-copy {
    text-align: center;
    color: rgba(255,255,255,.6);
    font-size: .75rem;
    margin-top: 20px;
}

.auth-card form { text-align: left; }

/* =========================================================
   FORMULAIRES
   ========================================================= */
.form-label { font-weight: 600; font-size: .85rem; color: #334155; margin-bottom: 4px; }
.form-control, .form-select {
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: .9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--ve-primary-2);
    box-shadow: 0 0 0 3px rgba(30,90,150,.1);
}

/* =========================================================
   AVATARS — Tailles forcées (IMPORTANT)
   ========================================================= */

/* ---------- Navbar (petit cercle) ---------- */
.nav-avatar {
    width: 36px !important;
    height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    border: 2px solid rgba(255,255,255,.7);
    flex-shrink: 0;
    display: block;
}

.nav-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.3);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    border: 2px solid rgba(255,255,255,.7);
    flex-shrink: 0;
}

/* ---------- Page profil (grand avatar) ---------- */
.avatar-profil-img {
    width: 120px !important;
    height: 120px !important;
    max-width: 120px !important;
    max-height: 120px !important;
    min-width: 120px !important;
    min-height: 120px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    border: 4px solid #fff;
    box-shadow: 0 6px 20px rgba(15,55,100,.3);
    display: block !important;
    margin: 0 auto;
    overflow: hidden;
}

.avatar-profil {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e5a96, #0f3764);
    color: #fff;
    font-size: 3rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(15,55,100,.3);
    margin: 0 auto;
}

/* ---------- Aperçu avant upload (profil) ---------- */
.photo-preview {
    width: 90px !important;
    height: 90px !important;
    max-width: 90px !important;
    max-height: 90px !important;
    min-width: 90px !important;
    min-height: 90px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    border: 3px solid #e3e8ef;
    display: block !important;
}

.photo-preview-placeholder {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e5a96, #0f3764);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 2rem;
    border: 3px solid #e3e8ef;
}

/* ---------- Liste utilisateurs (petit avatar) ---------- */
.user-avatar-sm {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    border: 2px solid #e5e9f2;
    display: block !important;
    flex-shrink: 0;
}

.user-avatar-placeholder-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e5a96, #0f3764);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .95rem;
    flex-shrink: 0;
}

/* =========================================================
   SÉLECTEUR DE THÈME
   ========================================================= */
.theme-option {
    border: 2px solid #e5e9f2;
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all .2s ease;
    background: #fff;
}
.theme-option:hover {
    border-color: #1e5a96;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30,90,150,.15);
}
.theme-option.selected {
    border-color: #1e5a96;
    box-shadow: 0 0 0 3px rgba(30,90,150,.15);
}
.theme-preview {
    width: 100%; height: 90px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid #e5e9f2;
}
.theme-bar { height: 16px; }
.theme-body { display: flex; height: calc(100% - 16px); }
.theme-side { width: 30%; }
.theme-content { flex: 1; }

.theme-preview-clair .theme-bar { background: #1e5a96; }
.theme-preview-clair .theme-side { background: #f0f4f9; }
.theme-preview-clair .theme-content { background: #ffffff; }

.theme-preview-sombre .theme-bar { background: #1e5a96; }
.theme-preview-sombre .theme-side { background: #1f2937; }
.theme-preview-sombre .theme-content { background: #111827; }

.theme-label {
    font-weight: 600; font-size: .9rem;
    display: flex; align-items: center; gap: 6px;
    color: #334155;
}
.theme-check { display: none; }
.theme-option.selected .theme-check { display: inline-block; }

/* =========================================================
   IMPRESSION
   ========================================================= */
@media print {
    .no-print { display: none !important; }
    .sidebar, .topbar, .sidebar-backdrop { display: none !important; }
    .app-wrapper { display: block; }
}

/* =========================================================
   THÈME SOMBRE
   ========================================================= */
html[data-theme="sombre"] body {
    background: #111827;
    color: #d1d5db;
}
html[data-theme="sombre"] .card {
    background: #1f2937;
    color: #d1d5db;
}
html[data-theme="sombre"] .card-header,
html[data-theme="sombre"] .card-footer {
    background: #1f2937 !important;
    color: #d1d5db;
    border-color: #374151;
}
html[data-theme="sombre"] .sidebar {
    background: #1a2433;
    border-right-color: #374151;
}
html[data-theme="sombre"] .sidebar .nav-link {
    color: #9ca3af;
}
html[data-theme="sombre"] .sidebar .nav-link:hover {
    background: #253245;
    color: #60a5fa;
}
html[data-theme="sombre"] .sidebar .nav-link.active {
    background: #1e3a5f;
    color: #60a5fa;
}
html[data-theme="sombre"] .table {
    color: #d1d5db;
    border-color: #374151;
}
html[data-theme="sombre"] .table thead th {
    background: #1a2433;
    color: #9ca3af;
}
html[data-theme="sombre"] .table td,
html[data-theme="sombre"] .table th {
    border-color: #374151;
}
html[data-theme="sombre"] .table-hover tbody tr:hover {
    background: #253245;
    color: #ffffff;
}
html[data-theme="sombre"] .form-control,
html[data-theme="sombre"] .form-select,
html[data-theme="sombre"] .input-group-text {
    background: #1a2433;
    border-color: #374151;
    color: #d1d5db;
}
html[data-theme="sombre"] .form-control:focus,
html[data-theme="sombre"] .form-select:focus {
    background: #1a2433;
    color: #d1d5db;
    border-color: #3b82f6;
}
html[data-theme="sombre"] .form-control::placeholder {
    color: #6b7280;
}
html[data-theme="sombre"] .text-muted {
    color: #9ca3af !important;
}
html[data-theme="sombre"] .stat-mini {
    background: #1f2937;
    color: #d1d5db;
}
html[data-theme="sombre"] .stat-mini-value {
    color: #60a5fa;
}
html[data-theme="sombre"] .dropdown-menu {
    background: #1f2937;
    border-color: #374151;
}
html[data-theme="sombre"] .dropdown-item {
    color: #d1d5db;
}
html[data-theme="sombre"] .dropdown-item:hover {
    background: #253245;
    color: #60a5fa;
}
html[data-theme="sombre"] .dropdown-divider {
    border-color: #374151;
}
html[data-theme="sombre"] h1,
html[data-theme="sombre"] h2,
html[data-theme="sombre"] h3,
html[data-theme="sombre"] h4,
html[data-theme="sombre"] h5,
html[data-theme="sombre"] h6 {
    color: #ffffff;
}
html[data-theme="sombre"] .modal-content {
    background: #1f2937;
    color: #d1d5db;
}
html[data-theme="sombre"] .modal-header,
html[data-theme="sombre"] .modal-footer {
    border-color: #374151;
}
html[data-theme="sombre"] .btn-close {
    filter: invert(1);
}
html[data-theme="sombre"] .nav-tabs {
    border-color: #374151;
}
html[data-theme="sombre"] .nav-tabs .nav-link {
    color: #9ca3af;
    border-color: transparent;
}
html[data-theme="sombre"] .nav-tabs .nav-link:hover {
    border-color: #374151 #374151 #374151;
    color: #60a5fa;
}
html[data-theme="sombre"] .nav-tabs .nav-link.active {
    background: #1f2937;
    color: #60a5fa;
    border-color: #374151 #374151 #1f2937;
}
html[data-theme="sombre"] .theme-option {
    background: #1a2433;
    border-color: #374151;
}
html[data-theme="sombre"] .theme-label {
    color: #d1d5db;
}
html[data-theme="sombre"] .list-group-item {
    background: #1f2937;
    color: #d1d5db;
    border-color: #374151;
}
html[data-theme="sombre"] .alert-info {
    background: #1a2d4a;
    border-color: #0f3764;
    color: #93c5fd;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 480px) {
    .auth-logo-img {
        width: 110px;
        height: 110px;
    }
    .avatar-profil-img,
    .avatar-profil {
        width: 100px !important;
        height: 100px !important;
        min-width: 100px !important;
        min-height: 100px !important;
    }
}