:root {
    --accent: #6366f1;
    --accent-dark: #4f46e5;
    --bg-main: #f8fafc;
    --bg-panel: rgba(255, 255, 255, 0.8);
    --bg-soft: rgba(241, 245, 249, 0.6);
    --border-soft: rgba(226, 232, 240, 0.8);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --bot-bg: #ffffff;
    --user-bg: linear-gradient(135deg, #6366f1, #818cf8);
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
    --bg-gradient: radial-gradient(circle at 0% 0%, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);

    /* Animation Speeds */
    --transition: cubic-bezier(0.4, 0, 0.2, 1) 0.4s;
}

[data-theme="dark"] {
    --accent: #818cf8;
    --accent-dark: #6366f1;
    --bg-main: #020617;
    --bg-panel: rgba(15, 23, 42, 0.7);
    --bg-soft: rgba(30, 41, 59, 0.5);
    --border-soft: rgba(51, 65, 85, 0.5);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bot-bg: rgba(30, 41, 59, 0.8);
    --user-bg: linear-gradient(135deg, #4f46e5, #6366f1);
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    --bg-gradient: radial-gradient(circle at 0% 0%, #020617 0%, #0f172a 50%, #1e293b 100%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
    height: 100vh;
    background: var(--bg-gradient);
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
    overflow: auto;
    /* Changed from hidden to allow scrolling if needed */
    transition: background 0.5s ease;
}

/* Silky Zen Background Elements */
.background-blobs {
    position: fixed;
    inset: 0;
    z-index: -2;
    filter: blur(80px);
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.4;
    transition: transform 10s ease-in-out;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #e0e7ff 0%, transparent 70%);
    top: -100px;
    left: -100px;
    animation: slowBlob 20s infinite alternate;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #fae8ff 0%, transparent 70%);
    bottom: -100px;
    right: -100px;
    animation: slowBlob 25s infinite alternate-reverse;
}

@keyframes slowBlob {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(50px, 100px) scale(1.1);
    }

    100% {
        transform: translate(-50px, 50px) scale(0.9);
    }
}

/* Main Container Transition */
#auth-container,
#chat-container {
    animation: pageReveal 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageReveal {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat container */
.chat-container {
    width: 100%;
    max-width: 900px;
    /* Wider for dashboard feel */
    height: 85vh;
    background: var(--bg-panel);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border: 1px solid var(--border-soft);
    border-radius: 32px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease-out;
    transform-style: flat;
    /* Removed preserve-3d for better interaction reliability */
}

/* Header */
.chat-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-info h2 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.header-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.role-badge {
    padding: 4px 12px;
    background: #eef2ff;
    color: #6366f1;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 100px;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.role-badge.admin {
    background: #fdf2f8;
    color: #db2777;
    border-color: rgba(219, 39, 119, 0.1);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.theme-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    margin-right: 10px;
    padding: 5px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    background: var(--bg-soft);
    color: var(--accent);
}

/* Main Viewport */
.chat-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 40px 20px 40px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
    position: relative;
    scroll-behavior: smooth;
}

.chat-viewport::-webkit-scrollbar {
    width: 6px;
}

.chat-viewport::-webkit-scrollbar-track {
    background: transparent;
}

.chat-viewport::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

/* Hero Section */
.hero-section {
    padding: 60px 0 40px 0;
    text-align: center;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 40px;
    animation: fadeInDown 1s ease-out;
}

.hero-section span {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    display: block;
    margin-bottom: 12px;
}

.hero-section h1 {
    font-size: 2.2rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text-main);
    margin-bottom: 16px;
}

.hero-section p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Category Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.category-card {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.category-card:hover {
    background: var(--bg-main);
    border-color: var(--accent);
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.15);
}

.cat-icon {
    font-size: 1.5rem;
    margin-bottom: 12px;
    display: block;
}

.category-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.category-card p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Message Area */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    margin-bottom: 8px;
    animation: messageIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes messageIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    max-width: 80%;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
}

.bot-message .message-bubble {
    background: var(--bot-bg);
    color: var(--text-main);
    border: 1px solid var(--border-soft);
    border-bottom-left-radius: 4px;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-bubble {
    background: var(--user-bg);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.15);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    background: var(--bot-bg);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 20px;
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: pulse 1s infinite alternate;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    from {
        opacity: 0.4;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Input Area */
.chat-input-area {
    padding: 24px 40px;
    background: rgba(255, 255, 255, 0.3);
    border-top: 1px solid var(--border-soft);
    display: flex;
    gap: 16px;
}

#user-input {
    flex: 1;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 14px 20px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

#user-input:focus {
    background: var(--bg-main);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

#send-button {
    width: 48px;
    height: 48px;
    background: var(--user-bg);
    border: none;
    border-radius: 14px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

#send-button:hover {
    transform: scale(1.05) rotate(5deg);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

/* Navigation & Buttons */
.icon-btn {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: var(--bg-main);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

#back-btn {
    z-index: 100;
    pointer-events: auto;
}

#logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.1);
    color: #ef4444;
    padding: 10px 18px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

#logout-btn:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.2);
}

#logout-btn svg {
    transition: transform 0.3s ease;
}

#logout-btn:hover svg {
    transform: rotate(90deg) scale(1.1);
}

/* Dashboard & Messages Sections */
.dashboard-section,
.messages-section {
    width: 100%;
    animation: contentReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes contentReveal {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Feedback Box */
.feedback-box {
    margin-top: 40px;
    padding: 24px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    transition: all 0.4s ease;
}

.feedback-box:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.feedback-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.feedback-content p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.feedback-input-row {
    display: flex;
    gap: 12px;
}

.feedback-input-row input {
    flex: 1;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-main);
    outline: none;
    transition: 0.3s ease;
}

.feedback-input-row input:focus {
    border-color: var(--accent);
    background: var(--bg-panel);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.feedback-input-row button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.feedback-input-row button:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.feedback-status {
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

/* Auth Section Refinement */
#auth-container {
    width: 100%;
    max-width: 400px;
    z-index: 10;
}

.auth-card {
    background: var(--bg-panel);
    backdrop-filter: blur(32px);
    border: 1px solid var(--border-soft);
    border-radius: 32px;
    padding: 48px 40px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-card h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: -0.5px;
}

.auth-card input,
.auth-select {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 16px 20px;
    color: var(--text-main);
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
}

.auth-card input:focus,
.auth-select:focus {
    border-color: var(--accent);
    background: var(--bg-main);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

.auth-card button {
    background: var(--user-bg);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.auth-card button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.2);
}

.toggle-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.toggle-text a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.loading-state {
    pointer-events: none;
    opacity: 0.7;
    filter: grayscale(0.5);
}

/* Layout Switch Animations */
.fade-out {
    animation: fadeOut 0.4s forwards;
}

.fade-in {
    animation: fadeIn 0.4s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .chat-container {
        height: 100vh;
        border-radius: 0;
    }

    .chat-viewport {
        padding: 0 20px 20px 20px;
    }

    .hero-section h1 {
        font-size: 1.8rem;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}