/* ============================================
   SAV YOUTELL — CSS COMPLET
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #1E3A8A;
    --primary-light: #3b5bdb;
    --secondary: #F97316;
    --accent1: #06B6D4;
    --accent1-light: #22d3ee;
    --accent2: #8B5CF6;
    --accent2-light: #a78bfa;
    --accent3: #EC4899;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #06B6D4;

    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active: rgba(6,182,212,0.12);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;

    --sidebar-width: 260px;
    --topbar-height: 42px;
    --border-radius: 10px;
    --border-radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --transition: 0.2s ease;

    --font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

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

/* ============================================
   TOPBAR (bandeau global compteurs)
   ============================================ */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 90;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 1rem; }

.topbar-counter {
    display: flex; align-items: center; gap: 6px;
    color: #64748b; text-decoration: none; font-size: 0.8rem;
    padding: 0.3rem 0.6rem; border-radius: 6px; transition: all var(--transition);
}
.topbar-counter:hover { background: rgba(255,255,255,0.06); color: #94a3b8; text-decoration: none; }
.topbar-counter.has-items { color: #e2e8f0; }
.topbar-counter.topbar-alert { color: #fbbf24; }
.topbar-counter.topbar-alert .topbar-badge { background: var(--danger); color: white; }
.topbar-counter.topbar-info { color: var(--accent2-light); }

.topbar-badge {
    background: rgba(255,255,255,0.1); color: inherit;
    font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 10px;
    font-size: 0.7rem; min-width: 20px; text-align: center;
}
.topbar-counter.has-items .topbar-badge { background: var(--accent1); color: white; }
.topbar-label { font-size: 0.78rem; }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed; top: var(--topbar-height); left: 0; bottom: 0;
    width: var(--sidebar-width); background: var(--sidebar-bg);
    z-index: 80; overflow-y: auto; padding-bottom: 80px;
}

.navbar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 1.25rem 1.5rem; color: white; font-weight: 700; font-size: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo-circles { display: flex; gap: 4px; }
.circle { width: 8px; height: 8px; border-radius: 50%; }

.sidebar-menu { list-style: none; padding: 0.5rem 0.75rem; }

.sidebar-menu li a {
    display: flex; align-items: center; gap: 10px;
    padding: 0.6rem 1rem; color: #94a3b8; text-decoration: none;
    border-radius: 8px; font-size: 0.88rem; transition: all var(--transition);
    position: relative;
}

.sidebar-menu li a:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-menu li a.active { background: var(--sidebar-active); color: var(--accent1); font-weight: 600; }
.sidebar-menu li a.active::before {
    content: ''; position: absolute; left: 0; top: 20%; bottom: 20%;
    width: 3px; background: var(--accent1); border-radius: 2px;
}

.sidebar-menu li a i { width: 20px; text-align: center; font-size: 0.9rem; }

.sidebar-divider {
    height: 1px; background: rgba(255,255,255,0.06);
    margin: 0.75rem 0.75rem; list-style: none;
}

.sidebar-section-title {
    padding: 0.5rem 1rem 0.25rem; font-size: 0.7rem; text-transform: uppercase;
    letter-spacing: 0.08em; color: #475569; font-weight: 600; list-style: none;
}

.sidebar-badge {
    margin-left: auto; background: var(--accent1); color: white;
    font-size: 0.65rem; font-weight: 700; padding: 0.15rem 0.5rem;
    border-radius: 10px; min-width: 20px; text-align: center;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width); margin-top: var(--topbar-height);
    padding: 1.5rem 2rem 3rem; min-height: calc(100vh - var(--topbar-height));
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--card-bg); border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
    padding: 1.5rem; margin-bottom: 1.5rem;
}

.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title { font-size: 1rem; font-weight: 600; margin: 0; }
.card-title i { margin-right: 6px; }

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg); border-radius: var(--border-radius-lg);
    padding: 1.25rem 1.5rem; box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color); position: relative;
    overflow: hidden; transition: all 0.3s;
}

.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px; background: var(--accent1); opacity: 0; transition: opacity 0.3s;
}

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

.stat-card:nth-child(1)::before { background: var(--accent1); }
.stat-card:nth-child(2)::before { background: var(--accent2); }
.stat-card:nth-child(3)::before { background: var(--secondary); }
.stat-card:nth-child(4)::before { background: var(--accent3); }

.stat-card h3 { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.5rem; }
.stat-card h3 i { margin-right: 6px; }
.stat-card .value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; color: var(--text-primary); }
.stat-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

.stat-link { text-decoration: none; color: inherit; display: block; }
.stat-link:hover { text-decoration: none; }
.stat-card-alert { border-left: 3px solid var(--danger); }
.stat-card-info { border-left: 3px solid var(--accent2); }

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }

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

.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; padding: 0.75rem 1rem; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600; border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem; vertical-align: middle;
}

.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(6,182,212,0.03); }

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex; align-items: center; padding: 0.2rem 0.65rem;
    border-radius: 6px; font-size: 0.75rem; font-weight: 600;
    line-height: 1.4; white-space: nowrap;
}

.badge-primary { background: rgba(30,58,138,0.1); color: var(--primary); }
.badge-secondary { background: rgba(148,163,184,0.15); color: #64748b; }
.badge-success { background: rgba(16,185,129,0.1); color: #059669; }
.badge-danger { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-warning { background: rgba(245,158,11,0.1); color: #d97706; }
.badge-info { background: rgba(6,182,212,0.1); color: #0891b2; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block; margin-bottom: 0.35rem; font-size: 0.88rem;
    font-weight: 500; color: var(--text-secondary);
}

.form-control {
    width: 100%; padding: 0.6rem 0.85rem; border: 1px solid var(--border-color);
    border-radius: 8px; font-size: 0.9rem; font-family: var(--font-family);
    background: var(--card-bg); color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none; border-color: var(--accent1);
    box-shadow: 0 0 0 3px rgba(6,182,212,0.1);
}

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-help {
    font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem;
}

.form-help i { margin-right: 4px; }

.search-form .form-row,
.form-row {
    display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end;
}

.search-form .form-group { flex: 1; min-width: 150px; margin-bottom: 0; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0.55rem 1.15rem; border: none; border-radius: 8px;
    font-size: 0.88rem; font-weight: 600; cursor: pointer;
    font-family: var(--font-family); transition: all 0.2s;
    text-decoration: none; line-height: 1.4;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(30,58,138,0.2); }
.btn-primary:hover { background: var(--primary-light); box-shadow: 0 4px 12px rgba(30,58,138,0.3); }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: #475569; color: white; }

.btn-outline {
    background: transparent; border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover { background: var(--body-bg); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }
.w-100 { width: 100%; }

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 0.85rem 1.25rem; border-radius: var(--border-radius);
    margin-bottom: 1rem; font-size: 0.9rem; border-left: 4px solid;
}

.alert-success { background: rgba(16,185,129,0.08); border-left-color: var(--success); color: #065f46; }
.alert-error { background: rgba(239,68,68,0.08); border-left-color: var(--danger); color: #991b1b; }
.alert-warning { background: rgba(245,158,11,0.08); border-left-color: var(--warning); color: #92400e; }
.alert-info { background: rgba(6,182,212,0.08); border-left-color: var(--info); color: #155e75; }

/* ============================================
   AVATAR
   ============================================ */
.avatar {
    border-radius: 10px; font-weight: 700; letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* ============================================
   TICKET META
   ============================================ */
.ticket-meta {
    display: flex; gap: 1.5rem; flex-wrap: wrap;
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg); padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.ticket-meta-item label {
    display: block; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; margin-bottom: 0.2rem;
}

.ticket-meta-item span { font-size: 0.9rem; }

/* ============================================
   CHAT
   ============================================ */
.chat-container {
    max-height: 450px; overflow-y: auto; padding: 0.5rem 0;
}

.chat-message {
    display: flex; gap: 10px; margin-bottom: 1rem; align-items: flex-start;
}

.chat-message.own { flex-direction: row-reverse; }

.chat-bubble {
    background: var(--body-bg); padding: 0.75rem 1rem;
    border-radius: 12px; max-width: 75%; font-size: 0.9rem;
    line-height: 1.5; border: 1px solid var(--border-color);
}

.chat-message.own .chat-bubble {
    background: rgba(6,182,212,0.08); border-color: rgba(6,182,212,0.15);
}

.note-interne {
    background: #fef3c7 !important; border-color: #f59e0b !important; color: #92400e !important;
}

.chat-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; }
.chat-message.own .chat-meta { text-align: right; }

/* ============================================
   PAGINATION
   ============================================ */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 1.5rem; }

.page-item { display: inline-flex; }
.page-link {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border: 1px solid var(--border-color);
    border-radius: 8px; font-size: 0.85rem; color: var(--text-secondary);
    text-decoration: none; transition: all var(--transition);
}

.page-link:hover { background: var(--body-bg); text-decoration: none; }
.page-item.active .page-link { background: var(--primary); color: white; border-color: var(--primary); }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center; padding: 3rem 2rem; color: var(--text-muted);
}

.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.4; display: block; }
.empty-state p { margin-bottom: 1rem; }

/* ============================================
   FILE LIST
   ============================================ */
.file-list { list-style: none; padding: 0; }
.file-list li {
    padding: 0.5rem 0; border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
}
.file-list li i { color: var(--text-muted); margin-right: 6px; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 500;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: var(--card-bg); border-radius: var(--border-radius-lg);
    padding: 2rem; width: 90%; max-width: 600px;
    max-height: 85vh; overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 { margin: 0; font-size: 1.2rem; }

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-container {
    min-height: 100vh; display: flex; align-items: center;
    justify-content: center; padding: 2rem;
    background: linear-gradient(135deg, #0f172a 0%, #1E3A8A 100%);
}

.auth-card {
    background: var(--card-bg); border-radius: var(--border-radius-lg);
    padding: 2.5rem; width: 100%; max-width: 440px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.auth-logo { margin-bottom: 2rem; }
.auth-logo h1 { font-size: 1.3rem; font-weight: 700; color: var(--primary); margin-top: 0.5rem; }
.auth-logo p { color: var(--text-muted); font-size: 0.9rem; }

.auth-card .btn-primary { width: 100%; justify-content: center; margin-top: 0.5rem; }
.auth-card .form-control { padding: 0.7rem 1rem; }

.auth-links { text-align: center; margin-top: 1.5rem; font-size: 0.85rem; }
.auth-links a { color: var(--accent1); }

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.stat-card { animation: fadeInUp 0.4s ease backwards; }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .topbar { left: 0; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .ticket-meta { flex-direction: column; gap: 0.75rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
