/* ============================================
   Chat NirMind - Design System & Styles
   ============================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Colors */
    --bg-primary: #0a0a14;
    --bg-secondary: #0f0f1e;
    --bg-tertiary: #161628;
    --bg-input: rgba(22, 22, 40, 0.85);
    --bg-input-border: rgba(120, 80, 200, 0.25);
    --bg-input-border-focus: rgba(150, 100, 255, 0.5);

    --text-primary: #e8e8f0;
    --text-secondary: #9090a8;
    --text-muted: #5a5a72;
    --text-hint: #6a6a82;

    --accent-purple: #8b5cf6;
    --accent-purple-light: #a78bfa;
    --accent-purple-dark: #6d28d9;
    --accent-violet: #7c3aed;
    --accent-pink: #c084fc;
    --accent-magenta: #9333ea;

    --orb-core: #a855f7;
    --orb-glow-inner: rgba(168, 85, 247, 0.6);
    --orb-glow-outer: rgba(124, 58, 237, 0.15);

    --pill-bg: rgba(30, 30, 52, 0.8);
    --pill-border: rgba(120, 80, 200, 0.2);
    --pill-hover-bg: rgba(45, 45, 72, 0.9);
    --pill-hover-border: rgba(150, 100, 255, 0.4);

    --btn-bg: rgba(25, 25, 45, 0.8);
    --btn-border: rgba(100, 70, 180, 0.3);
    --btn-hover-bg: rgba(40, 40, 65, 0.9);

    --mic-bg: rgba(80, 70, 110, 0.6);
    --mic-hover-bg: rgba(120, 80, 200, 0.7);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.9375rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 1.75rem;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Borders */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Shadows */
    --shadow-glow: 0 0 60px rgba(139, 92, 246, 0.15);
    --shadow-input: 0 4px 30px rgba(0, 0, 0, 0.3), 0 0 40px rgba(139, 92, 246, 0.08);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    outline: none;
}

textarea {
    font-family: inherit;
    border: none;
    outline: none;
    resize: none;
}

/* --- Background Effects --- */
.bg-effects {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    will-change: transform;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.35) 0%, rgba(124, 58, 237, 0.08) 70%, transparent 100%);
    top: 15%;
    left: 35%;
    animation: blobFloat1 20s ease-in-out infinite;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(192, 132, 252, 0.2) 0%, rgba(147, 51, 234, 0.05) 70%, transparent 100%);
    bottom: 10%;
    right: 10%;
    animation: blobFloat2 25s ease-in-out infinite;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(109, 40, 217, 0.25) 0%, rgba(88, 28, 135, 0.05) 70%, transparent 100%);
    top: 50%;
    left: -5%;
    animation: blobFloat3 18s ease-in-out infinite;
}

@keyframes blobFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(40px, 30px) scale(1.08); }
}

@keyframes blobFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-40px, -30px) scale(1.1); }
    66% { transform: translate(30px, 40px) scale(0.92); }
}

@keyframes blobFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(50px, -20px) scale(1.15); }
}

/* --- App Container --- */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    overflow: hidden;
}

/* --- Header --- */
.header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    flex-shrink: 0;
}

.header-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
    font-weight: 400;
}

.header-right {
    display: flex;
    gap: var(--space-sm);
}

.header-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 16px;
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
}

.header-btn:hover {
    background: var(--btn-hover-bg);
    color: var(--text-primary);
    border-color: rgba(150, 100, 255, 0.4);
    transform: translateY(-1px);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Chat Area --- */
.chat-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 0 var(--space-xl);
    position: relative;
}

/* --- Orb Animation --- */
.orb-container {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.orb-container.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    position: absolute;
}

.orb {
    position: relative;
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-core {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%,
        rgba(200, 160, 255, 0.9) 0%,
        rgba(168, 85, 247, 0.8) 25%,
        rgba(124, 58, 237, 0.7) 50%,
        rgba(88, 28, 135, 0.6) 75%,
        rgba(59, 7, 100, 0.4) 100%
    );
    box-shadow:
        0 0 30px rgba(168, 85, 247, 0.5),
        0 0 60px rgba(139, 92, 246, 0.3),
        0 0 100px rgba(124, 58, 237, 0.15),
        inset 0 0 30px rgba(200, 160, 255, 0.2);
    animation: orbPulse 4s ease-in-out infinite;
}

.orb-glow {
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(168, 85, 247, 0.25) 0%,
        rgba(139, 92, 246, 0.1) 40%,
        transparent 70%
    );
    animation: orbGlow 4s ease-in-out infinite;
    animation-delay: 0.5s;
}

.orb-ring {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 1px solid rgba(168, 85, 247, 0.15);
    animation: orbRing 6s linear infinite;
}

.orb-particles span {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(192, 132, 252, 0.6);
    animation: orbParticle 5s ease-in-out infinite;
}

.orb-particles span:nth-child(1) { top: 10%; left: 50%; animation-delay: 0s; }
.orb-particles span:nth-child(2) { top: 30%; right: 5%; animation-delay: 0.8s; }
.orb-particles span:nth-child(3) { bottom: 15%; right: 15%; animation-delay: 1.6s; }
.orb-particles span:nth-child(4) { bottom: 10%; left: 20%; animation-delay: 2.4s; }
.orb-particles span:nth-child(5) { top: 40%; left: 5%; animation-delay: 3.2s; }
.orb-particles span:nth-child(6) { top: 15%; right: 25%; animation-delay: 4s; }

@keyframes orbPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes orbGlow {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 1; }
}

@keyframes orbRing {
    0% { transform: rotate(0deg) scale(1); opacity: 0.4; }
    50% { transform: rotate(180deg) scale(1.05); opacity: 0.8; }
    100% { transform: rotate(360deg) scale(1); opacity: 0.4; }
}

@keyframes orbParticle {
    0%, 100% { opacity: 0; transform: translate(0, 0) scale(0.5); }
    20% { opacity: 1; transform: translate(-5px, -10px) scale(1); }
    80% { opacity: 0.5; transform: translate(8px, -15px) scale(0.8); }
}

/* Orb thinking animation */
.orb.thinking .orb-core {
    animation: orbThinking 1.5s ease-in-out infinite;
}

.orb.thinking .orb-glow {
    animation: orbThinkingGlow 1.5s ease-in-out infinite;
}

@keyframes orbThinking {
    0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(168, 85, 247, 0.5), 0 0 60px rgba(139, 92, 246, 0.3); }
    50% { transform: scale(1.12); box-shadow: 0 0 50px rgba(168, 85, 247, 0.7), 0 0 100px rgba(139, 92, 246, 0.5); }
}

@keyframes orbThinkingGlow {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 1; }
}

/* --- Messages --- */
.messages-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: none;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--space-xl) 0;
}

.messages-container.active {
    display: flex;
}

.message {
    display: flex;
    gap: var(--space-md);
    animation: messageIn 0.4s ease-out;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-violet));
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent-magenta), var(--accent-pink));
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-role {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.message-text {
    font-size: var(--font-size-base);
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
}

.message-text p {
    margin-bottom: var(--space-sm);
}

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

.message-actions {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.message-action-btn:hover {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple-light);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-purple-light);
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Processing message */
.processing-message {
    transition: opacity 0.3s ease;
}

/* Progress bar */
.progress-bar-container {
    width: 100%;
    height: 3px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-violet), var(--accent-pink));
    background-size: 200% 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
    animation: progressShimmer 2s linear infinite;
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

/* --- Input Section --- */
.input-section {
    flex-shrink: 0;
    padding: 0 var(--space-xl) var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-wrapper {
    width: 100%;
    max-width: 720px;
}

.input-box {
    background: var(--bg-input);
    border: 1px solid var(--bg-input-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-input);
    backdrop-filter: blur(20px);
    transition: all var(--transition-base);
}

.input-box:focus-within {
    border-color: var(--bg-input-border-focus);
    box-shadow: var(--shadow-input), 0 0 20px rgba(139, 92, 246, 0.12);
}

.message-input {
    width: 100%;
    background: transparent;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    line-height: 1.5;
    max-height: 150px;
    min-height: 24px;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-sm);
}

.input-tools {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.tool-btn:hover {
    color: var(--accent-purple-light);
    background: rgba(139, 92, 246, 0.1);
}

.tool-divider {
    width: 1px;
    height: 16px;
    background: rgba(100, 100, 140, 0.25);
    margin: 0 2px;
}

.mic-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--mic-bg);
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.mic-btn:hover {
    background: var(--mic-hover-bg);
    color: white;
    transform: scale(1.05);
}

.mic-btn.recording {
    background: rgba(239, 68, 68, 0.6);
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* Send button (replaces mic when typing) */
.send-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-violet));
    color: white;
    transition: all var(--transition-base);
}

.send-btn.visible {
    display: flex;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

.mic-btn.hidden {
    display: none;
}

/* --- Suggestions --- */
.suggestions {
    text-align: center;
    margin-top: var(--space-lg);
    max-width: 720px;
    transition: all var(--transition-slow);
}

.suggestions.hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    height: 0;
    margin: 0;
    overflow: hidden;
}

.suggestions-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.suggestions-label svg {
    color: var(--accent-purple-light);
}

.suggestions-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
}

.suggestion-pill {
    padding: 8px 18px;
    background: var(--pill-bg);
    border: 1px solid var(--pill-border);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 400;
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
}

.suggestion-pill:hover {
    background: var(--pill-hover-bg);
    border-color: var(--pill-hover-border);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.1);
}

.suggestions-hint {
    font-size: var(--font-size-xs);
    color: var(--text-hint);
    margin-top: var(--space-md);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 140, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 100, 140, 0.5);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .header {
        padding: var(--space-md);
        flex-direction: column;
        gap: var(--space-md);
    }

    .header-right {
        align-self: flex-end;
    }

    .header-title {
        font-size: var(--font-size-xl);
    }

    .input-section {
        padding: 0 var(--space-md) var(--space-md);
    }

    .input-box {
        padding: var(--space-sm) var(--space-md);
    }

    .orb {
        width: 140px;
        height: 140px;
    }

    .orb-core {
        width: 75px;
        height: 75px;
    }

    .orb-glow {
        width: 120px;
        height: 120px;
    }

    .orb-ring {
        width: 105px;
        height: 105px;
    }

    .suggestion-pill {
        font-size: var(--font-size-xs);
        padding: 6px 14px;
    }

    .blob-1 { width: 300px; height: 300px; }
    .blob-2 { width: 250px; height: 250px; }
    .blob-3 { width: 200px; height: 200px; }
}

@media (max-width: 480px) {
    .header-btn span {
        display: none;
    }

    .suggestions-grid {
        flex-direction: column;
        align-items: center;
    }
}

/* --- Fullscreen Mode --- */
body.fullscreen .header {
    display: none;
}

body.fullscreen .chat-area {
    height: calc(100vh - 180px);
}
