/* ============================
   StackLogix Chatbot — Styles
   ============================ */

:root {
    /* Color System */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-elevated: #16213e;
    --bg-glass: rgba(22, 33, 62, 0.6);
    --bg-glass-light: rgba(30, 45, 80, 0.4);

    --text-primary: #e8eaf6;
    --text-secondary: #9fa8da;
    --text-muted: #5c6bc0;
    --text-dim: #3949ab;

    --accent-primary: #7c4dff;
    --accent-secondary: #536dfe;
    --accent-glow: rgba(124, 77, 255, 0.3);
    --accent-gradient: linear-gradient(135deg, #7c4dff, #536dfe, #448aff);

    --success: #00e676;
    --warning: #ffab40;
    --error: #ff5252;

    --border-color: rgba(92, 107, 192, 0.15);
    --border-focus: rgba(124, 77, 255, 0.5);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(124, 77, 255, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================
   Reset & Base
   ============================ */

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

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ============================
   Layout
   ============================ */

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ============================
   Sidebar
   ============================ */

.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: white;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-glass);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: inherit;
}

.new-chat-btn:hover {
    background: var(--bg-glass-light);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-glow);
}

.sidebar-section {
    margin-top: 24px;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding: 0 4px;
}

.system-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-glass);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(10px);
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
}

.info-value {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-dot::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warning);
    margin-right: 6px;
    animation: pulse 2s infinite;
}

.status-dot.online::before {
    background: var(--success);
}

.status-dot.offline::before {
    background: var(--error);
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.session-id {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px !important;
    color: var(--text-dim) !important;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-prompts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prompt-chip {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-glass);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-chip:hover {
    background: var(--bg-glass-light);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    transform: translateX(4px);
}

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

.ingest-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.ingest-btn:hover {
    border-color: var(--warning);
    color: var(--warning);
}

.ingest-btn.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* ============================
   Chat Main
   ============================ */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

.chat-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 300px;
    background: radial-gradient(ellipse at 50% 0%, rgba(124, 77, 255, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.chat-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    position: relative;
    z-index: 1;
}

.chat-title h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================
   Messages
   ============================ */

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    position: relative;
    z-index: 1;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Welcome Screen */

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.6s ease;
}

.welcome-screen.hidden {
    display: none;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow-glow), 0 0 60px rgba(124, 77, 255, 0.2);
    color: white;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-8px);
    }
}

.welcome-screen h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-screen>p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 32px;
}

.welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

.suggestion-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
    text-align: left;
}

.suggestion-card:hover {
    background: var(--bg-glass-light);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.card-icon {
    font-size: 20px;
}

/* Message Bubbles */

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.message.assistant .message-avatar {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 12px rgba(124, 77, 255, 0.3);
}

.message.user .message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.message-content {
    max-width: 75%;
    min-width: 0;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.65;
    word-wrap: break-word;
}

.message.assistant .message-bubble {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
    backdrop-filter: blur(10px);
    color: var(--text-primary);
}

.message.user .message-bubble {
    background: var(--accent-gradient);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 2px 16px rgba(124, 77, 255, 0.25);
}

.message-bubble p {
    margin-bottom: 8px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin-bottom: 4px;
}

.message-bubble strong {
    color: inherit;
    font-weight: 600;
}

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

.message.user .message-time {
    text-align: right;
}

/* Follow-up Question */

.follow-up {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(124, 77, 255, 0.08);
    border: 1px solid rgba(124, 77, 255, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.follow-up:hover {
    background: rgba(124, 77, 255, 0.15);
    border-color: var(--accent-primary);
}

.follow-up-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.follow-up-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Typing Indicator */

.typing-indicator {
    display: flex;
    gap: 12px;
    animation: slideUp 0.3s ease;
}

.typing-indicator .message-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 12px rgba(124, 77, 255, 0.3);
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    border-top-left-radius: 4px;
    backdrop-filter: blur(10px);
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dotBounce 1.4s ease-in-out infinite;
}

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

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

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

@keyframes dotBounce {

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

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================
   Input Area
   ============================ */

.input-area {
    padding: 16px 32px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(20px);
    position: relative;
    z-index: 1;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 18px;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.1);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    padding: 6px 0;
}

.input-wrapper textarea::placeholder {
    color: var(--text-dim);
}

.send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 2px 8px rgba(124, 77, 255, 0.3);
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(124, 77, 255, 0.4);
}

.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    box-shadow: none;
}

.input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 8px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================
   Toast Notification
   ============================ */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: toastIn 0.3s ease;
    backdrop-filter: blur(20px);
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--error);
}

.toast.info {
    border-color: var(--accent-primary);
}

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes toastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================
   Sources
   ============================ */

.sources-container {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(0, 230, 118, 0.04);
    border: 1px solid rgba(0, 230, 118, 0.15);
    border-radius: var(--radius-sm);
    animation: fadeIn 0.3s ease;
}

.sources-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--success);
    margin-bottom: 8px;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    background: rgba(0, 230, 118, 0.04);
    border-radius: 4px;
    font-size: 11px;
    transition: background var(--transition-fast);
}

.source-item:hover {
    background: rgba(0, 230, 118, 0.08);
}

.source-file {
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.source-folder {
    color: var(--text-dim);
    font-size: 10px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-score {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    min-width: 36px;
    text-align: center;
}

.source-score.high {
    color: var(--success);
    background: rgba(0, 230, 118, 0.1);
}

.source-score.medium {
    color: var(--warning);
    background: rgba(255, 171, 64, 0.1);
}

.source-score.low {
    color: var(--text-muted);
    background: rgba(92, 107, 192, 0.1);
}

/* Streaming cursor */

.cursor-blink {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: var(--accent-primary);
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.streaming-content {
    min-height: 20px;
}

/* ============================
   Responsive
   ============================ */

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .chat-header {
        padding: 16px 20px;
    }

    .messages-container {
        padding: 16px 20px;
    }

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

    .welcome-suggestions {
        grid-template-columns: 1fr;
    }

    .message-content {
        max-width: 85%;
    }

    .source-file {
        max-width: 120px;
    }
}