/* 
  style.css
  Contains all the styling for the application.
  Implements the "Neural Glass" premium dark mode aesthetic, responsive design,
  and reactive micro-interactions.
*/
:root {
    /* Neural Glass Aesthetic Colors */
    --bg-deep: #050505;
    --bg-glass: rgba(15, 15, 20, 0.4);
    --bg-glass-heavy: rgba(10, 10, 15, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 240, 255, 0.3);

    --neon-cyan: #00f0ff;
    --neon-violet: #8b5cf6;
    --neon-red: #ff2a5f;
    --critic-color: #ff2a5f;
    --success-color: #00e676;

    --text-main: #ffffff;
    --text-muted: #8892b0;

    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --font-mono: 'Fira Code', monospace;

    /* Glass Effects */
    --blur-light: blur(10px);
    --blur-heavy: blur(24px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-deep);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- AMBIENT NEURAL BACKGROUND --- */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: var(--bg-deep);
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    animation: floatGlow 20s infinite alternate ease-in-out;
}

.glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--neon-violet) 0%, transparent 70%);
    top: -20%;
    left: -10%;
    animation-duration: 25s;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--neon-cyan) 0%, transparent 70%);
    bottom: -10%;
    right: -10%;
    animation-duration: 22s;
    animation-delay: -5s;
}

.glow-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--neon-red) 0%, transparent 70%);
    top: 40%;
    left: 40%;
    opacity: 0.15;
    animation-duration: 30s;
    animation-delay: -10s;
}

@keyframes floatGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(50px, -50px) scale(1.1);
    }

    100% {
        transform: translate(-30px, 40px) scale(0.9);
    }
}

/* --- LAYOUT STATE 1: Landing Screen --- */
.landing-screen {
    min-height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.logo {
    max-width: 380px;
    height: auto;
    margin-bottom: 1.5rem;
    display: block;
    filter: drop-shadow(0 0 30px rgba(0, 240, 255, 0.2));
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.5s ease;
}

.logo:hover {
    transform: scale(1.05) translateY(-5px);
    filter: drop-shadow(0 0 50px rgba(139, 92, 246, 0.6));
    cursor: pointer;
}

h1 {
    font-size: 4.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    letter-spacing: -0.04em;
    line-height: 1.05;
}

.beta-badge {
    position: absolute;
    top: 0;
    right: -20px;
    background: var(--critic-color);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    transform: rotate(10deg);
    box-shadow: 0 2px 10px rgba(255, 42, 95, 0.5);
    z-index: 10;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: rotate(10deg) translateY(0);
    }

    40% {
        transform: rotate(10deg) translateY(-5px);
    }

    60% {
        transform: rotate(10deg) translateY(-3px);
    }
}

.gradient-text {
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-violet));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 40px rgba(139, 92, 246, 0.4);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.3rem;
    max-width: 650px;
    margin: 0 auto 3rem;
    line-height: 1.8;
    font-weight: 300;
}

/* Neural Glass Start Button */
.btn-glow {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 0.1em;
    padding: 1.2rem 3rem;
    border: 1px solid var(--border-glass);
    border-radius: 50px;
    cursor: pointer;
    background: var(--bg-glass-heavy);
    backdrop-filter: var(--blur-heavy);
    -webkit-backdrop-filter: var(--blur-heavy);
    color: white;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    isolation: isolate;
}

.btn-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-violet), var(--neon-red), var(--neon-cyan));
    background-size: 300%;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: gradientFlow 4s linear infinite;
}

.btn-glow:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 240, 255, 0.4);
    border-color: transparent;
    color: #fff;
}

.btn-glow:hover::after {
    opacity: 1;
}

/* --- Stagger Animations --- */
.stagger-1 {
    opacity: 0;
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.2s;
}

.stagger-2 {
    opacity: 0;
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.4s;
}

.stagger-3 {
    opacity: 0;
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.6s;
}

.stagger-4 {
    opacity: 0;
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.8s;
}

@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(40px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-glow:hover::before {
    opacity: 1;
}

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* --- State Transitions --- */
.fade-out {
    animation: fadeOutAnim 0.4s ease forwards;
}

@keyframes fadeOutAnim {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.98);
        visibility: hidden;
    }
}

.fade-in {
    animation: fadeInAnim 0.5s ease forwards;
}

@keyframes fadeInAnim {
    from {
        opacity: 0;
        transform: scale(1.02);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- LAYOUT STATE 2: Full-screen Analysis Terminal --- */
.chat-app {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: transparent;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.chat-header {
    background: var(--bg-glass-heavy);
    backdrop-filter: var(--blur-heavy);
    -webkit-backdrop-filter: var(--blur-heavy);
    padding: max(0.8rem, env(safe-area-inset-top)) 1.5rem 0.8rem 1.5rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-glass);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--neon-red), var(--neon-violet)) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(255, 42, 95, 0.3);
}

.chat-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: white;
}

.chat-info .status {
    font-size: 0.9rem;
    font-family: var(--font-mono);
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.chat-window {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    /* Prevents scroll bouncing */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: transparent;
    scroll-behavior: smooth;
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

/* Custom Scrollbar */
.chat-window::-webkit-scrollbar {
    width: 8px;
}

.chat-window::-webkit-scrollbar-track {
    background: transparent;
}

.chat-window::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* --- Anti-Bubble: Neural Analysis Cards --- */
.analysis-card {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.8rem;
    font-size: 1.05rem;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
    border-radius: 16px;
    background: var(--bg-glass);
    backdrop-filter: var(--blur-heavy);
    -webkit-backdrop-filter: var(--blur-heavy);
    color: var(--text-main);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: cardEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: all 0.4s ease;
}

.analysis-card.ai {
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-left: 4px solid var(--neon-violet);
}

.analysis-card.user {
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-right: 4px solid var(--neon-cyan);
    text-align: right;
    background: rgba(0, 240, 255, 0.03);
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}



.analysis-card p {
    margin-bottom: 1rem;
}

.analysis-card p:last-child {
    margin-bottom: 0;
}

.analysis-card.dimmed {
    opacity: 0.5;
    transform: scale(0.98);
}

.analysis-card.dimmed:hover {
    opacity: 1;
    transform: scale(1);
}

/* --- Typography Engine: Neural Glass --- */
/* Markdown Headers */
.sys-header {
    font-family: var(--font-heading);
    color: var(--neon-cyan);
    letter-spacing: 0.05em;
    margin-top: 2rem;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid rgba(0, 240, 255, 0.15);
    padding-bottom: 0.6rem;
    text-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
    font-weight: 800;
}

.analysis-card.ai h1.sys-header {
    font-size: 1.5rem;
    color: var(--neon-violet);
    border-color: rgba(139, 92, 246, 0.3);
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.analysis-card h2.sys-header {
    font-size: 1.25rem;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.analysis-card h3.sys-header {
    font-size: 1.1rem;
    border-bottom: none;
    color: var(--text-muted);
}

/* User Commands */
.user-command {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: white;
    background: rgba(0, 240, 255, 0.05);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border-left: 3px solid var(--neon-cyan);
    box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.02);
    display: inline-block;
}

.user-command em {
    color: var(--text-muted);
    font-style: normal;
}

/* Markdown Formatting */
.analysis-card strong {
    color: white;
    font-weight: 800;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.analysis-card em {
    color: var(--neon-cyan);
    font-style: normal;
}

/* Custom Bullet Points */
.analysis-card ul {
    padding-left: 0;
    margin: 1.5rem 0;
    list-style: none;
}

.analysis-card li {
    margin-bottom: 0.8rem;
    color: #e2e8f0;
    position: relative;
    padding-left: 1.5rem;
    line-height: 1.6;
}

.analysis-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6rem;
    width: 8px;
    height: 2px;
    background: var(--neon-violet);
    box-shadow: 0 0 8px var(--neon-violet);
    border-radius: 2px;
}

.analysis-card.user li::before {
    background: var(--neon-cyan);
    box-shadow: 0 0 8px var(--neon-cyan);
}

/* Processing Animations */
.typing-indicator-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pulse-ring {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--neon-violet);
    position: relative;
    animation: pulse 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
        box-shadow: 0 0 0 15px rgba(139, 92, 246, 0);
    }
}

.typing-text {
    font-family: var(--font-mono);
    color: var(--neon-violet);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.9em;
}

/* Markdown Tables */
.table-container {
    overflow-x: auto;
    margin: 2rem 0;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);

}

.analysis-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-family: var(--font-mono);
}

.analysis-card th,
.analysis-card td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.analysis-card th {
    background: rgba(139, 92, 246, 0.1);
    color: var(--neon-violet);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analysis-card tr:last-child td {
    border-bottom: none;
}

/* --- REACTIVE INPUT ENGINE --- */
.command-bar-container {
    padding: 0 2rem max(2rem, env(safe-area-inset-bottom)) 2rem;
    background: transparent;
    display: flex;
    flex-direction: column;
    z-index: 100;
    position: sticky;
    bottom: 0;
}

.command-bar {
    display: flex;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-glass-heavy);
    backdrop-filter: var(--blur-heavy);
    -webkit-backdrop-filter: var(--blur-heavy);
    border-radius: 50px;
    border: 1px solid var(--border-glass);
    padding: 0.8rem 1.5rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.command-bar.active-typing {
    border-color: rgba(0, 240, 255, 0.6);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.2), 0 10px 30px rgba(0, 0, 0, 0.4);
}

.cmd-prompt {
    font-family: var(--font-mono);
    color: var(--neon-cyan);
    font-weight: bold;
    font-size: 1.2rem;
    user-select: none;
}

#chatInput {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-family: var(--font-body);
    font-size: 1.1rem;
    outline: none;
}

#chatInput::placeholder {
    color: #4b5563;
}

.chat-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0.6rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.chat-upload-label:hover {
    color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
    transform: scale(1.05);
}

#sendChatBtn {
    background: linear-gradient(135deg, var(--neon-violet), var(--neon-cyan));
    color: white;
    border: none;
    border-radius: 50px;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

#sendChatBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.5);
    filter: brightness(1.2);
}

#sendChatBtn:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.2);
    box-shadow: none;
    cursor: not-allowed;
}

.error {
    background: rgba(255, 42, 95, 0.1);
    color: var(--neon-red);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    text-align: center;
    border: 1px solid rgba(255, 42, 95, 0.3);
}

.hidden {
    display: none !important;
}

/* Footer Styles */
.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 4rem;
    padding-bottom: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    z-index: 10;
}

.footer-links {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--neon-cyan);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: white;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.footer .separator {
    margin: 0 10px;
    opacity: 0.5;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .logo {
        max-width: 250px;
    }

    h1 {
        font-size: 2.2rem;
        margin-bottom: 1rem;
    }

    .subtitle {
        font-size: 0.95rem;
        line-height: 1.5;
        margin-bottom: 1.5rem;
    }

    .landing-content {
        padding: 1rem;
    }

    .chat-header {
        padding: 0.8rem;
    }

    .command-bar-container {
        padding: 0 0.5rem max(0.5rem, env(safe-area-inset-bottom)) 0.5rem;
    }

    .command-bar textarea {
        font-size: 16px;
        /* Prevents iOS Safari auto-zoom */
    }

    .analysis-card {
        padding: 1rem;
    }

    #startChatBtn {
        padding: 0.8rem 1.5rem;
        font-size: 0.95rem;
    }
}