/* ═══════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════ */

.login-page {
    background: #0a0f1e;
    position: relative;
}

/* Animated background */
.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.login-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

.login-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: orbFloat 20s ease-in-out infinite;
}

.login-orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #1d4ed8 0%, transparent 70%);
    top: -200px;
    left: -100px;
    animation-duration: 25s;
}

.login-orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
    bottom: -150px;
    right: -100px;
    animation-duration: 20s;
    animation-delay: -5s;
}

.login-orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #0ea5e9 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 18s;
    animation-delay: -10s;
    opacity: 0.3;
}

@keyframes orbFloat {
    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.02); }
}

@media (max-width: 640px) {
    .login-orb-1 { width: 300px; height: 300px; }
    .login-orb-2 { width: 250px; height: 250px; }
    .login-orb-3 { width: 200px; height: 200px; }
    .login-card { padding: 1.5rem; }
}

/* Glass card */
.login-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Input fields */
.login-input {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.login-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Submit button */
.login-btn {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
}

.login-btn:hover {
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.45);
    transform: translateY(-1px);
}

.login-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

/* Fade-in animation */
.login-fade-in {
    animation: loginFadeIn 0.8s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

.login-fade-in-delay {
    animation-delay: 0.2s;
}

@keyframes loginFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════
   CHAT & APP
   ═══════════════════════════════════════════ */

/* Mobile viewport fix (100vh includes browser chrome on mobile) */
.mobile-viewport {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    height: 100dvh; /* Modern browsers */
}

/* Mobile sidebar — positioned fixed, hidden off-screen, JS controls transform */
@media (max-width: 1023px) {
    .sidebar-mobile {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    }
}

/* Mobile chat bubbles */
@media (max-width: 640px) {
    .ai-bubble, [class*="bg-primary-600"][class*="rounded-2xl"] {
        max-width: 90% !important;
    }

    .prose {
        font-size: 0.9rem;
    }

    .prose h1 { font-size: 1.15em; }
    .prose h2 { font-size: 1.1em; }
    .prose h3 { font-size: 1.05em; }
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .topic-btn {
        min-height: 48px;
    }

    #chat-input {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }
}

/* Typing indicator animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Prose styling for AI responses */
.prose h1, .prose h2, .prose h3, .prose h4 {
    font-weight: 600;
    margin-top: 1em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}

.prose h1 { font-size: 1.25em; }
.prose h2 { font-size: 1.15em; }
.prose h3 { font-size: 1.05em; }

.prose p {
    margin-bottom: 0.75em;
    line-height: 1.6;
}

.prose ul, .prose ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.prose li {
    margin-bottom: 0.25em;
    line-height: 1.5;
}

.prose ul li { list-style-type: disc; }
.prose ol li { list-style-type: decimal; }

.prose code {
    background: #f1f5f9;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Courier New', monospace;
}

.prose pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.75em 0;
}

.prose pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.prose blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 1em;
    color: #64748b;
    margin: 0.75em 0;
}

.prose strong { font-weight: 600; }

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75em 0;
}

.prose th, .prose td {
    border: 1px solid #e2e8f0;
    padding: 0.5em 0.75em;
    text-align: left;
}

.prose th {
    background: #f8fafc;
    font-weight: 600;
}

/* AI chat bubble dark mode */
.ai-bubble {
    background: white;
}

.dark .ai-bubble {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

/* Dark mode prose overrides */
.dark .prose-invert code {
    background: #334155;
    color: #e2e8f0;
}

.dark .prose-invert blockquote {
    color: #94a3b8;
}

.dark .prose-invert th, .dark .prose-invert td {
    border-color: #475569;
}

.dark .prose-invert th {
    background: #334155;
    color: #e2e8f0;
}

/* Active topic highlight dark mode */
.dark .topic-btn.bg-primary-50 {
    background: rgba(37, 99, 235, 0.15) !important;
}

.dark .topic-btn.text-primary-700 {
    color: #93c5fd !important;
}

/* (sidebar responsive is now handled by .sidebar-mobile above) */

/* Chat messages scroll fix */
#messages {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

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

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

#messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dark #messages::-webkit-scrollbar-thumb {
    background: #475569;
}

.dark #messages::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Admin mobile */
@media (max-width: 640px) {
    .admin-tab {
        white-space: nowrap;
        padding-left: 1rem;
        padding-right: 1rem;
        font-size: 0.8rem;
    }
}

/* Admin tab active state */
.admin-tab {
    color: #6b7280;
    transition: all 0.2s;
}

.admin-tab.active {
    color: #2563eb;
    border-bottom: 2px solid #2563eb;
}

/* File input styling */
input[type="file"]::file-selector-button {
    cursor: pointer;
}

/* Smooth transitions */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dark * {
    scrollbar-color: #475569 transparent;
}

/* Dark mode transition */
html.dark {
    color-scheme: dark;
}
