/* ============================================
   ROTH AI - Main Stylesheet
   ============================================
   Design System: Neomorphic Dark Theme
   Based on Figma mockups
   ============================================ */

/* ============================================
   GOOGLE FONTS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Tienne:wght@400;700;900&family=Onest:wght@400;500;600;700&display=swap');

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
    /* Colors */
    --bg-primary: #171821;
    --bg-secondary: #1e1f2e;
    --bg-card: #545454;
    --bg-info: #242938;
    --accent: #00a7e9;
    --accent-hover: #00bfff;
    --text-primary: #ffffff;
    --text-secondary: #e5e5e5;
    --text-muted: #a0a0a0;
    --border-subtle: rgba(255, 255, 255, 0.1);

    /* Neomorphic Shadows */
    --neo-shadow-dark: rgba(0, 0, 0, 0.5);
    --neo-shadow-light: rgba(255, 255, 255, 0.05);
    --neo-outset:
        8px 8px 16px var(--neo-shadow-dark),
        -8px -8px 16px var(--neo-shadow-light);
    --neo-outset-sm:
        4px 4px 8px var(--neo-shadow-dark),
        -4px -4px 8px var(--neo-shadow-light);
    --neo-inset:
        inset 4px 4px 8px var(--neo-shadow-dark),
        inset -4px -4px 8px var(--neo-shadow-light);
    --neo-outset-accent:
        8px 8px 16px var(--neo-shadow-dark),
        -4px -4px 12px rgba(0, 167, 233, 0.15);

    /* Typography */
    --font-display: 'Tienne', serif;
    --font-body: 'Onest', sans-serif;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 10px;
    --radius-md: 15px;
    --radius-lg: 25px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* ============================================
   LAYOUT
   ============================================ */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
    height: 80px;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-logo {
    width: 50px;
    height: auto;
}

.header-title {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

/* Main Container - Desktop Split Layout */
.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chat Panel (Left Side) */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--space-xl);
    overflow: hidden;
    max-width: 50%;
}

/* Monitoring Panel (Right Side) */
.monitoring-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    padding: var(--space-xl);
    border-left: 1px solid var(--border-subtle);
    overflow-y: auto;
    max-width: 50%;
}

/* ============================================
   NEOMORPHIC CARD COMPONENTS
   ============================================ */
.neo-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--neo-outset);
    transition: box-shadow var(--transition-base);
}

.neo-card:hover {
    box-shadow: var(--neo-outset-accent);
}

.neo-card-inset {
    background: var(--bg-info);
    border-radius: var(--radius-md);
    box-shadow: var(--neo-inset);
}

/* ============================================
   WELCOME SCREEN
   ============================================ */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    gap: var(--space-lg);
}

.welcome-logo {
    width: 120px;
    height: auto;
    opacity: 0.9;
}

.welcome-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    color: var(--text-primary);
}

/* ============================================
   CHAT CONTAINER
   ============================================ */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Messages */
.message {
    display: flex;
    gap: var(--space-md);
    max-width: 90%;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.bot {
    align-self: flex-start;
    flex-direction: column;
    gap: var(--space-sm);
}

.message-bubble {
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    line-height: 1.6;
}

.message.user .message-bubble {
    background: var(--bg-card);
    border-radius: var(--radius-md) var(--radius-md) 0 var(--radius-md);
    box-shadow: var(--neo-outset-sm);
}

.message.bot .message-bubble {
    background: transparent;
    padding-left: 0;
    padding-top: 0;
}

/* Reasoning Panel (Inline for mobile) */
.message-reasoning {
    margin-bottom: var(--space-sm);
}

.reasoning-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    cursor: pointer;
    user-select: none;
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
    background: var(--bg-info);
    border-radius: var(--radius-sm);
}

.reasoning-toggle:hover {
    color: var(--accent);
}

.reasoning-toggle-icon {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-base);
}

/* Down arrow rotates when expanded */
.reasoning-toggle.collapsed .reasoning-toggle-icon {
    transform: rotate(0deg);
}

.reasoning-toggle:not(.collapsed) .reasoning-toggle-icon {
    transform: rotate(180deg);
}

.reasoning-content {
    max-height: 300px;
    overflow-y: auto;
    padding: var(--space-sm);
    margin-top: var(--space-xs);
    background: var(--bg-info);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: max-height var(--transition-base), padding var(--transition-base), opacity var(--transition-base);
}

.reasoning-toggle.collapsed+.reasoning-content {
    max-height: 0;
    padding: 0 var(--space-sm);
    opacity: 0;
    overflow: hidden;
}

/* ============================================
   INPUT AREA
   ============================================ */
.input-container {
    padding: var(--space-md) 0;
    flex-shrink: 0;
}

.input-box {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--neo-outset);
}

.input-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.125rem;
    resize: none;
    min-height: 1.5em;
    max-height: 150px;
    line-height: 1.5;
    display: flex;
    align-items: center;
}

.input-textarea::placeholder {
    color: var(--text-muted);
}

.input-button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: var(--neo-outset-sm);
    flex-shrink: 0;
}

.input-button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.input-button:active {
    transform: translateY(0);
    box-shadow: var(--neo-inset);
}

.input-button img {
    width: 20px;
    height: 20px;
}

.input-button.stop-btn {
    background: #e74c3c;
}

.input-button.stop-btn:hover {
    background: #ff5f4f;
}

/* ============================================
   MONITORING PANELS (Desktop)
   ============================================ */
.panel-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--neo-outset);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.panel-header-icon {
    width: 32px;
    height: 32px;
}

.panel-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-primary);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.panel-content::-webkit-scrollbar {
    width: 4px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Empty State */
.panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 1.25rem;
    line-height: 1.5;
}

/* Process Items */
.process-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-info);
    border-radius: var(--radius-sm);
    box-shadow: var(--neo-inset);
    animation: processItemIn 0.3s ease;
}

@keyframes processItemIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.process-item-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.process-item-text {
    font-size: 1rem;
    color: var(--text-primary);
}

.process-item-text.wrap {
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    gap: var(--space-xl);
    transition: opacity var(--transition-slow);
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.loading-progress {
    width: 300px;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: var(--neo-inset);
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 4px;
    transition: width var(--transition-base);
}

/* ============================================
   MARKDOWN STYLES
   ============================================ */
.markdown-body {
    font-family: var(--font-body);
    line-height: 1.7;
}

.markdown-body p {
    margin: var(--space-sm) 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    font-family: var(--font-display);
    margin: var(--space-md) 0 var(--space-sm) 0;
}

.markdown-body h1 {
    font-size: 1.5rem;
}

.markdown-body h2 {
    font-size: 1.25rem;
}

.markdown-body h3 {
    font-size: 1.1rem;
}

.markdown-body h4 {
    font-size: 1rem;
}

.markdown-body ul,
.markdown-body ol {
    margin: var(--space-sm) 0;
    padding-left: var(--space-lg);
}

.markdown-body li {
    margin: var(--space-xs) 0;
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    margin: var(--space-sm) 0;
    padding-left: var(--space-md);
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body code:not(.hljs) {
    background: rgba(0, 167, 233, 0.15);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
}

.markdown-body pre {
    background: var(--bg-info);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    margin: var(--space-sm) 0;
    overflow-x: auto;
    box-shadow: var(--neo-inset);
}

.markdown-body pre code {
    background: none;
    padding: 0;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Highlight.js */
.hljs {
    background: transparent !important;
    color: var(--text-primary);
}

.hljs-keyword {
    color: #c792ea;
}

.hljs-string {
    color: #c3e88d;
}

.hljs-number {
    color: #f78c6c;
}

.hljs-comment {
    color: #676e95;
    font-style: italic;
}

.hljs-function {
    color: #82aaff;
}

.hljs-class {
    color: #ffcb6b;
}

.hljs-variable {
    color: #f07178;
}

.hljs-attr {
    color: #ffcb6b;
}

.hljs-built_in {
    color: #82aaff;
}

.hljs-title {
    color: #82aaff;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: var(--space-sm);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.6;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   ONBOARDING MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity var(--transition-base);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    max-width: 500px;
    text-align: center;
    box-shadow: var(--neo-outset);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: var(--space-md);
}

.modal-text {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

.btn {
    padding: var(--space-sm) var(--space-xl);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--neo-outset-sm);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-info);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #2d3548;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    :root {
        font-size: 14px;
    }

    .app-header {
        padding: var(--space-sm) var(--space-md);
        height: 60px;
    }

    .header-logo {
        width: 36px;
    }

    .header-title {
        font-size: 1.5rem;
    }

    .app-main {
        flex-direction: column;
    }

    .chat-panel {
        max-width: 100%;
        padding: var(--space-md);
    }

    /* Hide monitoring panel on mobile */
    .monitoring-panel {
        display: none;
    }

    .message {
        max-width: 95%;
    }

    .message.user .message-bubble {
        padding: var(--space-sm) var(--space-md);
    }

    .input-box {
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-md);
    }

    .input-textarea {
        font-size: 1rem;
    }

    .input-button {
        width: 38px;
        height: 38px;
    }

    .welcome-logo {
        width: 80px;
    }

    .welcome-title {
        font-size: 1.25rem;
    }

    /* Show inline reasoning on mobile */
    .message-reasoning {
        display: block;
    }

    .modal-content {
        margin: var(--space-md);
        padding: var(--space-xl);
    }

    .modal-buttons {
        flex-direction: column;
    }
}

/* Desktop: hide inline reasoning (shown in panel) */
@media (min-width: 769px) {
    .message-reasoning.mobile-only {
        display: none;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-accent {
    color: var(--accent);
}