/* ============================================================
   YEGLU – Style inspiré de BIONICONNECT
   Palette indigo/violet · Inter · Cartes blanches · Shadows douces
   ============================================================ */

/* ---- Google Fonts : Inter ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700;800&display=swap');

/* ============================================================
   VARIABLES
   ============================================================ */
:root {
    /* Couleurs primaires */
    --primary:        #667eea;
    --primary-dark:   #5a67d8;
    --primary-light:  #818cf8;
    --gradient:       linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-subtle:linear-gradient(135deg, rgba(102,126,234,.08) 0%, rgba(118,75,162,.05) 100%);

    /* Sémantiques */
    --success: #10b981;
    --warning: #f59e0b;
    --danger:  #ef4444;
    --info:    #8b5cf6;

    /* Surfaces & fonds */
    --bg:         #f0f2f5;
    --bg-card:    #ffffff;
    --surface-50: #f8fafc;
    --surface-100:#f1f5f9;

    /* Sidebar */
    --sidebar-bg:     #1e1b4b;
    --sidebar-text:   #a5b4fc;
    --sidebar-active: #667eea;
    --sidebar-width:  260px;

    /* Texte */
    --text:           #1e293b;
    --text-primary:   #1e293b;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;

    /* Bordures */
    --border: #e2e8f0;
    --border-light: rgba(226,232,240,.6);

    /* Rayons */
    --radius:    12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    /* Ombres */
    --shadow:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.08);
    --shadow-xl: 0 20px 60px rgba(0,0,0,.10);

    --font:       'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --transition: .2s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper { display: flex; min-height: 100vh; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar fine sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.brand-logo {
    width: 40px; height: 40px;
    background: transparent;
    border-radius: 10px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgba(102,60,200,.35));
}

.brand-name {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    letter-spacing: .3px;
}

.brand-tagline {
    font-size: 10px;
    color: rgba(165,180,252,.6);
    margin-top: 1px;
    font-weight: 500;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(165,180,252,.4);
    padding: 18px 20px 6px;
}

.sidebar-nav { padding: 8px 10px; flex: 1; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: rgba(102,126,234,.12);
    color: #c7d2fe;
}

.sidebar-link.active {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102,126,234,.35);
}

.sidebar-link .icon {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: .75;
}

.sidebar-link.active .icon,
.sidebar-link:hover .icon { opacity: 1; }

.sidebar-footer {
    padding: 14px 10px;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.04);
    margin-bottom: 6px;
}

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(102,126,234,.4);
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #e0e7ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: rgba(165,180,252,.6);
    text-transform: capitalize;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    background: rgba(255,255,255,.85);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(226,232,240,.8);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: box-shadow var(--transition);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition);
}

.menu-toggle:hover { background: var(--surface-100); color: var(--primary); }

.page-title {
    font-size: 16px;
    font-weight: 650;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
    padding: 24px;
    flex: 1;
    max-width: 1600px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-card);
}

.card-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body { padding: 20px; }

.mb-3 { margin-bottom: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-1 { margin-bottom: 8px; }
.mt-3 { margin-top: 24px; }
.mt-2 { margin-top: 16px; }
.mt-1 { margin-top: 8px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}

.stat-icon.blue   { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.stat-icon.green  { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; }
.stat-icon.red    { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.stat-icon.sky    { background: linear-gradient(135deg, #0ea5e9, #0284c7); color: #fff; }

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.stat-trend    { font-size: 12px; font-weight: 600; margin-top: 4px; }
.trend-up      { color: var(--success); }
.trend-down    { color: var(--danger); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font);
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102,126,234,.35);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(102,126,234,.45);
    opacity: .92;
    color: #fff;
}

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

.btn-secondary:hover {
    background: var(--surface-100);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-success   { background: linear-gradient(135deg, #10b981, #059669); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,.3); }
.btn-success:hover { opacity: .9; color: #fff; }

.btn-danger    { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,.3); }
.btn-danger:hover { opacity: .9; color: #fff; }

.btn-warning   { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.btn-warning:hover { opacity: .9; color: #fff; }

.btn-outline   { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--gradient); color: #fff; border-color: transparent; }

.btn-sm  { padding: 5px 12px; font-size: 12.5px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    background: var(--surface-50);
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .45px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-50); }

tbody td {
    padding: 12px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}

.td-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: var(--font);
    color: var(--text-primary);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102,126,234,.15);
}

.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 100px; resize: vertical; }

.form-hint  { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: .2px;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: rgba(102,126,234,.12); color: var(--primary-dark); }
.badge-muted   { background: var(--surface-100); color: var(--text-secondary); }

/* ============================================================
   ALERTS / FLASH MESSAGES
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success { background: #f0fdf4; color: #166534; border-color: var(--success); }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: var(--danger); }
.alert-warning { background: #fffbeb; color: #92400e; border-color: var(--warning); }
.alert-info    { background: rgba(102,126,234,.07); color: var(--primary-dark); border-color: var(--primary); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 44px; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.empty-state p  { font-size: 13.5px; color: var(--text-muted); }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .separator { color: var(--border); }
.breadcrumb .current { color: var(--text-primary); font-weight: 600; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
}

.page-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all var(--transition);
    font-family: var(--font);
}

.page-btn:hover, .page-btn.active {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102,126,234,.3);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.4);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: translateY(-16px) scale(.98);
    transition: transform var(--transition);
    border: 1px solid var(--border-light);
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title  { font-size: 16px; font-weight: 700; }
.modal-close  { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-muted); padding: 4px; transition: color var(--transition); }
.modal-close:hover { color: var(--danger); }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 10px; }

/* ============================================================
   PLAN CARDS
   ============================================================ */
.plan-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
}

.plan-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 20px;
    text-align: center;
    transition: all var(--transition);
    background: #fff;
}

.plan-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.plan-card.current {
    border-color: var(--primary);
    background: rgba(102,126,234,.04);
    box-shadow: 0 0 0 3px rgba(102,126,234,.12);
}

.plan-card.featured { border-color: var(--success); }

.plan-name  { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.plan-price { font-size: 26px; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.plan-price .currency { font-size: 14px; font-weight: 600; }
.plan-period { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.plan-features { list-style: none; font-size: 13px; text-align: left; margin-bottom: 16px; }
.plan-features li { padding: 4px 0; display: flex; align-items: center; gap: 6px; }
.plan-features li::before { content: '✓'; color: var(--success); font-weight: 700; }

/* ============================================================
   QR CODE
   ============================================================ */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.qr-image {
    border: 3px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   SCAN MOBILE (layout plein écran)
   ============================================================ */
.scan-page {
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 24px 16px;
    color: #fff;
}

.scan-header {
    text-align: center;
    margin-bottom: 24px;
}

.scan-header h1 { font-size: 21px; font-weight: 800; }
.scan-header p  { font-size: 13.5px; color: rgba(165,180,252,.75); margin-top: 4px; }

.scan-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 22px;
    width: 100%;
    max-width: 420px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
}

.scan-point-name { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.scan-site-name  { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 20px; }

.scan-success { text-align: center; padding: 32px 0; }
.scan-success .check-icon { font-size: 56px; color: var(--success); margin-bottom: 16px; }
.scan-success h2 { font-size: 21px; font-weight: 800; }
.scan-success p  { color: var(--text-secondary); margin-top: 8px; font-size: 13.5px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    :root { --sidebar-width: 240px; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: flex; }
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; height: 56px; }
    .form-row { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .stat-cards  { grid-template-columns: 1fr; }
    .plan-cards  { grid-template-columns: 1fr; }
    .td-actions  { flex-wrap: wrap; }
    .page-content { padding: 12px; }
}

/* ============================================================
   SIDEBAR OVERLAY MOBILE
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ============================================================
   LOADER
   ============================================================ */
.spinner {
    width: 22px; height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-muted    { color: var(--text-muted); }
.text-small    { font-size: 12px; }
.fw-bold       { font-weight: 700; }
.text-gradient { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-full  { width: 100%; }
.hidden  { display: none !important; }
.d-none  { display: none; }
