:root {
    --bg-dark: #0a0a0c;
    --sidebar-bg: rgba(18, 18, 22, 0.8);
    --accent: #7c4dff;
    --accent-glow: rgba(124, 77, 255, 0.4);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --user-msg: #2d2d3a;
    --bot-msg: rgba(124, 77, 255, 0.15);
    --success: #00e676;
    --error: #ff5252;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

h1,
h2,
.logo h1 {
    font-family: 'Outfit', sans-serif;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    height: 100%;
    min-height: 0;
}

/* Sidebar Header - Reverted */
.sidebar-header {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    background: var(--glass-bg);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.logo h1,
.logo-3d {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #7c4dff, #00e5ff, #7c4dff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(124, 77, 255, 0.5);
    animation: gradientShift 3s ease infinite, float3d 4s ease-in-out infinite;
    transform-style: preserve-3d;
    perspective: 500px;
    line-height: 1.2;
}

.logo-3d .subtitle {
    display: block;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 6px;
    background: linear-gradient(135deg, #00e5ff, #7c4dff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease infinite reverse;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes float3d {

    0%,
    100% {
        transform: translateY(0) rotateX(0deg);
        filter: drop-shadow(0 4px 6px rgba(124, 77, 255, 0.3));
    }

    25% {
        transform: translateY(-3px) rotateX(2deg);
        filter: drop-shadow(0 8px 12px rgba(124, 77, 255, 0.4));
    }

    50% {
        transform: translateY(-5px) rotateX(0deg);
        filter: drop-shadow(0 12px 20px rgba(124, 77, 255, 0.5));
    }

    75% {
        transform: translateY(-3px) rotateX(-2deg);
        filter: drop-shadow(0 8px 12px rgba(124, 77, 255, 0.4));
    }
}



.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.quick-action-btn {
    background: rgba(124, 77, 255, 0.1);
    color: white;
    border: 1px solid rgba(124, 77, 255, 0.3);
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.quick-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent);
    transition: 0.5s;
}

.quick-action-btn:hover {
    transform: translateX(5px) scale(1.02);
    background: rgba(124, 77, 255, 0.25);
    border-color: var(--accent);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.quick-action-btn:hover::before {
    left: 100%;
}

.quick-action-btn:active {
    transform: scale(0.98);
}


.tools-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.tool-server-section {
    margin-bottom: 8px;
}

.tool-server-header {
    font-size: 12px;
    color: var(--accent);
    letter-spacing: 0.5px;
    font-weight: 700;
    padding: 10px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.tool-server-header:hover {
    background: rgba(124, 77, 255, 0.15);
    border-color: var(--accent);
}

.tool-server-header.collapsed {
    opacity: 0.8;
}

.tool-count {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 400;
}

.expand-icon {
    font-size: 10px;
    color: var(--text-secondary);
    margin-left: auto;
    padding-left: 8px;
}

.tools-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 8px;
    padding-top: 6px;
    border-left: 2px solid var(--glass-border);
    margin-left: 12px;
    margin-top: 4px;
}

.tools-container.hidden {
    display: none;
}


.tool-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.tool-item:hover {
    border-color: var(--accent);
    background: rgba(124, 77, 255, 0.1);
}

.tool-name {
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-server {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* Main Chat Styling */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top right, rgba(124, 77, 255, 0.05), transparent);
    position: relative;
}

.chat-header {
    height: 64px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 40px;
    /* New 3D Gradient Animation */
    background: linear-gradient(270deg, rgba(124, 77, 255, 0.1), rgba(0, 229, 255, 0.1), rgba(124, 77, 255, 0.1));
    background-size: 200% 200%;
    animation: headerGradient 4s ease infinite;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

@keyframes headerGradient {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.model-badge {
    background: var(--accent);
    color: white;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    box-shadow: 0 0 15px var(--accent-glow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(124, 77, 255, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(124, 77, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(124, 77, 255, 0);
    }
}


.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.message {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 20px;
    line-height: 1.5;
    font-size: 15px;
    position: relative;
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.assistant-message {
    background: var(--bot-msg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(124, 77, 255, 0.2);
}

.user-message {
    background: var(--user-msg);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border: 1px solid var(--glass-border);
}

.message-content h3 {
    margin-bottom: 10px;
}

.message-content p {
    margin-bottom: 15px;
}

.message-content ul,
.message-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 15px;
    border: 1px solid var(--glass-border);
}

.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 10px 0;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.message-content img:hover {
    transform: scale(1.02);
}

/* Input Area */
.input-area {
    padding: 20px 40px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-container {
    width: 100%;
    max-width: 800px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s;
    gap: 10px;
}

.tool-selector-container {
    width: 100%;
    position: relative;
    z-index: 100;
}

.input-row {
    display: flex;
    align-items: flex-end;
    width: 100%;
}

.tool-dropdown {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 10px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    -webkit-appearance: menulist;
    appearance: menulist;
    pointer-events: auto;
}

.tool-dropdown:hover,
.tool-dropdown:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tool-dropdown option {
    background: var(--bg-dark);
    color: var(--text-primary);
    padding: 10px;
}

.input-container:focus-within {
    border-color: var(--accent);
}

textarea {
    flex: 1;
    background: none;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    padding: 8px 0;
    max-height: 200px;
    outline: none;
}

.send-button {
    background: var(--accent);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin-left: 12px;
}

.send-button:hover {
    background: #6a3de8;
    transform: scale(1.05);
}

.send-button svg {
    width: 20px;
    height: 20px;
}

.mic-button {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 8px;
}

.mic-button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.mic-button.recording {
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
    border-color: #ff4444;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
    }
}

.mic-button svg {
    width: 20px;
    height: 20px;
}

.disclaimer {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 12px;
}

/* Background Blurs */
.bg-blur {
    position: fixed;
    width: 40vw;
    height: 40vw;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 1;
    opacity: 0.15;
    pointer-events: none;
}

.blur-1 {
    top: -10%;
    right: -10%;
    background: var(--accent);
}

.blur-2 {
    bottom: -10%;
    left: -10%;
    background: #00bcd4;
}

/* Thinking Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 10px;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1.0);
    }
}

/* Scrollbar - High Visibility */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 6px;
    border: 3px solid transparent;
    background-clip: padding-box;
    opacity: 1;
}

::-webkit-scrollbar-thumb:hover {
    background: #6a3de8;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: var(--bg-dark);
    min-width: 0;
    /* Prevent flex overflow */
}

/* History List Styling */
.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.session-item {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.session-item.active {
    background: rgba(124, 77, 255, 0.15);
    border-color: var(--accent);
    color: var(--text-primary);
}

.session-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-date {
    font-size: 11px;
    opacity: 0.6;
}

/* ============ VOICE MODE BUTTON ============ */
.voice-mode-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.2), rgba(0, 229, 255, 0.15));
    border: 1px solid rgba(124, 77, 255, 0.4);
    border-radius: 25px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
}

.voice-mode-button:hover {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.35), rgba(0, 229, 255, 0.25));
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 77, 255, 0.3);
}

.voice-mode-button:active {
    transform: translateY(0) scale(0.98);
}

.voice-mode-button.active {
    background: linear-gradient(135deg, rgba(0, 230, 118, 0.25), rgba(0, 229, 255, 0.2));
    border-color: #00e676;
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.3);
}

.voice-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.voice-icon svg {
    width: 20px;
    height: 20px;
    stroke: #00e5ff;
    transition: stroke 0.3s;
}

.voice-mode-button:hover .voice-icon svg {
    stroke: #7c4dff;
}

.voice-mode-button.active .voice-icon svg {
    stroke: #00e676;
    animation: voicePulseIcon 1s infinite;
}

.voice-text {
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #7c4dff, #00e5ff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: all 0.3s;
}

.voice-mode-button:hover .voice-text {
    background: linear-gradient(135deg, #00e5ff, #7c4dff);
    -webkit-background-clip: text;
    background-clip: text;
}

.voice-mode-button.active .voice-text {
    background: linear-gradient(135deg, #00e676, #00e5ff);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Animated pulse ring behind button */
.voice-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 25px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
}

.voice-mode-button.active .voice-pulse {
    animation: voiceRingPulse 1.5s infinite;
}

@keyframes voiceRingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.4);
        opacity: 1;
    }

    70% {
        box-shadow: 0 0 0 15px rgba(0, 230, 118, 0);
        opacity: 0;
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 230, 118, 0);
        opacity: 0;
    }
}

@keyframes voicePulseIcon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* Voice button shimmer effect */
.voice-mode-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: 0.5s;
}

.voice-mode-button:hover::before {
    left: 100%;
}

/* Mobile adjustments - ONLY for voice button positioning, no size changes */
@media (max-width: 768px) {
    .chat-header {
        padding: 0 15px;
        justify-content: flex-start;
    }

    .voice-mode-button {
        padding: 8px 14px;
    }

    .voice-text {
        font-size: 12px;
    }

    .voice-icon {
        width: 20px;
        height: 20px;
    }

    .voice-icon svg {
        width: 16px;
        height: 16px;
    }
}