/* MOLUSKA AI - Shell & Pearl Theme */
:root {
    --bg-color: #0c0f0a;
    --sidebar-bg: #141712;
    --chat-bg: #0c0f0a;
    --input-bg: #1f241a;

    --text-primary: #fcfdec;
    --text-secondary: #a3b899;

    /* Moluska Palette (Shell/Pearl Theme) */
    --accent-color: #E0CDA9;
    /* Pearl/Sand */
    --accent-glow: #F5DEB3;
    /* Wheat Glow */
    --highlight: #FF7F50;
    /* Coral Accent */

    --user-msg-bg: #E6D5B8;
    /* Warm Shell */
    --user-text: #2c1810;
    /* Dark Brown for contrast */

    --ai-msg-bg: #1f241a;

    --border-color: #2d3626;
    --glass-bg: rgba(20, 23, 18, 0.8);
    --glass-border: rgba(224, 205, 169, 0.2);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-glow: 0 0 15px rgba(224, 205, 169, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(250, 204, 21, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(132, 204, 22, 0.05) 0%, transparent 20%);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(234, 179, 8, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(234, 179, 8, 0.5);
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    /* For absolute positioning of close button if needed, though current logic uses flex */
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Playfair Display', serif;
    /* Elegant font */
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--accent-glow);
    text-shadow: 0 0 15px rgba(224, 205, 169, 0.4);
    letter-spacing: 0.5px;
    user-select: none;
    /* Prevent text selection */
    cursor: default;
    /* Arrow cursor instead of text cursor */
}

.logo-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
}

.logo i {
    color: var(--accent-glow);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

.new-chat-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--accent-color), var(--highlight));
    border: none;
    border-radius: 0.75rem;
    color: black;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.4);
}

.history-container {
    flex: 1;
    overflow-y: auto;
    margin-top: 1rem;
}

.history-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-item {
    width: 100%;
    /* Ensure it spans width like a div */
    border: none;
    /* Reset button border */
    background: transparent;
    /* Reset button background */
    text-align: left;
    /* Reset button text align */
    font-family: inherit;
    /* Reset font */
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    outline: none;
    /* Remove focus outline */
    user-select: none;
    /* Prevent text selection */
    -webkit-tap-highlight-color: transparent;
    /* Remove highlight on mobile tap */
}

.history-item:focus,
.history-item:active {
    outline: none;
    box-shadow: none;
}

.history-item:hover {
    background-color: var(--input-bg);
    color: var(--text-primary);
}

.history-item.active {
    background-color: rgba(234, 179, 8, 0.1);
    color: var(--accent-glow);
    /* Removed border-left as per user request */
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: auto;
}

.twitter-btn {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    text-decoration: none;
}

.twitter-btn:hover {
    color: #1DA1F2;
    /* Twitter Blue */
    background-color: rgba(29, 161, 242, 0.1);
}



/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--chat-bg);
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(12, 15, 10, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.model-selector-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    position: relative;
    transition: all 0.2s;
    user-select: none;
    /* Prevent text selection */
}

.model-selector-container:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.1);
}

.model-select {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding-right: 1.5rem;
    /* Space for arrow usually, but we keep it simple */
    outline: none;
    text-align: center;
}

.model-select option {
    background-color: var(--bg-color);
    color: var(--text-primary);
    padding: 10px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--highlight);
    box-shadow: 0 0 5px var(--highlight);
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(234, 179, 8, 0.03) 0%, transparent 50%);
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message .message-content {
    background-color: transparent;
    /* Removed border-left as per user request */
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--accent-color), #ca8a04);
    color: var(--user-text);
    border-radius: 1rem 1rem 0 1rem;
    padding: 0.75rem 1.25rem;
    max-width: 85%;
    box-shadow: 0 2px 10px rgba(234, 179, 8, 0.2);
    font-weight: 500;
}

.message-content {
    line-height: 1.7;
    font-size: 1rem;
}

.message-content strong {
    color: var(--accent-glow);
}

/* Override strong color for user message to black/dark */
.user-message .message-content strong {
    color: #000;
}

.message-content p {
    margin-bottom: 0.75rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content img {
    max-width: 100%;
    border-radius: 0.75rem;
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
}

/* Code Blocks */
pre {
    background-color: #000;
    padding: 1rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    border: 1px solid var(--border-color);
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    color: #e2e8f0;
}

/* Input Area */
.input-area {
    padding: 1rem 2rem 2rem;
    background: linear-gradient(to top, var(--bg-color) 80%, transparent);
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.input-container {
    position: relative;
    background-color: var(--input-bg);
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    /* Tighter padding */
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.input-container:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 4px 25px rgba(234, 179, 8, 0.15);
    background-color: #272c20;
}

.attach-btn,
.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.attach-btn {
    background: transparent;
    color: var(--text-secondary);
}

.attach-btn:hover {
    color: var(--accent-glow);
    background-color: rgba(255, 255, 255, 0.05);
}

.send-btn {
    background-color: var(--accent-color);
    color: black;
}

.send-btn:hover {
    background-color: var(--highlight);
    transform: scale(1.05);
}

.send-btn:disabled {
    background-color: var(--input-bg);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    padding: 0.75rem 0.5rem;
    outline: none;
}

.footer-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
}

/* File Preview */
.file-preview-area {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
    overflow-x: auto;
}

.preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 2px solid var(--accent-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-file {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom-left-radius: 5px;
}

/* Mobile Responsive */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
}

.mobile-close-btn {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        max-width: 320px;
        height: 100%;
        background-color: var(--sidebar-bg);
        /* Ensure dark bg */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        z-index: 1001;
        /* Higher than overlay */
        transform: translateX(-100%);
        /* Start off-screen */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        /* Smoother slide */
    }

    .sidebar.active {
        transform: translateX(0);
        /* Slide in to 0 */
        left: 0;
        /* Reinforce */
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .mobile-menu-btn {
        display: block;
    }

    .mobile-close-btn {
        display: block;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 1.25rem;
        cursor: pointer;
        padding: 0.5rem;
        position: absolute;
        right: 0.5rem;
        top: 0.5rem;
    }

    /* Hide New Chat text on mobile to save space if needed, or adjust layout */
    .new-chat-btn {
        margin-left: auto;
        margin-right: 2.5rem;
        /* Make room for close button */
    }

    .input-area {
        padding: 1rem;
    }

    .messages-container {
        padding: 1rem;
    }
}

/* Status Indicator */
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ccc;
    display: inline-block;
    transition: all 0.3s ease;
    cursor: help;
}

.status-indicator.online {
    background-color: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.status-indicator.offline {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}