:root {
    --bg-dark: #0a0a0c;
    --glass-bg: rgba(22, 22, 26, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent: #6366f1;
    --accent-light: #818cf8;
    --secondary: #8b5cf6;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --success: #10b981;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    height: 100vh;
    height: -webkit-fill-available;
}

/* Glass morphism */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* Accent gradient */
.accent-gradient {
    background: linear-gradient(135deg, var(--accent), var(--secondary));
}

/* Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #312e81;
    border-radius: 10px;
}

/* WhatsApp Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 350px;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    background: rgba(22, 22, 26, 0.9);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.contact-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 5px;
}

.contact-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.contact-item.active {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

.contact-info {
    flex: 1;
    overflow: hidden;
}

.contact-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.contact-phone {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.admin-badge {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    font-weight: 700;
    text-transform: uppercase;
}

.contact-avatar.admin-avatar {
    background: linear-gradient(135deg, #10b981, #3b82f6);
    border: 2px solid rgba(16, 185, 129, 0.4);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 12, 0.95);
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(22, 22, 26, 0.9);
}

.back-button {
    display: none;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 8px 4px;
    margin-right: -5px;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.chat-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.chat-actions button:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

.chat-actions button.blocked {
    color: #ef4444;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 65%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

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

.message.sent {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received {
    align-self: flex-start;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    text-align: right;
}

.message-input-container {
    padding: 15px 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 10px;
    background: rgba(22, 22, 26, 0.9);
}

.message-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.message-input:focus {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.send-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-button:hover {
    background: var(--accent-light);
    transform: scale(1.05);
}

.send-button:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

/* User Selector (for demo) */
.user-selector {
    padding: 15px;
    background: rgba(22, 22, 26, 0.5);
    border-bottom: 1px solid var(--glass-border);
}

.user-selector label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.user-selector select {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
}

/* Admin Panel Styles */
.admin-container {
    display: flex;
    height: 100vh;
    background: var(--bg-dark);
}

.admin-sidebar {
    width: 280px;
    background: var(--glass-bg);
    border-right: 1px solid var(--glass-border);
    padding: 20px;
}

.admin-sidebar h2 {
    color: var(--accent);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.admin-nav {
    list-style: none;
}

.admin-nav li {
    margin-bottom: 10px;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

.admin-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.admin-content h1 {
    margin-bottom: 25px;
    font-size: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.table-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
}

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

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* Block Status */
.blocked-badge {
    display: inline-block;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Section */
.section {
    margin-bottom: 40px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* Back to chat link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 20px;
    font-weight: 500;
    transition: all 0.2s;
}

.back-link:hover {
    color: var(--accent-light);
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Utilities */
.text-accent { color: var(--accent); }
.text-secondary { color: var(--text-secondary); }

/* Responsive */
@media (max-width: 768px) {
    .auth-card {
        width: 90%;
        padding: 30px 20px;
    }

    .sidebar {
        width: 100%;
        flex: none;
        transition: transform 0.3s ease;
    }

    .chat-area {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 10;
        background: var(--bg-dark);
    }

    .app-container.show-chat .chat-area {
        transform: translateX(0);
    }

    .app-container.show-chat .sidebar {
        transform: translateX(-100%);
    }

    .back-button {
        display: block;
    }

    .message {
        max-width: 85%;
    }

    .message-input-container {
        padding: 10px;
    }

    .message-input {
        padding: 10px 15px;
    }

    /* Admin specific mobile */
    .admin-container {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }
}