/*
 * SAPEO WhatsApp Business - CSS Moderne & Optimisé
 * Design System complet pour une interface professionnelle
 */

/* ========================================
   VARIABLES CSS GLOBALES
======================================== */
:root {
    /* Couleurs principales */
    --primary: #25D366;
    --primary-dark: #20BA59;
    --primary-light: #4ADE80;
    --secondary: #128C7E;
    --accent: #34B7F1;
    
    /* Backgrounds */
    --bg-main: #F0F2F5;
    --bg-white: #FFFFFF;
    --bg-light: #F9FAFB;
    --bg-dark: #111827;
    --bg-chat: #E5DDD5;
    
    /* Textes */
    --text-dark: #111827;
    --text-medium: #374151;
    --text-light: #6B7280;
    --text-lighter: #9CA3AF;
    
    /* Bordures & Séparateurs */
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --divider: #D1D5DB;
    
    /* États */
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    
    /* Ombres */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Espacements */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    /* Rayons de bordure */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-dark);
    background: var(--bg-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* ========================================
   TYPOGRAPHIE
======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-dark);
}

h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; }
h6 { font-size: 14px; }

p {
    margin-bottom: var(--space-md);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ========================================
   LAYOUT PRINCIPAL
======================================== */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    background: var(--bg-main);
    overflow: hidden;
}

/* Main content - pour les conversations (grid) */
.main-content {
    overflow: hidden;
    height: 100vh;
    display: grid;
    grid-template-columns: 400px 1fr;
    position: relative;
}

/* Main content - pour les autres pages (scroll) */
.main-content.page-view {
    display: block;
    overflow-y: auto;
    grid-template-columns: none;
}

/* Overlay pour fermer le panneau d'infos */
.contact-info-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
}

.contact-info-overlay.active {
    display: block;
}

/* ========================================
   SIDEBAR
======================================== */
.sidebar {
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: var(--space-lg);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.sidebar-header h1 {
    font-size: 22px;
    color: white;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-weight: 700;
}

.sidebar-header h1 i {
    font-size: 26px;
}

.connection-status {
    margin-top: var(--space-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    opacity: 0.95;
}

.connection-status i {
    font-size: 8px;
    color: var(--success);
}

/* Stats Rapides */
.quick-stats {
    padding: var(--space-md);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
}

.stat-item {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}

.stat-item:last-child {
    margin-bottom: 0;
}

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

.stat-item i {
    font-size: 24px;
    color: white;
    width: 40px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: white;
    display: block;
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    display: block;
    margin-top: var(--space-xs);
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md) var(--space-sm);
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 12px var(--space-md);
    margin-bottom: var(--space-xs);
    border-radius: var(--radius);
    color: var(--text-medium);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.nav-item:hover::before {
    height: 60%;
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.1), rgba(18, 140, 126, 0.1));
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active::before {
    height: 70%;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.badge {
    background: var(--error);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    margin-left: auto;
    line-height: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
    background: var(--bg-white);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.user-details {
    flex: 1;
}

.user-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.3;
}

.user-role {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.3;
}

.logout-btn {
    width: 40px;
    height: 40px;
    background: #FEF2F2;
    color: var(--error);
    border: none;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    font-size: 16px;
}

.logout-btn:hover {
    background: #FEE2E2;
    transform: scale(1.05);
}

/* ========================================
   MAIN CONTENT
======================================== */
.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    background: var(--bg-main);
    overflow: hidden;
}

/* ========================================
   PANEL CONVERSATIONS
======================================== */
.conversations-panel {
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conversations-header {
    padding: var(--space-lg);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
}

.conversations-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--space-md);
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Boutons */
.btn-icon {
    background: var(--bg-light);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-white);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-new-chat {
    background: var(--primary);
    border: none;
    padding: 10px var(--space-lg);
    border-radius: var(--radius);
    color: white;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
    font-size: 14px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.btn-new-chat:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Search Bar */
.search-bar {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.search-bar i {
    color: var(--text-light);
    font-size: 16px;
}

.search-bar input {
    flex: 1;
    border: 1px solid var(--border);
    background: var(--bg-light);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-dark);
    transition: var(--transition);
}

.search-bar input::placeholder {
    color: var(--text-lighter);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.filter-tabs::-webkit-scrollbar {
    height: 4px;
}

.filter-tabs::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.filter-tab {
    background: transparent;
    border: 1px solid var(--border);
    padding: 8px var(--space-md);
    border-radius: var(--radius-full);
    color: var(--text-medium);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.filter-tab:hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}

.filter-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tab-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
}

.filter-tab.active .tab-count {
    background: rgba(255, 255, 255, 0.2);
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-white);
}

.conversations-list::-webkit-scrollbar {
    width: 6px;
}

.conversations-list::-webkit-scrollbar-track {
    background: transparent;
}

.conversations-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition);
}

.conversation-item:hover {
    background: var(--bg-light);
}

.conversation-item.active {
    background: rgba(37, 211, 102, 0.05);
    border-left: 3px solid var(--primary);
}

.conversation-avatar {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 15px;
    margin-bottom: 2px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-preview {
    color: var(--text-light);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    text-align: right;
    flex-shrink: 0;
}

.conversation-time {
    color: var(--text-lighter);
    font-size: 12px;
    display: block;
    margin-bottom: var(--space-xs);
}

.conversation-item.unread .conversation-time {
    color: var(--primary);
    font-weight: 600;
}

.unread-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: var(--radius-full);
    display: inline-block;
    line-height: 1;
}

/* ========================================
   ZONE DE CHAT
======================================== */
.chat-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    position: relative;
    height: 100vh;
    overflow: hidden;
}

/* Contact Info Panel */
.contact-info-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.contact-info-panel.active {
    right: 0;
}

.contact-info-header {
    padding: var(--space-lg);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.contact-info-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.btn-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: var(--transition);
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.contact-info-content {
    padding: var(--space-lg);
}

.contact-profile {
    text-align: center;
    padding: var(--space-xl) 0;
    border-bottom: 1px solid var(--border);
}

.profile-avatar {
    width: 100px;
    height: 100px;
    margin: 0 auto var(--space-md);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
}

.contact-profile h3 {
    font-size: 20px;
    margin-bottom: var(--space-xs);
}

.contact-profile p {
    color: var(--text-light);
    font-size: 14px;
}

.info-section {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    background: white;
}

.info-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-section h4 i {
    color: var(--primary);
    font-size: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: var(--space-md) 0;
    align-items: center;
}

.info-item label {
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
}

.info-item span {
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 500;
    text-align: right;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.stat-box {
    background: linear-gradient(135deg, var(--bg-light), white);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    text-align: center;
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

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

.stat-number {
    display: block;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-xs);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

.media-item {
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
}

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.tag {
    background: var(--bg-light);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-dark);
}

.chat-header {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-shrink: 0;
}

.contact-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 1;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.contact-details h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.status-text {
    font-size: 12px;
    color: var(--text-light);
}

.chat-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Messages */
.chat-messages-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    background: linear-gradient(to bottom, #E5DDD5 0%, #D9D3CC 100%);
    position: relative;
    min-height: 0;
}

.chat-messages-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect fill="%23D9D3CC" width="100" height="100"/><path d="M0 0L100 100M100 0L0 100" stroke="%23E5DDD5" stroke-width="0.5" opacity="0.05"/></svg>');
    opacity: 0.4;
    pointer-events: none;
}

.chat-messages {
    position: relative;
    z-index: 1;
    background: #E5DDD5;
    min-height: 100%;
    padding: 20px;
}

.chat-messages-wrapper::-webkit-scrollbar {
    width: 8px;
}

.chat-messages-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-full);
}

.message {
    display: flex;
    margin-bottom: 4px;
    padding: 0 var(--space-sm);
    animation: fadeIn 0.3s ease;
    align-items: flex-end;
    gap: 4px;
    clear: both;
    width: 100%;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 4px;
}

.message.sent .message-avatar {
    order: 2;
    display: none;
}

.message-content {
    max-width: 65%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.message.sent .message-content {
    align-items: flex-end;
}

.message.received .message-content {
    align-items: flex-start;
}

.message-bubble {
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: var(--transition);
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
}

.message-bubble:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

/* Triangles pour bulles WhatsApp */
.message.received .message-bubble::before {
    content: '';
    position: absolute;
    left: -7px;
    bottom: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 10px 10px;
    border-color: transparent transparent white transparent;
}

.message.sent .message-bubble::before {
    content: '';
    position: absolute;
    right: -7px;
    bottom: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 10px 10px 0;
    border-color: transparent transparent #DCF8C6 transparent;
}

/* Couleurs des bulles */
.message.received .message-bubble {
    background: white;
    color: var(--text-dark);
}

.message.sent .message-bubble {
    background: #DCF8C6;
    color: var(--text-dark);
}

/* Message avec réponse */
.message-reply-preview {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--primary);
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 4px;
    font-size: 13px;
}

.message-reply-preview .reply-sender {
    color: var(--primary);
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 2px;
}

.message-reply-preview .reply-text {
    color: var(--text-light);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-text {
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.message-media {
    margin-bottom: 6px;
    border-radius: 8px;
    overflow: hidden;
}

.message-media img,
.message-media video {
    max-width: 100%;
    max-height: 400px;
    display: block;
    border-radius: 8px;
    cursor: pointer;
}

.message-time {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.45);
    margin-top: 2px;
    margin-left: auto;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    float: right;
    margin-left: 4px;
}

.message.sent .message-time {
    color: rgba(0, 0, 0, 0.45);
}

.message-status {
    display: inline-flex;
    align-items: center;
}

.message-status i {
    font-size: 14px;
}

.message-status.read {
    color: #4FC3F7;
}

.message-status.delivered {
    color: #9E9E9E;
}

.message-status.sent {
    color: #9E9E9E;
}

.message-status.pending {
    color: #FFA726;
}

/* Menu contextuel message */
.message-actions {
    position: absolute;
    top: -8px;
    right: 0;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 10;
    overflow: hidden;
}

.message:hover .message-actions {
    display: flex;
}

.message-action-btn {
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

.message-action-btn:hover {
    background: var(--bg-light);
    color: var(--primary);
}

/* Menu contextuel étendu */
.message-context-menu {
    position: absolute;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
    z-index: 100;
    overflow: hidden;
    display: none;
}

.message-context-menu.active {
    display: block;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 12px var(--space-md);
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-dark);
    font-size: 14px;
}

.context-menu-item:hover {
    background: var(--bg-light);
}

.context-menu-item i {
    width: 20px;
    text-align: center;
    color: var(--text-light);
}

.context-menu-item.danger {
    color: var(--error);
}

.context-menu-item.danger:hover {
    background: #FEE2E2;
}

/* Date separator */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: var(--space-lg) 0;
}

.date-separator span {
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* Empty State */
.no-chat-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
    padding: var(--space-xl);
    text-align: center;
}

.empty-icon {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-xl);
}

.empty-icon i {
    font-size: 60px;
    color: white;
}

.no-chat-selected h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
}

.no-chat-selected p {
    font-size: 15px;
    color: var(--text-light);
    margin-bottom: var(--space-lg);
    max-width: 400px;
}

.btn-primary {
    background: var(--primary);
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius);
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Promo Box */
.promo-box {
    margin-top: var(--space-xl);
    padding: var(--space-lg);
    background: white;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
}

.promo-box p {
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.btn-promo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--primary);
    color: white;
    padding: 10px var(--space-lg);
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
}

.btn-promo:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* ========================================
   ZONE DE SAISIE
======================================== */
#chatInputContainer {
    padding: var(--space-md) var(--space-lg);
    background: #F0F0F0;
    border-top: 1px solid var(--border);
    position: relative;
    display: block !important;
    flex-shrink: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.chat-input-container {
    padding: var(--space-md) var(--space-lg);
    background: #F0F0F0;
    border-top: 1px solid var(--border);
    position: relative;
    display: block !important;
    flex-shrink: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Reply preview bar */
.reply-preview-bar {
    background: white;
    padding: var(--space-sm) var(--space-md);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius) var(--radius) 0 0;
    margin-bottom: var(--space-sm);
    display: none;
    align-items: center;
    justify-content: space-between;
}

.reply-preview-bar.active {
    display: flex;
}

.reply-preview-content {
    flex: 1;
}

.reply-preview-title {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 2px;
}

.reply-preview-text {
    font-size: 13px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: var(--space-xs);
    font-size: 18px;
    transition: var(--transition);
}

.reply-preview-close:hover {
    color: var(--text-dark);
}

.chat-input-wrapper {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-end;
    max-width: 100%;
}

.input-actions-left {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    flex-shrink: 0;
}

.input-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 20px;
    flex-shrink: 0;
}

.input-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dark);
}

.input-btn.active {
    background: var(--primary);
    color: white;
}

/* Attachment Menu */
.attachment-menu {
    position: absolute;
    bottom: 60px;
    left: var(--space-md);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-sm);
    display: none;
    flex-direction: column;
    gap: var(--space-xs);
    z-index: 10;
}

.attachment-menu.active {
    display: flex;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    white-space: nowrap;
}

.attachment-item:hover {
    background: var(--bg-light);
}

.attachment-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.attachment-icon.image {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.attachment-icon.video {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.attachment-icon.document {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.attachment-icon.audio {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
}

.attachment-icon.contact {
    background: linear-gradient(135deg, #fa709a, #fee140);
}

.attachment-icon.location {
    background: linear-gradient(135deg, #30cfd0, #330867);
}

.attachment-label {
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 500;
}

/* Media Preview */
.media-preview {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-light);
    padding: var(--space-md);
    border-top: 1px solid var(--border);
    display: none;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: var(--space-sm);
}

.media-preview.active {
    display: flex;
}

.media-preview-item {
    position: relative;
    flex-shrink: 0;
}

.media-preview-img {
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 2px solid var(--border);
}

.media-preview-doc {
    width: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-sm);
    text-align: center;
}

.media-preview-doc i {
    font-size: 40px;
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.media-preview-doc .doc-name {
    font-size: 11px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.media-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--error);
    color: white;
    border: 2px solid white;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.media-preview-remove:hover {
    transform: scale(1.1);
    background: #c62828;
}

.input-message-wrapper {
    flex: 1;
    background: white;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

#messageInput {
    width: 100%;
    min-height: 40px;
    max-height: 120px;
    padding: 10px var(--space-md);
    border: none;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    outline: none;
    box-sizing: border-box;
}

#messageInput::placeholder {
    color: var(--text-lighter);
}

.input-actions-right {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

#btnSend, #btnVoice {
    background: var(--primary);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    font-size: 18px;
}

#btnSend:hover:not(:disabled), #btnVoice:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

#btnSend:disabled {
    background: #BDBDBD;
    cursor: not-allowed;
    opacity: 0.7;
}

#btnVoice {
    display: none;
}

#btnVoice.active {
    display: flex;
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 60px;
    right: var(--space-md);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 320px;
    max-height: 400px;
    display: none;
    flex-direction: column;
    z-index: 10;
}

.emoji-picker.active {
    display: flex;
}

.emoji-picker-header {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: var(--space-xs);
    overflow-x: auto;
}

.emoji-category-btn {
    background: transparent;
    border: none;
    padding: var(--space-xs);
    cursor: pointer;
    font-size: 20px;
    opacity: 0.5;
    transition: var(--transition);
}

.emoji-category-btn:hover,
.emoji-category-btn.active {
    opacity: 1;
}

.emoji-picker-content {
    padding: var(--space-md);
    overflow-y: auto;
    flex: 1;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji-item {
    background: transparent;
    border: none;
    font-size: 24px;
    padding: 6px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
}

.emoji-item:hover {
    background: var(--bg-light);
    transform: scale(1.2);
}

.chat-input-main {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
}

.btn-send:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 260px 1fr;
    }
    
    .main-content {
        grid-template-columns: 360px 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .conversations-panel {
        display: none;
    }
}

/* ========================================
   UTILITIES
======================================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    color: var(--text-light);
}

.loading-spinner i {
    font-size: 32px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   ANIMATIONS
======================================== */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   DARK MODE (Optionnel)
======================================== */
[data-theme="dark"] {
    --bg-main: #0F172A;
    --bg-white: #1E293B;
    --bg-light: #334155;
    --text-dark: #F1F5F9;
    --text-medium: #E2E8F0;
    --text-light: #94A3B8;
    --text-lighter: #64748B;
    --border: #334155;
    --border-light: #475569;
    --bg-chat: #1E293B;
}

/* ========================================
   PAGE CONTACTS
======================================== */
.contacts-container {
    padding: var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
}

.contacts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
}

.contacts-header h1 {
    font-size: 28px;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-actions {
    display: flex;
    gap: var(--space-md);
}

.btn-secondary {
    background: var(--bg-light);
    border: 1px solid var(--border);
    padding: 12px var(--space-lg);
    border-radius: var(--radius);
    color: var(--text-medium);
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

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

.contacts-filters {
    background: var(--bg-white);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    box-shadow: var(--shadow);
}

.search-box {
    flex: 1;
    min-width: 300px;
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.search-box i {
    color: var(--text-light);
    font-size: 16px;
}

.search-box input {
    flex: 1;
    padding: 12px var(--space-md);
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dark);
    font-size: 14px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.filter-options {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.filter-options select {
    padding: 12px var(--space-md);
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dark);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-options select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.contacts-table-container {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.contacts-table {
    width: 100%;
    border-collapse: collapse;
}

.contacts-table thead {
    background: var(--bg-light);
}

.contacts-table th {
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.contacts-table td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-medium);
    font-size: 14px;
}

.contacts-table tbody tr {
    transition: var(--transition);
}

.contacts-table tbody tr:hover {
    background: var(--bg-light);
}

.contact-name {
    font-weight: 600;
    color: var(--text-dark);
}

.contact-tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-light);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-medium);
    margin-right: var(--space-xs);
}

/* ========================================
   PAGE TEMPLATES
======================================== */
.templates-container {
    padding: var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
}

.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
}

.templates-header h1 {
    font-size: 28px;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-lg);
}

.template-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.template-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.template-status {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.template-status.approved {
    background: #D1FAE5;
    color: #065F46;
}

.template-status.pending {
    background: #FEF3C7;
    color: #92400E;
}

.template-status.rejected {
    background: #FEE2E2;
    color: #991B1B;
}

.template-body {
    color: var(--text-medium);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: var(--space-md);
}

.template-footer {
    display: flex;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

.btn-template {
    flex: 1;
    padding: 8px var(--space-md);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-medium);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

.btn-template:hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ========================================
   PAGE SETTINGS
======================================== */
.settings-container {
    padding: var(--space-xl);
    max-width: 1200px;
    margin: 0 auto;
}

.settings-header {
    margin-bottom: var(--space-xl);
}

.settings-header h1 {
    font-size: 28px;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.settings-tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: var(--space-md) var(--space-lg);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.settings-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--border-light);
}

.card-header h2 {
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.status-badge {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: #D1FAE5;
    color: #065F46;
}

.status-inactive {
    background: #FEE2E2;
    color: #991B1B;
}

.form-section {
    margin-bottom: var(--space-xl);
}

.form-section h3 {
    font-size: 18px;
    color: var(--text-dark);
    margin-bottom: var(--space-md);
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px var(--space-md);
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dark);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.form-group small {
    display: block;
    color: var(--text-light);
    font-size: 12px;
    margin-top: var(--space-xs);
}

.form-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-light);
}

.btn-save {
    background: var(--primary);
    border: none;
    padding: 12px var(--space-xl);
    border-radius: var(--radius);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.btn-save:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ========================================
   PAGE STATISTICS
======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-white);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

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

.stat-card-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-card-info p {
    color: var(--text-light);
    margin-bottom: var(--space-xs);
    font-size: 13px;
}

.stat-card-info h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card-icon {
    font-size: 48px;
    opacity: 0.2;
}

.stat-card.success {
    border-left-color: var(--success);
}

.stat-card.success h2,
.stat-card.success .stat-card-icon {
    color: var(--success);
}

.stat-card.info {
    border-left-color: var(--info);
}

.stat-card.info h2,
.stat-card.info .stat-card-icon {
    color: var(--info);
}

.stat-card.warning {
    border-left-color: var(--warning);
}

.stat-card.warning h2,
.stat-card.warning .stat-card-icon {
    color: var(--warning);
}

/* ========================================
   MODALS
======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--border-light);
}

.modal-header h3 {
    font-size: 20px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--error);
}

/* ========================================
   ALERTS & NOTIFICATIONS
======================================== */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.alert-success {
    background: #D1FAE5;
    border-left: 4px solid var(--success);
    color: #065F46;
}

.alert-error {
    background: #FEE2E2;
    border-left: 4px solid var(--error);
    color: #991B1B;
}

.alert-warning {
    background: #FEF3C7;
    border-left: 4px solid var(--warning);
    color: #92400E;
}

.alert-info {
    background: #DBEAFE;
    border-left: 4px solid var(--info);
    color: #1E40AF;
}

/* Toast Container */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--bg-white);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 300px;
    animation: slideInRight 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

/* ========================================
   PAGE LOGIN
======================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: var(--space-lg);
}

.login-box {
    background: var(--bg-white);
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 450px;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-md);
    box-shadow: var(--shadow-lg);
}

.login-logo i {
    font-size: 40px;
    color: white;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: var(--space-xs);
}

.login-header p {
    color: var(--text-light);
    font-size: 14px;
}

.login-form {
    margin-bottom: var(--space-lg);
}

.login-form .form-group {
    margin-bottom: var(--space-lg);
}

.login-form label {
    display: block;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--space-sm);
    font-size: 14px;
}

.login-form .input-group {
    position: relative;
}

.login-form .input-group i {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.login-form input {
    width: 100%;
    padding: 12px var(--space-md) 12px 40px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dark);
    font-size: 14px;
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.login-form .btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    margin-top: var(--space-md);
}

.login-form .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.login-footer {
    text-align: center;
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-light);
}

.login-footer p {
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: var(--space-sm);
}

.login-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

.login-error {
    background: #FEE2E2;
    border-left: 4px solid var(--error);
    color: #991B1B;
    padding: var(--space-md);
    border-radius: var(--radius);
    margin-bottom: var(--space-lg);
    font-size: 14px;
}

/* ========================================
   EMPTY STATES
======================================== */
.empty-state {
    background: var(--bg-white);
    padding: var(--space-xl);
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow);
}

.empty-state-icon {
    font-size: 64px;
    color: var(--primary);
    margin-bottom: var(--space-lg);
    opacity: 0.6;
}

.empty-state h2 {
    font-size: 20px;
    margin-bottom: var(--space-sm);
}

.empty-state p {
    color: var(--text-light);
    margin-bottom: var(--space-lg);
}

/* ========================================
   ANIMATIONS & KEYFRAMES
======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

.toast.toast-success {
    background: var(--success);
    color: white;
}

.toast.toast-error {
    background: var(--error);
    color: white;
}

.toast.toast-warning {
    background: var(--warning);
    color: white;
}

.toast.toast-info {
    background: var(--info);
    color: white;
}

/* Loading Spinner */
.loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: var(--radius-full);
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
}

/* Typing Indicator */
.typing-indicator-dots {
    display: inline-flex;
    gap: 4px;
}

.typing-indicator-dots span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-light);
    animation: pulse 1.4s infinite;
}

.typing-indicator-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Utility Classes */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideIn 0.3s ease;
}

.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.fw-bold {
    font-weight: 700;
}

.fw-semibold {
    font-weight: 600;
}

.fw-normal {
    font-weight: 400;
}

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.p-0 { padding: 0; }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* ========================================
   PAGES - LAYOUT & SCROLL
======================================== */
.main-content {
    overflow-y: auto;
    height: 100vh;
    background: var(--bg-main);
}

.settings-container,
.contacts-container,
.templates-container,
.statistics-container,
.automations-container,
.donations-container {
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-main);
}

.settings-header,
.contacts-header,
.templates-header,
.stats-header,
.automations-header,
.donations-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.settings-tabs,
.filter-tabs {
    position: sticky;
    top: 80px;
    z-index: 9;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 var(--space-xl);
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 240px 1fr;
    }
    
    .sidebar-header h1 {
        font-size: 18px;
    }
    
    .stat-item {
        padding: var(--space-sm);
    }
    
    .stat-value {
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .chat-messages-wrapper {
        padding: var(--space-md);
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .emoji-picker {
        width: 100%;
        max-width: 320px;
    }
}
