/* Styles for Raiku AI documentation assistant SPA */

:root {
    --bg-color: #000204;
    --text-color: #FDFDFF;
    --accent-color: #C0FF38;
    --accent-color-hover: #ade432;
    --accent-color-transparent: rgba(192, 255, 56, 0.1);
    --border-color: rgba(253, 253, 255, 0.1);
    --sidebar-bg: #000204;
    --panel-bg: #04080D;
    --user-bubble-bg: #050B13;
    --ai-bubble-bg: #03070A;
    --sidebar-width: 250px;
    --sources-width: 300px;
    --header-height: 60px;
    --input-height: 80px;
    --border-radius: 12px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100%; /* Core height fix */
    width: 100%;
    overflow: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand-name, .welcome-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Scrollbar styling */
.scroll-custom::-webkit-scrollbar {
    width: 6px;
}

.scroll-custom::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-custom::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.scroll-custom::-webkit-scrollbar-thumb:hover {
    background: rgba(253, 253, 255, 0.2);
}

/* Layout container */
.app-container {
    display: flex;
    height: 100%;
    background: var(--bg-color);
    width: 100vw;
    overflow: hidden;
}

/* Sidebar styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 24px 16px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    color: #000;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.new-chat-btn:hover {
    background: var(--accent-color-hover);
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--accent-color-transparent);
}

.sidebar-nav {
    flex-grow: 1;
    padding: 16px;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(253, 253, 255, 0.7);
    transition: var(--transition);
}

.sidebar-nav li:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.sidebar-nav li.active {
    background: var(--accent-color-transparent);
    color: var(--accent-color);
}

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

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

.mini-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.brand-info {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 14px;
    font-weight: 600;
}

.status-indicator {
    font-size: 11px;
    color: rgba(253, 253, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Pulse animation for status dot */
.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.dot.pulse {
    background-color: var(--accent-color);
    box-shadow: 0 0 0 rgba(192, 255, 56, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(192, 255, 56, 1); }
    70% { box-shadow: 0 0 0 6px rgba(192, 255, 56, 0); }
    100% { box-shadow: 0 0 0 0 rgba(192, 255, 56, 0); }
}

.dot.green {
    background-color: var(--accent-color);
}

/* Main content and views */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%; /* Force fill */
}

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

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

.header-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.header-title {
    font-size: 18px;
    margin: 0;
}

.docs-status {
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(192, 255, 56, 0.05);
    border: 1px solid var(--accent-color-transparent);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(192, 255, 56, 0.8);
    font-weight: 500;
}

.header-right button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-left: 8px;
    transition: var(--transition);
}

.header-right button:hover {
    background: var(--border-color);
    border-color: rgba(253, 253, 255, 0.3);
}

.view-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for nested flex scrolling */
    position: relative;
}

.view {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}

.view.active {
    display: flex;
}
/* Removed absolute positioning to improve layout stability on mobile */

/* Chat View */
.messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 40px 15%; /* Default for desktop */
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex-grow: 1;
    text-align: center;
    padding: 20px 0;
}

.welcome-logo-wrapper {
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 20px rgba(192, 255, 56, 0.2));
}

.welcome-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-title {
    font-size: 42px;
    margin: 0;
    letter-spacing: -0.5px;
}

.welcome-subtitle {
    font-size: 18px;
    color: var(--accent-color);
    margin: 8px 0 24px;
    font-weight: 500;
}

.welcome-description {
    max-width: 600px;
    color: rgba(253, 253, 255, 0.6);
    margin-bottom: 40px;
    line-height: 1.6;
}

.suggested-prompts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 800px;
}

.prompt-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    display: flex;
    align-items: center;
}

.prompt-card:hover {
    border-color: var(--accent-color);
    background: rgba(192, 255, 56, 0.05);
    transform: translateY(-4px);
}

/* Input area */
.input-container {
    padding: 20px 15%;
    background: linear-gradient(to top, var(--bg-color) 80%, transparent);
    width: 100%;
}

.input-wrapper {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: rgba(192, 255, 56, 0.5);
    box-shadow: 0 0 15px rgba(192, 255, 56, 0.05);
}

#chat-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 16px; /* 16px prevents automatic zoom on iOS */
    padding: 8px 0;
    resize: none;
    outline: none;
    max-height: 200px;
}

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

.send-icon {
    width: 24px;
    height: 24px;
    fill: var(--accent-color);
    opacity: 0.5;
    transition: var(--transition);
}

.send-btn:not(:disabled) .send-icon {
    opacity: 1;
}

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

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeInUp 0.4s ease-out;
}

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

.message.user {
    align-self: flex-end;
}

.message.ai {
    align-self: flex-start;
}

.message-bubble {
    padding: 16px 20px;
    border-radius: 16px;
    font-size: 15px;
}

.user .message-bubble {
    background: var(--user-bubble-bg);
    border: 1px solid rgba(192, 255, 56, 0.2);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.ai .message-bubble {
    background: var(--ai-bubble-bg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    position: relative;
}

.ai .message-bubble code {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
}

.ai .message-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.message-meta {
    margin-top: 8px;
    font-size: 11px;
    color: rgba(253, 253, 255, 0.4);
    display: flex;
    gap: 12px;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: rgba(253, 253, 255, 0.5);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--border-color);
    color: var(--text-color);
}

/* Source inline block */
.sources-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.sources-label {
    font-size: 11px;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 8px;
    display: block;
}

.source-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.source-badge {
    font-size: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.source-badge:hover {
    border-color: var(--accent-color);
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.typing span {
    width: 6px;
    height: 6px;
    background: var(--accent-color);
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1.4s infinite;
}

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

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* Right Sources Panel */
.sources-panel {
    width: var(--sources-width);
    background: var(--panel-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
}

.sources-panel.collapsed {
    width: 0;
    overflow: hidden;
    border-left: none;
}

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

.panel-header h3 {
    margin: 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.close-panel {
    background: transparent;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 18px;
    opacity: 0.5;
}

.sources-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
}

.source-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.source-card:hover {
    border-color: rgba(192, 255, 56, 0.3);
    background: rgba(255, 255, 255, 0.04);
}

.source-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.source-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
}

.source-score {
    font-size: 10px;
    color: var(--accent-color);
    background: var(--accent-color-transparent);
    padding: 2px 6px;
    border-radius: 4px;
}

.source-path {
    font-size: 11px;
    color: rgba(253, 253, 255, 0.4);
    font-family: 'Roboto Mono', monospace;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-excerpt {
    font-size: 12px;
    color: rgba(253, 253, 255, 0.6);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.use-as-context-btn {
    margin-top: 10px;
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.use-as-context-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Views specific styling */
.empty-search, .no-sources, .no-selection {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(253, 253, 255, 0.3);
    font-size: 14px;
    text-align: center;
    padding: 40px;
}

/* Mobile responsive adjustments */
@media (max-width: 1024px) {
    .messages-container, .input-container {
        padding-left: 10%;
        padding-right: 10%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        background: var(--bg-color);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .main-content {
        width: 100%;
    }
    
    .messages-container {
        padding: 20px 16px 40px;
    }
    
    .input-container {
        padding: 12px 16px;
        padding-bottom: max(24px, env(safe-area-inset-bottom)); /* Account for iPhone home bar */
        background: var(--bg-color);
        position: relative;
        z-index: 10;
        border-top: 1px solid var(--border-color);
    }

    .welcome-title {
        font-size: 32px;
    }

    .welcome-logo-wrapper {
        width: 80px;
        height: 80px;
    }

    .message {
        max-width: 90%;
    }

    .mobile-toggle {
        display: block !important;
        font-size: 24px;
        cursor: pointer;
        padding: 8px;
        margin-left: -8px;
    }
    
    .docs-status {
        display: none;
    }

    .suggested-prompts {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0 16px;
    }

    .header {
        padding: 0 16px;
    }

    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        z-index: 900;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
}

.mobile-toggle {
    display: none;
}
