:root {
    --primary: #f97316; /* Vibrant Orange */
    --primary-dark: #ea580c;
    --primary-light: #fff7ed;
    --secondary: #6c757d;
    --accent: #25d366; /* WhatsApp Green */
    --accent-hover: #128c7e;
    --bg-dark: #1e293b;
    --bg-panel: #0f172a;
    --text-main: #334155;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
    --card-bg: #ffffff;
    --body-bg: #f8fafc;
}

/* Base styles only for standalone page */
body.chat-standalone-page {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--body-bg);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
}

/* Embed Mode - No background, full height */
body.embed-mode, html {
    height: 100%;
    margin: 0;
    padding: 0;
}

body.embed-mode {
    background: transparent !important;
    display: block !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.embed-mode #chat-widget {
    height: 100% !important;
    width: 100% !important;
    max-height: none !important;
    max-width: none !important;
    min-height: auto !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
}

body.embed-mode .chat-wrapper {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
}

/* Chatbot Styles (Isolated in Iframe) */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.chat-wrapper {
    width: 100%;
    max-width: 480px;
}

#chat-widget { 
    width: 100%; 
    height: 80vh; 
    max-height: 750px;
    min-height: 550px;
    background: rgba(255, 255, 255, 0.97); 
    backdrop-filter: blur(10px);
    border-radius: 20px; 
    box-shadow: 0 20px 40px rgba(234, 88, 12, 0.15), 0 1px 3px rgba(0,0,0,0.05); 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    border: 1px solid rgba(255, 255, 255, 0.8);
}

#chat-header { 
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); 
    color: white; 
    padding: 20px; 
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.2);
    z-index: 10;
    flex-shrink: 0; /* Prevent disappearing on small screens */
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.embed-only-btn {
    display: none; /* Hidden by default on standalone */
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    margin-right: auto;
    transition: background 0.3s;
}

body.embed-mode .embed-only-btn {
    display: none !important;
}

@media (max-width: 480px) {
    .header-content {
        gap: 10px;
    }
    .header-text h3 {
        font-size: 16px;
    }
}

.bot-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255,255,255,0.4);
}

.header-text h3 { 
    margin: 0 0 4px 0; 
    font-size: 18px; 
    font-weight: 700; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.1); 
    color: white;
}
.status-indicator { font-size: 12px; opacity: 0.9; font-weight: 600; display: flex; align-items: center; gap: 5px; color: white; }
.status-indicator::before { content: ""; display: inline-block; width: 8px; height: 8px; background: #fff; border-radius: 50%; box-shadow: 0 0 5px rgba(255,255,255,0.8); }

#chat-messages { flex: 1; padding: 20px 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: transparent; scroll-behavior: smooth; }

.message { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; word-wrap: break-word; position: relative; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.message.user { align-self: flex-start; background: #f1f5f9; color: var(--text-main); border-bottom-left-radius: 4px; border: 1px solid #e2e8f0; }
.message.bot { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 4px; box-shadow: 0 4px 10px rgba(249, 115, 22, 0.2); border: 1px solid var(--primary-dark); }

#chat-input-area { padding: 15px 20px; background: white; border-top: 1px solid #f1f5f9; display: flex; align-items: center; gap: 12px; z-index: 10; position: relative; flex-shrink: 0; /* Prevent disappearing on small screens */ }

#user-input { 
    flex: 1; 
    padding: 14px 20px; 
    border: 1px solid #e2e8f0; 
    border-radius: 30px; 
    outline: none; 
    font-size: 15px; 
    font-family: inherit; 
    background: #f8fafc; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
}
#user-input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1); }

#send-btn { background: var(--primary); color: white; border: none; width: 45px; height: 45px; border-radius: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 18px; transition: all 0.3s; box-shadow: 0 4px 10px rgba(249, 115, 22, 0.2); flex-shrink: 0; }
#send-btn:hover { background: var(--primary-dark); transform: scale(1.05) translateY(-2px); box-shadow: 0 6px 15px rgba(249, 115, 22, 0.3); }
#send-btn:active { transform: scale(0.95); }

#upload-label { font-size: 20px; cursor: pointer; color: var(--secondary); transition: 0.3s; padding: 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
#upload-label:hover { background: var(--primary-light); color: var(--primary); }

.whatsapp-btn { display: inline-flex; align-items: center; justify-content: center; margin-top: 8px; background: linear-gradient(135deg, #25D366, #128C7E); color: white; padding: 8px 15px; text-decoration: none; border-radius: 18px; font-weight: 700; font-size: 13px; box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3); transition: 0.3s; max-width: calc(100% - 30px); }
.whatsapp-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4); }

#image-preview { position: absolute; bottom: 85px; left: 20px; background: white; padding: 8px; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); z-index: 100; display: flex; flex-direction: column; align-items: center; }
#preview-img { max-width: 120px; max-height: 120px; border-radius: 6px; }
.clear-img-btn { position: absolute; top: -10px; right: -10px; background: var(--danger); color: white; border: none; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(239, 68, 68, 0.4); }

.loading-msg { opacity: 0.8; }
.loading-msg::after { content: '...'; animation: dots 1.5s steps(4, end) infinite; }
@keyframes dots { 0%, 20% { color: rgba(0,0,0,0); text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0); } 40% { color: white; text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0); } 60% { text-shadow: .25em 0 0 white, .5em 0 0 rgba(0,0,0,0); } 80%, 100% { text-shadow: .25em 0 0 white, .5em 0 0 white; } }

/* Rich Link Preview Cards */
.chat-link { color: #fff; font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.chat-link:hover { color: var(--primary-light); }
.message.user .chat-link { color: var(--primary); }

.message.bot.has-product-previews { width: min(92%, 340px); max-width: 92%; }
.link-preview-carousel { margin-top: 10px; display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; align-items: center; gap: 5px; }
.link-preview-container { display: flex; flex-direction: row; gap: 10px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scroll-behavior: smooth; padding: 2px 2px 10px; -webkit-overflow-scrolling: touch; }
.link-preview-container::-webkit-scrollbar { height: 6px; }
.link-preview-container::-webkit-scrollbar-track { background: rgba(255,255,255,0.12); border-radius: 999px; }
.link-preview-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.45); border-radius: 999px; }
.link-preview-card { display: block; flex: 0 0 135px; scroll-snap-align: start; background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); border-radius: 10px; padding: 8px; text-decoration: none; color: inherit; transition: all 0.3s; box-shadow: 0 4px 10px rgba(0,0,0,0.05); backdrop-filter: blur(5px); }
.link-preview-card:hover { background: rgba(255,255,255,0.25); transform: translateY(-2px); border-color: rgba(255,255,255,0.5); box-shadow: 0 8px 15px rgba(0,0,0,0.1); }
.carousel-btn { width: 28px; height: 28px; border: 1px solid rgba(255,255,255,0.35); border-radius: 50%; background: rgba(255,255,255,0.18); color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; font-size: 12px; }
.carousel-btn:hover { background: rgba(255,255,255,0.28); transform: translateY(-1px); }
.vpc-title { font-weight: 800; font-size: 12px; margin-bottom: 4px; line-height: 1.2; color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.1); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.vpc-image { width: 100%; border-radius: 6px; margin-bottom: 6px; max-height: 95px; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 1px solid rgba(255,255,255,0.2); }
.vpc-price { color: #fef08a; font-weight: 800; font-size: 11.5px; margin-bottom: 4px; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.vpc-desc { font-size: 10.5px; opacity: 0.9; line-height: 1.3; color: #f8fafc; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

@media (max-width: 520px) {
    .message.bot.has-product-previews { width: 100%; max-width: 100%; box-sizing: border-box; }
    .link-preview-carousel { grid-template-columns: 1fr; }
    .carousel-btn { display: none; }
    .link-preview-card { flex-basis: 175px; }
}

/* ----------------------------------------------------
   Admin Dashboard Styles (Premium & Modern)
------------------------------------------------------- */
.admin-body { background-color: var(--body-bg); color: #333; }

/* Login Screen */
.login-wrapper { display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-panel) 100%); }
.login-card { background: white; padding: 40px; border-radius: 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); width: 100%; max-width: 350px; text-align: center; }
.login-header h2 { margin: 10px 0 5px; color: var(--bg-dark); }
.login-header p { margin: 0 0 25px; color: var(--text-muted); font-size: 14px; }
.auth-icon { font-size: 40px; color: var(--primary); }
.auth-group { position: relative; margin-bottom: 20px; }
.input-icon { position: absolute; right: 15px; top: 14px; color: #888; }
.auth-group input { width: calc(100% - 40px); padding: 12px 15px 12px 40px; border: 1px solid #ddd; border-radius: 8px; outline: none; font-family: inherit; transition: border 0.3s; }
.auth-group input:focus { border-color: var(--primary); }

/* Buttons */
.primary-btn { background: var(--primary); color: white; border: none; padding: 12px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.3s; width: 100%; font-family: inherit; }
.primary-btn:hover { background: var(--primary-dark); }
.accent-btn { background: var(--accent); color: white; border: none; padding: 10px 15px; border-radius: 8px; cursor: pointer; font-family: inherit; }
.accent-btn:hover { background: var(--accent-hover); }
.icon-btn { background: #eee; border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: 0.2s; }
.icon-btn:hover { background: #e0e0e0; }
.danger-btn { background: #ffeeee; color: var(--danger); border: 1px solid var(--danger); padding: 5px 10px; border-radius: 5px; cursor: pointer; }
.danger-btn:hover { background: var(--danger); color: white; }
.pulse-hover:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }

/* Dashboard Layout */
.dashboard-layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { width: 260px; background: var(--bg-dark); color: var(--text-main); display: flex; flex-direction: column; transition: 0.3s; }
.sidebar-header { padding: 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo-icon { font-size: 30px; color: var(--primary); margin-bottom: 10px; }
.sidebar-header h2 { margin: 0; font-size: 20px; }
.sidebar-nav { flex: 1; padding: 20px 0; display: flex; flex-direction: column; gap: 5px; }
.nav-btn { background: transparent; border: none; color: var(--text-muted); padding: 15px 25px; text-align: right; cursor: pointer; transition: 0.2s; font-family: inherit; font-size: 15px; display: flex; align-items: center; gap: 15px; }
.nav-btn:hover, .nav-btn.active { background: rgba(255,255,255,0.05); color: white; border-right: 4px solid var(--primary); }
.sidebar-footer { padding: 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.logout-btn { background: transparent; border: none; color: var(--danger); cursor: pointer; font-family: inherit; font-size: 15px; font-weight: bold; display: flex; gap: 10px; }

/* Main Content */
.main-content { flex: 1; overflow-y: auto; padding: 30px; background: var(--body-bg); }
.topbar { margin-bottom: 30px; padding-bottom: 15px; border-bottom: 2px solid #eaeaea; }
.topbar h1 { margin: 0; color: #2c2c2c; font-size: 24px; }

/* Cards & Layout */
.dashboard-card { background: white; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.03); margin-bottom: 25px; overflow: hidden; border: 1px solid #f0f0f0; }
.card-header { padding: 20px 25px; border-bottom: 1px solid #f0f0f0; background: #fafafa; }
.card-header h3 { margin: 0 0 5px; color: #333; font-size: 18px; }
.subtitle { margin: 0; color: #777; font-size: 13px; }
.card-body { padding: 25px; }
.card-footer { padding: 15px 25px; background: #fafafa; border-top: 1px solid #f0f0f0; display: flex; align-items: center; }

/* Forms */
.form-grid { display: grid; gap: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #444; }
.help-text { font-weight: normal; color: #888; font-size: 12px; }
.modern-input, .modern-textarea { width: 100%; box-sizing: border-box; padding: 12px 15px; border: 1px solid #ddd; border-radius: 8px; font-family: inherit; transition: 0.3s; outline: none; }
.modern-input:focus, .modern-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,123,255,0.1); }
.add-knowledge-section { display: flex; flex-direction: column; gap: 15px; }
.add-btn { width: auto; align-self: flex-start; }

/* Tables */
.table-responsive { overflow-x: auto; }
.modern-table { width: 100%; border-collapse: collapse; text-align: right; }
.modern-table th { background: #f8f9fa; padding: 12px 15px; color: #555; font-weight: 600; border-bottom: 2px solid #eee; }
.modern-table td { padding: 12px 15px; border-bottom: 1px solid #eee; color: #444; vertical-align: middle; }
.modern-table tr:hover td { background: #fdfdfd; }
.text-center { text-align: center !important; }

/* Pagination Tools */
.pagination { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 20px; }
.page-indicator { font-weight: 600; color: #555; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Toggle Switch */
.toggle-group { display: flex; align-items: center; gap: 15px; }
.toggle-text h4 { margin: 0 0 3px; }
.toggle-text p { margin: 0; font-size: 12px; color: #777; }
.toggle-switch { position: relative; display: inline-block; width: 50px; height: 26px; flex-shrink: 0;}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(24px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Utilities */
.hidden { display: none !important; }
.divider { border: 0; height: 1px; background: #eee; margin: 25px 0; }
.status-alert { margin: 15px 25px 0; padding: 12px 15px; border-radius: 8px; background: #e8f5e9; color: var(--accent-hover); border: 1px solid #c8e6c9; }

/* Animations */
.slide-up { animation: slideUp 0.4s ease forwards; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
