@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,500;0,600;1,400&display=swap');

/* Global Font Application */
* {
    font-family: 'Noto Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
}

:root {
    --blur-md: 12px;
    --bg-main: #131314;
    --bg-overlay: rgba(0, 0, 0, 0.2);
    --bg-sidebar: rgba(30, 31, 32, 0.3);
    --bg-input: #2f3033;
    --text-main: #e3e3e3;
    --text-secondary: #9aa0a6;
    --accent: #8ab4f8;
    --accent-hover: #aecbfa;
    --border-color: rgba(255, 255, 255, 0.1);
    --sidebar-width: 60px;
    --sidebar-expanded: 300px;
    --user-bubble: rgb(4 39 96 / 77%);
    --ai-bubble: rgb(20 0 38 / 71%);
    --user-border: rgba(138, 180, 248, 0.4);
    --ai-border: rgba(197, 138, 249, 0.4);
}

/* Main Wrapper - Hidden by default */
.zoi-app-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    background: var(--bg-overlay);
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.zoi-app-wrapper.active {
    transform: translateY(0);
}

/* Chat Overlay for Sidebar */
.chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Sidebar - Collapsible */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 10001;
}

.sidebar.expanded {
    width: var(--sidebar-expanded);
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.menu-toggle {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    align-self: flex-start;
    transition: background 0.2s;
    flex-shrink: 0;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.new-chat-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    align-self: flex-start;
    transition: background 0.2s;
    flex-shrink: 0;
    display: flex;
}

.new-chat-text {
    display: none;
    pointer-events: none;
    margin-left: 8px;
    transition: opacity 0.3s ease;
}

.sidebar.expanded .new-chat-text {
    display: contents;
    pointer-events: all;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

/* History Search */
.history-search {
    padding: 0;
    margin-bottom: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar.expanded .history-search {
    opacity: 1;
    pointer-events: all;
}

.history-search input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}

.history-search input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
}

.history-search input::placeholder {
    color: var(--text-secondary);
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    opacity: 0;
    pointer-events: none;
}

.sidebar.expanded .chat-history {
    opacity: 1;
    pointer-events: all;
}

.history-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.history-item.selected {
    background: rgba(138, 180, 248, 0.1);
    color: var(--accent);
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.history-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.history-item i {
    font-size: 16px;
    flex-shrink: 0;
}

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

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.nav-item span {
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}

.sidebar.expanded .nav-item span {
    opacity: 1;
    pointer-events: all;
}

/* Scrollbar Styling */
.chat-history::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.7);
}


/* Main Content */
/* New Model Dropdown Styles */
.model-dropdown {
    position: relative;
}

.model-trigger {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.model-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
}

.model-trigger i {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

/* Rotation when active */
.model-trigger.active i {
    transform: rotate(180deg);
}

.model-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    background-color: rgba(30, 31, 32, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    min-width: 220px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 10002;
    /* Above sidebar */
}

.model-menu.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.model-menu button {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 12px 14px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.model-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.model-menu button i {
    font-size: 18px;
    color: var(--accent);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 900px;
    margin: 0;
    width: 100%;
    backdrop-filter: blur(0.5px);
    -webkit-backdrop-filter: blur(0.5px);
}

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

.close-app-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-app-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}


/* Updated Welcome Screen with Glassmorphism */
.welcome-screen {
    /* Layout & Spacing */
    margin: auto;
    padding: 50px 13px;
    max-width: 600px;
    width: 57%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    text-align: center;

    /* Styling: Background, Blur, and Border */
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 32px;

    /* Updated Animation: 
       Combines fadeIn (once) with breathingHue (infinite) 
    */
    animation:
            fadeIn 2s ease-out forwards,
            breathingHue 8s ease-in-out infinite;
}

.welcome-screen h1 {
    margin: 0;
    color: var(--text-main);
    /* Specific Request: Noto Sans Regular 400 Italic */
    font-family: 'Noto Sans', sans-serif;
    font-weight: 800;
    /* Using your specific gradient */
    background: linear-gradient(11deg, #5891ee 0%, #7208cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Keyframes for the Breathing + Hue Rotation */
@keyframes breathingHue {

    0%,
    100% {
        transform: scale(1);
        filter: hue-rotate(0deg);
        box-shadow: 0 0 15px rgba(88, 145, 238, 0.1);
        border-color: rgba(255, 255, 255, 0.1);
    }

    50% {
        transform: scale(1.03);
        /* Subtle "breath" in */
        filter: hue-rotate(360deg);
        /* Full color cycle */
        /* Pulsing border glow */
        box-shadow: 0 0 30px rgba(114, 8, 204, 0.3);
        border-color: rgba(255, 255, 255, 0.3);
    }
}

/* Original Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Message Bubbles - Updated */
.message {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    animation: slideIn 0.3s ease-out;
}

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

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.message.user .message-avatar {
    background: var(--accent);
    color: #131314;
}

.message.assistant .message-avatar {
    background: transparent;
    border: 2px solid rgba(197, 138, 249, 0.6);
    color: #c58af9;
}

.message-content {
    max-width: 500px;
    padding: 14px 18px;
    color: var(--text-main);
    line-height: 1.6;
    font-size: 15px;
    border-radius: 18px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.message.user .message-content {
    background-color: var(--user-bubble);
    border: 1px solid var(--user-border);
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background-color: var(--ai-bubble);
    border: 1px solid var(--ai-border);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
    padding: 0 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background-color: var(--ai-bubble);
    border: 1px solid var(--ai-border);
    border-radius: 18px;
    max-width: 70px;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.typing-indicator.active {
    display: flex;
    align-items: center;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

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

/* File Preview */
.file-preview {
    width: 100%;
    max-width: 720px;
    margin-bottom: 12px;
    display: none;
}

.file-preview-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-preview-content img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.file-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 32px;
    color: var(--accent);
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-size {
    color: var(--text-secondary);
    font-size: 12px;
}

.file-remove {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.file-remove:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.input-wrapper {
    width: 100%;
    max-width: 720px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 24px;
    padding: 11px 6px 3px 6px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

#messageInput {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    resize: none;
    font-size: 15px;
    outline: none;
    max-height: 200px;
    min-height: 24px;
    padding: 12px 16px;
    line-height: 1.5;
    font-family: inherit;
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

#messageInput::-webkit-scrollbar {
    width: 6px;
}

#messageInput::-webkit-scrollbar-track {
    background: transparent;
}

#messageInput::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

#messageInput::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.input-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px 8px;
}

.toolbar-left {
    display: flex;
    gap: 4px;
    position: relative;
}

.tool-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.tool-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

/* Tools Dropdown Menu */
.tools-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.tools-menu.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.tools-menu button {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 10px 14px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.tools-menu button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tools-menu button i {
    font-size: 18px;
    color: var(--accent);
}

.send-btn {
    background: var(--accent);
    border: none;
    color: #131314;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
}

.send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 10001;
    }

    .sidebar.expanded {
        transform: translateX(0);
        width: 280px;
    }

    .welcome-screen h1 {
        font-size: 32px;
    }

    .chat-messages {
        padding: 24px 16px;
    }

    .input-area-container {
        padding: 12px 16px 16px;
    }

    .message-content {
        max-width: 320px;
    }
}

/* Chat toggle button */
.chat-toggle-btn {
    position: fixed;
    top: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
    width: 150px;
    height: 100px;
    margin: 0 auto;
    border: 0 solid transparent;
    border-radius: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    position: absolute;
    left: 35%;
    top: 35%;
}

.loading-circle {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #7a30d4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.message-content .related-data-button {
    display: inline-flex;
    align-items: center;
    background: rgba(138, 180, 248, 0.08);
    border: 1px solid rgba(138, 180, 248, 0.25);
    border-radius: 20px;
    padding: 5px 12px;
    margin: 4px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 0 0 0 rgba(138, 180, 248, 0);
}

.message-content .related-data-button:hover {
    background: rgba(138, 180, 248, 0.18);
    border-color: rgba(138, 180, 248, 0.6);
    box-shadow: 0 0 10px rgba(138, 180, 248, 0.2);
    transform: translateY(-1px);
}

.message-content .related-data-button:active {
    transform: translateY(0px) scale(0.97);
    background: rgba(138, 180, 248, 0.25);
}

.message-content .related-data-button .btn {
    color: var(--accent);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2px;
    line-height: 1.4;
    padding: 0;
    border: none;
    background: transparent;
    transition: color 0.2s ease;
}

.message-content .related-data-button:hover .btn {
    color: var(--accent-hover);
}


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
