
.app-shell {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/*  SIDEBAR STYLES  */
.sidebar {
    width: 280px;
    background-color:rgba(42, 42, 42);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
}

[data-theme="light"] .sidebar {
    width: 280px;
    background-color: var(--header-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
}

.sidebar.closed {
    margin-left: -280px;
}

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

.sidebar-logo-img {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.sidebar-logo-img img {
    width: 160px;
    height: auto;
    object-fit: contain;
}


.new-chat-btn {
    margin: 15px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
}

.new-chat-btn:hover {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
    background: rgba(147, 51, 234, 0.08);
}

.plus-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
}

.history-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 10px 20px 10px;
}

.history-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 15px 10px 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    opacity: 0.7;
}

.history-item {
    padding: 11px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
    opacity: 0.75;
}

.history-item:hover {
    background-color: var(--border-color);
    opacity: 1;
}

/*  MAIN CONTENT AREA  */
.chat-page-wrapper {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-color);
    transition: background-color 0.3s;
    padding: 0;
    overflow: hidden;
}

/*  TOP NAVIGATION & TOGGLES  */

.sidebar-toggle-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-toggle-btn:hover {
    color: var(--primary-purple);
    border-color: var(--primary-purple);
    background: var(--card-bg);
}

.sidebar-toggle-btn svg {
    width: 24px;
    height: 24px;
}

.chat-back-btn {
    position: absolute;
    top: 20px;
    left: 70px; /* RIGHT of menu icon */
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 100;
}

.chat-back-btn img {
    width: 20px;
    height: 20px;
}

.chat-back-btn:hover {
    border-color: var(--primary-purple);
    transform: translateX(-2px) scale(1.05);
}

/* Dark mode icon fix */
[data-theme="dark"] .chat-back-btn img {
    filter: invert(1);
}


.theme-toggle {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 99;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.theme-toggle:hover {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
    transform: rotate(15deg);
}

/* CHAT INTERFACE STYLES */

.welcome-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px 20px;
    text-align: center;
    flex-grow: 1;
}

.chat-greeting {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--primary-purple), var(--purple-lighter));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.welcome-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.messages-wrapper {
    flex-grow: 1;
    width: 100%;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    padding: 20px;
    scroll-behavior: smooth;
}

.message-container {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

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

.user-message {
    justify-content: flex-end;
    padding-right: 0;
}

.ai-message {
    justify-content: flex-start;
    align-items: flex-end;
}

.ai-message .message-content {
    background: var(--border-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px 16px 16px 16px;
    max-width: 80%;
    padding: 12px 16px;
}



.message-content {
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 0.95rem;
}


.loading-dots {
    display: flex;
    gap: 4px;
    padding: 6px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-primary);
    animation: bounce 1.4s infinite;
}

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

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/*  INPUT SECTION  */
.input-section {
    width: 100%;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.minimal-input-wrapper {
    max-width: 700px;
    width: 100%;
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.minimal-input-wrapper:hover {
    border-color: var(--primary-purple);
    box-shadow: 0 4px 16px rgba(147, 51, 234, 0.15);
}

.minimal-input-wrapper:focus-within {
    border-color: var(--primary-purple);
    box-shadow: 0 4px 20px rgba(147, 51, 234, 0.25);
}

.minimal-input-area {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 12px;
}

.chat-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    padding: 8px 0;
    font-family: inherit;
}

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

.chat-input:disabled {
    opacity: 0.6;
}

.input-action-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 6px;
    font-size: 1.1rem;
}

.input-action-btn:hover:not(:disabled) {
    color: var(--primary-purple);
    background: rgba(147, 51, 234, 0.1);
    transform: scale(1.05);
}

.input-action-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.input-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.send-btn:not(:disabled) {
    color: var(--primary-purple);
}

.input-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

/*  SCROLLBAR STYLES  */
.messages-wrapper::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
    width: 6px;
}

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

.messages-wrapper::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
    transition: background 0.2s;
}

.messages-wrapper::-webkit-scrollbar-thumb:hover,
.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-purple);
}

/*  RESPONSIVE  */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
    }

    .chat-greeting {
        font-size: 1.8rem;
    }

    .welcome-subtitle {
        font-size: 1rem;
    }

    .message-container {
        padding: 10px;
    }

    .message {
        gap: 10px;
    }

    .user-message .message-content {
        max-width: 90%;
    }

    .ai-message .message-content {
        max-width: 90%;
    }

    .input-section {
        padding: 16px;
    }

    .minimal-input-area {
        padding: 8px 12px;
    }

    .input-action-btn {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .chat-input {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .chat-greeting {
        font-size: 1.5rem;
    }

    .sidebar-toggle-btn,
    .theme-toggle {
        width: 36px;
        height: 36px;
    }

    .message-content {
        font-size: 0.9rem;
    }
}

/* voice icon */
.voice-icon-img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
    transition: filter 0.3s ease;
    filter: invert(0); /* default clr */
}

[data-theme="dark"] .voice-icon-img {
    filter: invert(1) brightness(2); /* Turns the icon white */
}


/* The scrolling area */
.messages-wrapper {
    padding: 0;
}

/* Full-width row  */
.msg-row {
    width: 100%;
    padding: 18px 14px;
}

.msg-row-ai {
    background: var(--bg-color);
}

[data-theme="light"] .msg-row-ai {
    background: var(--bg-color);
}

.msg-inner {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

/* User row aligns its inner content to the right */
.msg-row-user .msg-inner {
    justify-content: flex-end;
}

/* Message body */
.msg-body {
    line-height: 1.6;
    font-size: 0.98rem;
    white-space: pre-wrap; /* keeps line breaks */
    word-break: break-word;
}

/* User bubble */
.msg-bubble-user {
    background: var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 16px 6px 16px 16px;
    max-width: min(520px, 85%);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* no bubble */
.msg-bubble-ai {
    background: transparent;
    border: none;
    padding: 0;
    max-width: 100%;
}

/* ===== AI Avatar Image ===== */

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

[data-theme="light"] .message-avatar {
    background: rgba(0, 0, 0, 0.05);
}


.msg-row {
    animation: slideIn 0.25s ease;
}

@media (max-width: 768px) {
    .msg-inner {
        max-width: 92vw;
    }

    .msg-bubble-user {
        max-width: 90%;
    }
}

/* ---------- Markdown styling for AI messages ---------- */
.msg-bubble-ai.markdown .markdown-content {
  line-height: 1.6;
  font-size: 15px;
}

.msg-bubble-ai.markdown .markdown-content h1,
.msg-bubble-ai.markdown .markdown-content h2,
.msg-bubble-ai.markdown .markdown-content h3 {
  margin: 12px 0 8px;
  font-weight: 700;
}

.msg-bubble-ai.markdown .markdown-content p {
  margin: 8px 0;
}

.msg-bubble-ai.markdown .markdown-content ul,
.msg-bubble-ai.markdown .markdown-content ol {
  margin: 8px 0 8px 22px;
}

.msg-bubble-ai.markdown .markdown-content li {
  margin: 6px 0;
}

.msg-bubble-ai.markdown .markdown-content strong {
  font-weight: 700;
}

.msg-bubble-ai.markdown .markdown-content code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.msg-bubble-ai.markdown .markdown-content pre {
  margin: 10px 0;
  padding: 12px;
  border-radius: 14px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.06);
}

.msg-bubble-ai.markdown .markdown-content pre code {
  padding: 0;
  background: transparent;
}

.delete-chat-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-icon-img {
    width: 16px;
    height: 16px;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.delete-chat-btn:hover .delete-icon-img {
    opacity: 1;
    transform: scale(1.1);
}

.history-item .delete-chat-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.upload-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.upload-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.10);
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


