/* Import Google Font Outfit */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette */
    --bg-main: #0a0e17;
    --bg-sidebar: #0f1524;
    --bg-card: rgba(20, 28, 47, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --primary: #25d366; /* WhatsApp Green */
    --primary-glow: rgba(37, 211, 102, 0.15);
    --primary-hover: #1ebd58;
    
    --secondary: #8b5cf6; /* Violet */
    --secondary-glow: rgba(139, 92, 246, 0.15);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;
    
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --glass-blur: 16px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Background animated mesh blur */
.mesh-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: float 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: var(--primary);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 45vw;
    height: 45vw;
    background: var(--secondary);
    animation-delay: -5s;
}

.grid-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

/* Sidebar Navigation */
aside.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 8px;
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
}

.sidebar-logo svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.brand-text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand-subtext {
    color: var(--primary);
    font-weight: 500;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 10px;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.sidebar-menu li a svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: var(--transition-fast);
}

.sidebar-menu li a:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

.sidebar-menu li.active a {
    color: #fff;
    background: linear-gradient(90deg, rgba(37, 211, 102, 0.1), rgba(139, 92, 246, 0.05));
    border-color: rgba(37, 211, 102, 0.2);
}

.sidebar-menu li.active a svg {
    color: var(--primary);
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.connection-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--danger);
    transition: var(--transition-fast);
}

.status-dot.connected {
    background-color: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

/* Main Content Wrapper */
main.content-area {
    flex-grow: 1;
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

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

header.content-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--bg-main);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.2);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

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

/* Card components (Glassmorphism) */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Tabs panels */
.tab-panel {
    display: none;
    animation: fadeIn var(--transition-normal);
}

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

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

/* --- ONGLET CONNECTIVITY --- */
.connectivity-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 30px;
}

.qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.qr-container {
    width: 260px;
    height: 260px;
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    margin: 25px 0;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.qr-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 23, 0.9);
    backdrop-filter: blur(4px);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
}

.qr-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.stat-card {
    text-align: center;
    padding: 20px;
}

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

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- ONGLET KNOWLEDGE BASE --- */
.kb-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    min-height: 500px;
}

.kb-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.product-item:hover, .product-item.active {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
}

.product-item.active {
    border-color: var(--primary);
}

.product-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.product-price {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 700;
}

.rule-group {
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.rule-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.rule-title {
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
}

.rule-textarea {
    width: 100%;
    height: 120px;
    background: rgba(10, 14, 23, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    padding: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    resize: vertical;
    transition: var(--transition-fast);
}

.rule-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.1);
}

/* --- ONGLET CHAT SIMULATOR --- */
.chat-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    height: calc(100vh - 200px);
    max-height: 750px;
}

.scenarios-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    overflow-y: auto;
}

.scenario-card {
    padding: 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.scenario-card:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--primary-glow);
}

.scenario-card h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.scenario-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chat-box {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 21, 36, 0.4);
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-avatar {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.2);
}

.chat-info h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chat-status {
    font-size: 0.75rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-status-pulse {
    width: 6px;
    height: 6px;
    background-color: var(--primary);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.4; }
    100% { transform: scale(1); opacity: 1; }
}

.chat-messages {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: rgba(10, 14, 23, 0.3);
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
}

.message.incoming {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom-left-radius: 2px;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.message.outgoing {
    align-self: flex-end;
    background-color: #056162; /* WhatsApp styled outgoing */
    color: #e9edef;
    border-bottom-right-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message.system {
    align-self: center;
    max-width: 90%;
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--warning);
    border-radius: 8px;
    text-align: center;
    font-size: 0.8rem;
    padding: 8px 12px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    align-self: flex-start;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1s infinite alternate;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    from { opacity: 0.3; transform: translateY(0); }
    to { opacity: 1; transform: translateY(-4px); }
}

.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(15, 21, 36, 0.4);
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input {
    flex-grow: 1;
    background: rgba(10, 14, 23, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.9rem;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* --- ONGLET SETTINGS --- */
.settings-section {
    margin-bottom: 35px;
}

.settings-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 18px;
    color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: rgba(10, 14, 23, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    padding: 12px;
    font-family: inherit;
    font-size: 0.9rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.1);
}

.help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Loading spinner */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top: 3px solid var(--primary);
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive grid layouts */
@media (max-width: 1024px) {
    .connectivity-grid, .kb-grid, .chat-container {
        grid-template-columns: 1fr;
    }
    aside.sidebar {
        width: 80px;
        padding: 20px 10px;
        align-items: center;
    }
    .brand-text, .connection-pill span {
        display: none;
    }
    .sidebar-menu li a {
        justify-content: center;
        padding: 12px;
    }
    .sidebar-menu li a span {
        display: none;
    }
}

/* --- ONGLET LIVE CHAT --- */
.live-chat-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    height: calc(100vh - 180px);
    min-height: 550px;
}

.live-chat-list-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
}

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

.card-header-simple h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.chat-search-bar {
    margin-bottom: 15px;
}

.chat-list-items {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-item-btn {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 12px 15px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    text-align: left;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-color);
}

.chat-item-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.chat-item-btn.active {
    background: rgba(37, 211, 102, 0.08);
    border-color: var(--primary);
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 5px;
}

.chat-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.chat-item-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.badge-bot {
    background: rgba(37, 211, 102, 0.15);
    color: var(--primary);
}

.badge-human {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.chat-item-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.live-chat-window-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    overflow: hidden;
}

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

.chat-window-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.mode-control-badge {
    display: flex;
    align-items: center;
}

.btn-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-toggle.bot-active {
    background: rgba(37, 211, 102, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-toggle.human-active {
    background: rgba(168, 85, 247, 0.1);
    border-color: #a855f7;
    color: #a855f7;
}

.chat-window-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(0, 0, 0, 0.15);
}

.msg-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.msg-bubble.sent {
    align-self: flex-end;
    background: rgba(37, 211, 102, 0.15);
    border: 1px solid rgba(37, 211, 102, 0.3);
    border-bottom-right-radius: 2px;
    color: var(--text-color);
}

.msg-bubble.received {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
    color: var(--text-color);
}

.msg-meta {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 5px;
    text-align: right;
}

.chat-window-footer {
    display: flex;
    gap: 15px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

