:root {
    --primary: #6D28D9;
    --secondary: #7C3AED;
    --accent: #8B5CF6;
    --light-lavender: #F5F3FF;
    --bg-color: #F8F5FF;
    --border-color: #E9D5FF;
    --hover-color: #DDD6FE;
    --text-color: #1F2937;
    --shadow-soft: 0 8px 24px rgba(109, 40, 217, 0.08);
    --shadow-medium: 0 10px 30px rgba(109, 40, 217, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.45);
    --transition: 250ms ease-in-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: radial-gradient(circle at top right, rgba(124,58,237,0.10), transparent 40%),
                radial-gradient(circle at bottom left, rgba(168,85,247,0.08), transparent 35%),
                var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

/* Hide old animated background */
.bg-animation {
    display: none;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    z-index: 10;
}

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

.sidebar-header h2 {
    font-size: 20px;
    color: var(--primary);
    margin-bottom: 15px;
}

.new-chat-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition);
    box-shadow: var(--shadow-soft);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.history-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: #6B7280;
    margin-bottom: 10px;
}

.history-list {
    list-style: none;
}

.history-item {
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    transition: background var(--transition), color var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.history-delete-btn {
    background: transparent;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
    padding: 0 4px;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    color: #EF4444;
}

.history-item:hover {
    background: #F3E8FF;
    color: var(--primary);
}

.history-item.active {
    background: #EDE9FE;
    color: var(--primary);
    font-weight: 500;
}

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

/* Dev Mode Toggle */
.dev-mode-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.dev-mode-toggle input { display: none; }
.slider {
    width: 34px; height: 18px;
    background-color: #ccc;
    border-radius: 34px;
    position: relative;
    transition: var(--transition);
    margin-right: 10px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px; width: 14px;
    left: 2px; bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition);
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(16px); }
.label-text { font-size: 14px; font-weight: 500; color: var(--text-color); }

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    /* Glassmorphism Effect for chat container */
    backdrop-filter: blur(14px);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

.chat-header {
    height: 60px;
    background: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    margin-right: 15px;
    transition: color var(--transition);
}
.mobile-menu-btn:hover {
    color: var(--primary);
}

.header-info h1 { font-size: 18px; color: var(--text-color); }
.header-info .subtitle { font-size: 12px; color: #6B7280; }

.status-indicator {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: #10B981;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dot { width: 8px; height: 8px; background: #10B981; border-radius: 50%; animation: pulse 2s infinite; }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Info Panel (Dev Mode) */
.info-panel {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    background: var(--light-lavender);
    border-bottom: 1px solid var(--border-color);
}
.info-panel .card {
    background: white;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 12px;
    box-shadow: var(--shadow-soft);
    text-align: center;
    transition: transform var(--transition);
}
.info-panel .card:hover {
    transform: translateY(-2px);
}
.info-panel .card h3 { color: #6B7280; font-size: 10px; text-transform: uppercase; margin-bottom: 4px; }
.info-panel .card p { color: var(--primary); font-weight: 600; }

/* Chat Box */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.welcome-screen {
    text-align: center;
    margin: auto;
    max-width: 600px;
    animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.welcome-screen h2 { font-size: 28px; margin-bottom: 10px; color: var(--text-color); }
.welcome-screen p { color: #6B7280; margin-bottom: 30px; }

.suggested-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.prompt-chip {
    background: white;
    border: 1px solid var(--border-color);
    padding: 12px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    box-shadow: var(--shadow-soft);
    transition: all var(--transition);
}

.prompt-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Messages */
.message {
    max-width: 80%;
    margin-bottom: 24px;
    padding: 16px 20px;
    line-height: 1.6;
    font-size: 15px;
    animation: slideUp 0.3s ease-out;
    position: relative;
    word-wrap: break-word;
    transition: all var(--transition);
}

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

.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
}

.bot {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

/* Markdown Styling inside Bot */
.bot h1, .bot h2, .bot h3 { margin-bottom: 10px; margin-top: 15px; color: var(--primary); }
.bot h1:first-child, .bot h2:first-child, .bot h3:first-child { margin-top: 0; }
.bot p { margin-bottom: 10px; }
.bot p:last-child { margin-bottom: 0; }
.bot ul, .bot ol { margin-left: 20px; margin-bottom: 10px; }
.bot table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.bot th, .bot td { border: 1px solid var(--border-color); padding: 8px; text-align: left; }
.bot th { background-color: var(--light-lavender); color: var(--primary); }
.bot code { background: var(--light-lavender); color: var(--primary); padding: 2px 5px; border-radius: 4px; font-family: monospace; }
.bot pre code { display: block; padding: 10px; overflow-x: auto; color: var(--text-color); }

/* Custom UI Cards */
.restaurant-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    box-shadow: var(--shadow-soft);
    transition: all var(--transition);
}
.restaurant-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}
.restaurant-card h4 { color: var(--primary); margin-bottom: 5px; font-size: 16px; }
.restaurant-card .meta { font-size: 13px; color: #6B7280; margin-bottom: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.restaurant-card .actions { display: flex; gap: 10px; }
.restaurant-card .btn {
    padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all var(--transition);
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-medium); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--light-lavender); }

/* Loader */
.typing-loader {
    display: flex; gap: 5px; align-items: center; height: 20px;
}
.typing-loader span {
    width: 6px; height: 6px; background: var(--primary); border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-loader span:nth-child(1) { animation-delay: -0.32s; }
.typing-loader span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Input Area */
.input-wrapper {
    padding: 20px;
    background: transparent;
}
.input-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    background: white;
    border-radius: 30px;
    padding: 8px 8px 8px 20px;
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
    align-items: center;
    transition: all var(--transition);
}
.input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 10px 40px rgba(109, 40, 217, 0.15);
}
.input-container input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
    color: var(--text-color);
}
.input-container input::placeholder {
    color: #9CA3AF;
}

.send-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; transition: all var(--transition);
}
.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-medium);
}
.send-btn:disabled {
    background: #ccc; cursor: not-allowed; transform: none; box-shadow: none;
}

/* Mic Button */
.mic-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: white;
    color: var(--primary);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

.mic-btn:hover {
    background: var(--light-lavender);
    transform: scale(1.05);
}

.mic-btn.listening {
    background: var(--primary);
    color: white;
    animation: micPulse 1.5s infinite;
    box-shadow: 0 0 15px rgba(109, 40, 217, 0.4);
}

@keyframes micPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(109, 40, 217, 0.5); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(109, 40, 217, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(109, 40, 217, 0); }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -260px;
        height: 100%;
    }
    .sidebar.open { left: 0; }
    .mobile-menu-btn { display: block; }
    .message { max-width: 90%; }
}

/* Auth Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition);
}
.modal-overlay.open {
    opacity: 1; pointer-events: all;
}
.modal-content {
    background: white; padding: 30px; border-radius: 16px;
    width: 90%; max-width: 400px; position: relative;
    box-shadow: var(--shadow-medium);
    transform: translateY(20px); transition: transform var(--transition);
}
.modal-overlay.open .modal-content {
    transform: translateY(0);
}
.modal-close {
    position: absolute; top: 15px; right: 20px;
    background: none; border: none; font-size: 24px; cursor: pointer; color: #6B7280;
}
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 14px; font-weight: 500; }
.form-group input { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 14px; }
.form-group input:focus { outline: none; border-color: var(--primary); }
.form-error { color: #EF4444; font-size: 13px; margin-bottom: 10px; text-align: center; }

/* Header Auth */
.header-auth {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.profile-badge {
    display: flex; align-items: center; gap: 8px;
    background: var(--light-lavender);
    padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border-color);
}
.profile-role {
    font-size: 12px; font-weight: 600; color: var(--primary);
}
