@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --background: 0 0% 0%; /* Pure black */
    --foreground: 210 40% 98%; /* Almost white */
    --card: 230 20% 10% / 0.90; /* Deep dark blue for card bg - 90% opacity */
    --card-foreground: 210 40% 98%;
    --primary: 230 80% 65%; /* Vibrant blue-purple for main glow, focus rings */
    --primary-foreground: 0 0% 100%; /* White text on primary */
    --muted: 220 20% 25%;
    --muted-foreground: 220 15% 65%; /* For "Remember me", "OR", placeholder hints */
    --accent: 230 80% 65%; /* Vibrant blue-purple for links, matching primary glow */
    --accent-foreground: 0 0% 100%; /* White text if accent were a button bg */
    --destructive: 0 70% 55%;
    --destructive-foreground: 0 0% 100%;
    --border: 230 50% 40%; /* General borders, darker version of primary */
    --input: 230 30% 25%;  /* For BORDER of input fields (dark, subtle blue tint when not focused) */
    --ring: 230 80% 70%; /* Brighter primary for focus rings */
    --glow-cyan: 185 85% 55%; /* Vibrant cyan for bottom card glow */
    --agent-stack-offset-desktop: -104px;
    --agent-stack-offset-mobile: -84px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Star Background */
.star-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: hsl(var(--background));
    will-change: transform;
}

/* Login/Agent Container */
.container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-grow: 1;
    flex-direction: column;
    align-items: center;
    padding: 0 1rem 1rem;
}

@media (min-width: 641px) {
    body {
        overflow-y: scroll;
    }
}

/* Agent Display Styles (from partials/agent_display.html) */
.qr-glow-container {
    position: relative;
    width: 250px;
    height: 250px;
    min-width: 250px;
    min-height: 250px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    background: transparent;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    will-change: box-shadow, border-color;
    flex-shrink: 0;
    overflow: hidden;
    cursor: pointer;
    z-index: 10;
}

.qr-code-img {
    width: 170px;
    height: 170px;
    z-index: 2;
    border-radius: 12px;
    filter: invert(1);
    mix-blend-mode: screen;
}

.status-text {
    color: hsl(var(--muted-foreground));
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.8;
    height: 1.2em; /* Prevent layout shift */
    text-align: center;
}

.caption-container {
    width: 100%;
    max-width: 600px;
    height: 14rem; /* Increased height */
    margin-top: 1rem;
    z-index: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: relative;
    padding-left: 10%; /* Mobile default */

    /* Hide scrollbar */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */

    /* Default mask: None. Fades are applied via classes based on scroll state. */
    mask-image: none;
    -webkit-mask-image: none;

    transition:
        mask-image 0.3s ease,
        -webkit-mask-image 0.3s ease,
        transform 0.3s ease;
}

/* Top fade only (when scrolled down) */
.caption-container.mask-top {
    transform: translateY(-2rem);
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 10%,
        black 40%,
        black 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 10%,
        black 40%,
        black 100%
    );
}

/* Bottom fade only (when scrolled to top) */
.caption-container.mask-bottom {
    mask-image: linear-gradient(
        to bottom,
        black 0%,
        black 60%,
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        black 0%,
        black 60%,
        transparent 100%
    );
}

/* Both fades (when in middle) */
.caption-container.mask-both {
    transform: translateY(-2rem);
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 10%,
        black 40%,
        black 60%,
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 10%,
        black 40%,
        black 60%,
        transparent 100%
    );
}

.caption-container::-webkit-scrollbar {
    display: none;
}

/* Spacer to allow scrolling past content */
.caption-container::after {
    content: "";
    display: block;
    min-height: 12rem; /* Approx one page height */
    flex-shrink: 0;
    width: 100%;
}

.caption-block {
    position: relative;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.5;
    max-width: 95%; /* Mobile default */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    text-align: left;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .caption-container {
        padding-left: 5%;
        padding-right: 0;
        align-items: flex-start; /* Left aligns the caption-blocks */
    }
    .caption-block {
        max-width: 90%; /* Restore to 90% for desktop */
    }
}

.caption-block span {
    opacity: 1;
    white-space: pre-wrap;
}

/* Agent Interface Specific (from agent_interface.html) */
.agent-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 70px 1rem 0;
    z-index: 15;
    flex-shrink: 0;
    min-height: 100dvh; /* From agent_interface.html */
}

.agent-page .agent-container {
    transform: translateY(var(--agent-stack-offset-desktop));
    will-change: transform;
}

.login-agent-container {
    min-height: 80dvh;
}

@media (max-width: 640px) {
    .agent-container {
        padding-top: 70px;
    }

    .agent-page .agent-container {
        transform: translateY(var(--agent-stack-offset-mobile));
    }
}

/* Match caption width to login card width */
.agent-container .caption-container {
    max-width: 38rem;
}

/* Login Card Styles (from login.html) */
.login-card {
    width: 100%;
    max-width: 24rem;
    background: transparent;
    border: 2px solid hsl(var(--primary) / 0.8);
    box-shadow: 0px 0px 25px 5px hsl(var(--primary) / 0.5),
                0px 20px 25px -8px hsl(var(--glow-cyan) / 0.5);
    border-radius: 1.5rem;
    backdrop-filter: blur(10px);
    transition: box-shadow 0.1s ease-out, border-color 0.1s ease-out;
}

@keyframes flashWhite {
    0% {
        border-color: hsl(var(--primary) / 0.8);
        box-shadow: 0px 0px 25px 5px hsl(var(--primary) / 0.5),
                    0px 20px 25px -8px hsl(var(--glow-cyan) / 0.5);
    }
    50% {
        border-color: rgba(255, 255, 255, 0.7);
        box-shadow: 0px 0px 30px 8px rgba(255, 255, 255, 0.4),
                    0px 0px 45px 15px rgba(255, 255, 255, 0.25);
    }
    100% {
        border-color: hsl(var(--primary) / 0.8);
        box-shadow: 0px 0px 25px 5px hsl(var(--primary) / 0.5),
                    0px 20px 25px -8px hsl(var(--glow-cyan) / 0.5);
    }
}

.login-card.flash {
    animation: flashWhite 0.5s ease-in-out;
}

.card-header {
    text-align: center;
    padding: 2rem 2rem 1.5rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: hsl(var(--foreground));
    margin-bottom: 0.5rem;
    display: inline-block;
}

.card-content {
    padding: 0 2rem 2rem;
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-input {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--input));
    color: hsl(var(--foreground));
    height: 3rem;
    padding: 0 0.75rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-input::placeholder {
    color: hsl(var(--muted-foreground) / 0.7);
}

.form-input:focus {
    outline: none;
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.sign-in-button {
    width: 100%;
    background: linear-gradient(135deg, #764ba2, #8A6ABF, #667eea);
    color: hsl(var(--primary-foreground));
    font-weight: 600;
    height: 3rem;
    border-radius: 0.5rem;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.sign-in-button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.sign-in-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.divider {
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
}

.divider-line {
    flex-grow: 1;
    border-top: 1px solid hsl(var(--input));
}

.divider-text {
    margin: 0 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

/* OAuth Buttons */
.oauth-button {
    width: 100%;
    border: 1px solid hsl(var(--input));
    background: #1f1f1f;
    color: #fff;
    font-weight: 500;
    height: 48px;
    border-radius: 24px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin-bottom: 1rem;
}

.oauth-button:hover {
    background: #2a2a2a;
    box-shadow: 0 1px 2px 0 rgba(255,255,255,.15), 0 1px 3px 1px rgba(255,255,255,.10);
}

.oauth-button:active {
    background: #3a3a3a;
}

.oauth-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.oauth-button:last-child {
    margin-bottom: 0;
}

.oauth-button svg {
    flex-shrink: 0;
}

.google-button {
    background: #000;
    border-color: #1a1a1a;
}

.google-button svg {
    width: 18px;
    height: 18px;
}

.apple-button {
    background: #000;
    color: #fff;
    border-color: #1a1a1a;
}

.apple-button:hover {
    background: #1a1a1a;
    border-color: #2a2a2a;
}

.apple-button:active {
    background: #2a2a2a;
}

.apple-button svg {
    width: 16px;
    height: 20px;
}

.facebook-button {
    background: #000;
    color: #fff;
    border-color: #1a1a1a;
}

.facebook-button:hover {
    background: #1a1a1a;
    border-color: #2a2a2a;
}

.facebook-button:active {
    background: #2a2a2a;
}

.facebook-button svg {
    width: 20px;
    height: 20px;
}

/* Upload Button */
.upload-button {
    position: absolute;
    top: 340px;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    height: 48px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    z-index: 50;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    backdrop-filter: blur(10px);
}

.upload-button:hover {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 1px 2px 0 rgba(255,255,255,.15), 0 1px 3px 1px rgba(255,255,255,.10);
}

.upload-button:active {
    background: rgba(255, 255, 255, 0.35);
}

/* Footer */
.footer {
    margin-top: 2rem;
    text-align: center;
    padding: 2rem 0;
    width: 100%;
}

.footer-text {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground) / 0.7);
}

.error-message {
    background: hsl(var(--destructive) / 0.1);
    border: 1px solid hsl(var(--destructive) / 0.5);
    color: hsl(var(--destructive-foreground));
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Loading Spinner */
.loading-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Nav Bar */
.top-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background: transparent;
    z-index: 100;
}

@media (min-width: 768px) {
    .top-nav {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 650px;
        width: 100%;
    }
}

.nav-logo {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    padding: 8px;
}

.nav-menu-dot {
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
}

/* FAQ Styles */
.faq-card {
    display: none; /* Initially hidden */
    width: 100%;
    max-width: 800px;
}

.faq-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 1rem;
}

.faq-question {
    color: white;
    font-size: 1.125rem;
    font-weight: 500;
    padding: 1.5rem 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    text-align: center;
}

.faq-question:hover {
    opacity: 0.8;
}

.faq-answer {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    line-height: 1.6;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0;
}

.faq-answer.expanded {
    max-height: 500px;
    padding-bottom: 1.5rem;
}

@media (max-width: 640px) {
    .container {
        padding: 0.5rem;
    }

    .qr-code-fixed {
        top: 40px;
    }

    .upload-button {
        top: 280px;
    }

    .login-card {
        max-width: 100%;
    }

    .card-header {
        padding: 1.5rem 1.5rem 1rem;
    }

    .card-content {
        padding: 0 1.5rem 1.5rem;
    }

    .top-nav {
        padding: 0 1rem;
    }
}

/* Agent Interface Specific Components */
.title-pill {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.8rem 2rem;
    border-radius: 9999px;
    color: white;
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.start-button {
    margin-top: 2rem;
    width: 250px;
    height: 48px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    z-index: 50;
    font-family:
        "Inter",
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.start-button:hover {
    background: rgba(255, 255, 255, 0.25);
    box-shadow:
        0 1px 2px 0 rgba(255, 255, 255, 0.15),
        0 1px 3px 1px rgba(255, 255, 255, 0.1);
}

.start-button:active {
    background: rgba(255, 255, 255, 0.35);
}

.input-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 600px;
    z-index: 100;
    display: flex;
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom);
    transition: bottom 0.3s ease;
}

.text-input-pill {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
    padding: 1rem 1.5rem;
    color: white;
    font-size: 1rem;
    font-family: "Inter", sans-serif;
    outline: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.text-input-pill::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.text-input-pill:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
