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

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark theme colors */
    --background: hsl(222, 47%, 6%);
    --foreground: hsl(210, 40%, 96%);
    --card: hsl(222, 47%, 8%);
    --primary: hsl(190, 95%, 50%);
    --primary-foreground: hsl(222, 47%, 6%);
    --secondary: hsl(222, 30%, 14%);
    --muted: hsl(222, 30%, 12%);
    --muted-foreground: hsl(215, 20%, 55%);
    --destructive: hsl(0, 84%, 60%);
    --border: hsl(222, 30%, 18%);
    
    /* Terminal colors */
    --terminal-bg: #ffffff;
    --terminal-text: #000000;
    --user-message-bg: hsl(190, 95%, 85%);
    
    /* Fonts */
    --font-body: 'Inter', sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
}

html {
    height: 100%;
    width: 100vw;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    color: var(--foreground);
    background: var(--background);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

/* ===== NAVIGATION ===== */
.navbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 1000;
}

.nav-container {
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.nav-logo a {
    display: block;
    line-height: 0;
}

.nav-logo img {
    display: block;
    height: 44px !important;
    max-height: 44px !important;
    width: auto;
    object-fit: contain;
}

.nav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-link {
    padding: 8px 16px;
    text-decoration: none;
    color: var(--muted-foreground);
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--primary);
    background: var(--secondary);
}

.nav-link-primary {
    background: var(--primary);
    color: var(--primary-foreground);
}

.nav-link-primary:hover {
    opacity: 0.9;
    box-shadow: 0 0 20px hsl(190, 95%, 50%, 0.4);
}

/* ===== HERO BANNER ===== */
.hero-banner {
    background: linear-gradient(135deg, var(--card) 0%, var(--secondary) 100%);
    border-bottom: 1px solid var(--border);
    padding: 60px 20px;
    text-align: center;
    flex-shrink: 0;
}

.hero-text {
    font-size: 42px;
    font-weight: 700;
    color: var(--foreground);
    margin: 0 auto;
    max-width: 900px;
    line-height: 1.2;
}

.hero-arrow {
    font-size: 48px;
    color: var(--primary);
    margin-top: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(10px);
    }
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    border: none;
    font-family: var(--font-body);
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    opacity: 0.9;
    box-shadow: 0 0 60px hsl(190, 95%, 50%, 0.3);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--foreground);
}

.btn-secondary:hover {
    background: var(--muted);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ===== CHAT CONTAINER - FULL SCREEN ===== */
.chat-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--background);
    padding: 10px;
    overflow: hidden;
}

.chat-screen {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--terminal-bg);
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border: 2px solid var(--border);
    position: relative; /* For absolute positioning of scroll indicator */
}

.chat-controls {
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 2px solid #e5e5e5;
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.database-selector {
    flex: 1;
    max-width: 250px;
    padding: 10px 12px;
    border-radius: 6px;
    border: 2px solid #ddd;
    background: white;
    color: var(--terminal-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-mono);
}

.database-selector:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsl(190, 95%, 50%, 0.2);
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--terminal-bg);
}

/* Scroll indicator */
.scroll-indicator {
    position: fixed; /* Fixed to viewport, not chat container */
    bottom: 120px; /* Above input area */
    right: 40px;
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000; /* High z-index to stay on top */
    transition: opacity 0.3s, transform 0.3s;
}

.scroll-indicator:hover {
    transform: scale(1.1);
}

.scroll-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.scroll-arrow {
    font-size: 28px;
    color: var(--primary-foreground);
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary);
    color: var(--primary-foreground);
}

.message.assistant .message-avatar {
    background: #333;
    color: white;
}

.message-content {
    padding: 12px 16px;
    border-radius: 8px;
    line-height: 1.6;
    font-family: var(--font-mono);
    font-size: 14px;
    border: 1px solid #ddd;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--user-message-bg);
    color: var(--terminal-text);
}

.message.assistant .message-content {
    background: var(--terminal-bg);
    color: var(--terminal-text);
}

.message-content a {
    color: var(--primary);
    text-decoration: underline;
}

.message-content strong {
    font-weight: 700;
}

.sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    font-size: 12px;
    color: #555;
}

.sources strong {
    display: block;
    margin-bottom: 4px;
}

.redacted {
    background: #333;
    color: #333;
    padding: 2px 6px;
    border-radius: 3px;
    user-select: none;
}

.loading {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: #555;
    border-radius: 50%;
    animation: bounce-dot 1.4s infinite ease-in-out;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce-dot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.chat-input-container {
    padding: 16px;
    border-top: 2px solid #e5e5e5;
    background: rgba(0, 0, 0, 0.02);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    font-family: var(--font-mono);
    background: white;
    color: var(--terminal-text);
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsl(190, 95%, 50%, 0.2);
}

.chat-input::placeholder {
    color: #888;
}

.send-button {
    padding: 12px 28px;
    background: var(--primary);
    color: var(--primary-foreground);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.send-button:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 0 60px hsl(190, 95%, 50%, 0.3);
}

.send-button:disabled {
    background: #999;
    cursor: not-allowed;
    opacity: 0.5;
}

.error {
    background: #fef2f2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

.preview-notice {
    margin-top: 10px;
    padding: 10px;
    background: #fef9e7;
    border: 1px solid #f1c40f;
    border-radius: 6px;
    font-size: 12px;
    color: #7d6608;
    font-weight: 500;
}

.preview-notice a {
    color: #7d6608;
    font-weight: 600;
    text-decoration: underline;
}

/* ===== AUTH PAGES ===== */
.auth-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.auth-card {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 40px;
    max-width: 440px;
    width: 100%;
}

.auth-title {
    text-align: center;
    color: var(--primary);
    margin-bottom: 28px;
    font-size: 26px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: var(--secondary);
    color: var(--muted-foreground);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--primary);
    color: var(--primary-foreground);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--secondary);
    color: var(--foreground);
}

.auth-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsl(190, 95%, 50%, 0.1);
}

.auth-input::placeholder {
    color: var(--muted-foreground);
}

.auth-error {
    color: var(--destructive);
    font-size: 14px;
    text-align: center;
    min-height: 20px;
}

.auth-info {
    margin-top: 16px;
    padding: 14px;
    background: var(--secondary);
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid var(--border);
}

.auth-info ul {
    margin-top: 8px;
    margin-left: 20px;
}

.verify-title {
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 20px;
}

.verify-text {
    margin-bottom: 16px;
    color: var(--muted-foreground);
    font-size: 14px;
}

/* ===== DASHBOARD LAYOUT ===== */
#chatInterface {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dashboard-container {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.dashboard-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stats-sidebar {
    width: 280px;
    background: var(--card);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats-card {
    background: var(--secondary);
    border-radius: 10px;
    padding: 18px;
    border: 1px solid var(--border);
}

.stats-card h3 {
    font-size: 15px;
    margin-bottom: 14px;
    color: var(--foreground);
}

.plan-info {
    text-align: center;
}

.plan-name {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--primary);
}

.plan-usage {
    font-size: 22px;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 4px;
}

.plan-period {
    font-size: 12px;
    color: var(--muted-foreground);
}

.tribunal-list {
    list-style: none;
    font-size: 13px;
    color: var(--foreground);
}

.tribunal-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.tribunal-list li:last-child {
    border-bottom: none;
}

/* ===== CONTENT PAGES ===== */
.page-container {
    flex: 1;
    overflow-y: auto;
    padding: 50px 20px;
}

.content-wrapper {
    width: 100%;
    padding: 0 40px;
    margin: 0 auto;
}

.content-narrow {
    max-width: 750px;
}

.page-title {
    font-size: 32px;
    margin-bottom: 28px;
    color: var(--foreground);
}

.content-section {
    margin-bottom: 40px;
    background: var(--card);
    border-radius: 12px;
    padding: 28px;
    border: 1px solid var(--border);
}

.content-section h2 {
    font-size: 22px;
    margin-bottom: 14px;
    color: var(--foreground);
}

.content-section p {
    color: var(--muted-foreground);
    line-height: 1.7;
    margin-bottom: 14px;
}

.example-box {
    background: var(--secondary);
    border-left: 4px solid var(--primary);
    padding: 18px;
    border-radius: 8px;
    margin-top: 14px;
}

.example-box ul {
    margin-top: 10px;
    margin-left: 18px;
    color: var(--foreground);
}

.tips-list {
    margin-left: 18px;
    color: var(--muted-foreground);
}

.tips-list li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* ===== CONTACT PAGE ===== */
.contact-intro {
    text-align: center;
    margin-bottom: 40px;
    color: var(--muted-foreground);
    font-size: 17px;
}

.contact-form-container {
    background: var(--card);
    border-radius: 12px;
    padding: 35px;
    border: 1px solid var(--border);
    margin-bottom: 40px;
}

.contact-form {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--foreground);
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--secondary);
    color: var(--foreground);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsl(190, 95%, 50%, 0.1);
}

textarea.form-input {
    resize: vertical;
    min-height: 110px;
}

.form-message {
    margin-top: 14px;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
}

.form-message.success {
    background: hsl(142, 76%, 36%, 0.1);
    color: hsl(142, 76%, 36%);
    border: 1px solid hsl(142, 76%, 36%);
}

.form-message.error {
    background: hsl(0, 84%, 60%, 0.1);
    color: var(--destructive);
    border: 1px solid var(--destructive);
}

.contact-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.contact-info-card {
    background: var(--card);
    border-radius: 12px;
    padding: 28px;
    text-align: center;
    border: 1px solid var(--border);
}

.contact-icon {
    font-size: 44px;
    margin-bottom: 14px;
}

.contact-info-card h3 {
    font-size: 17px;
    margin-bottom: 10px;
    color: var(--foreground);
}

.contact-info-card p {
    color: var(--muted-foreground);
}

.contact-info-card a {
    color: var(--primary);
    text-decoration: none;
}

.faq-section {
    margin-top: 50px;
}

.faq-section h2 {
    font-size: 26px;
    margin-bottom: 28px;
    color: var(--foreground);
}

.faq-item {
    background: var(--card);
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
}

.faq-item h3 {
    font-size: 17px;
    margin-bottom: 10px;
    color: var(--foreground);
}

.faq-item p {
    color: var(--muted-foreground);
    line-height: 1.6;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--card);
    color: var(--foreground);
    padding: 50px 20px 20px;
    border-top: 1px solid var(--border);
}

.footer.footer-compact {
    padding: 20px;
}

.footer.footer-compact .footer-content {
    display: none;
}

.footer.footer-compact .footer-bottom {
    padding-top: 0;
    border-top: none;
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    margin-bottom: 35px;
}

.footer-section h3,
.footer-section h4 {
    margin-bottom: 14px;
    color: var(--foreground);
}

.footer-section p {
    color: var(--muted-foreground);
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 7px;
}

.footer-section a {
    color: var(--muted-foreground);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: var(--primary);
}

.footer-bottom {
    max-width: 1100px;
    margin: 0 auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--muted-foreground);
    font-size: 13px;
}

/* ===== SCROLLBAR ===== */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
    }
}

.chat-messages::-webkit-scrollbar,
.stats-sidebar::-webkit-scrollbar,
.page-container::-webkit-scrollbar,
.auth-container::-webkit-scrollbar {
    width: 10px;
}

.chat-messages::-webkit-scrollbar-track,
.stats-sidebar::-webkit-scrollbar-track,
.page-container::-webkit-scrollbar-track,
.auth-container::-webkit-scrollbar-track {
    background: #e8e8e8;
}

.chat-messages::-webkit-scrollbar-thumb,
.stats-sidebar::-webkit-scrollbar-thumb,
.page-container::-webkit-scrollbar-thumb,
.auth-container::-webkit-scrollbar-thumb {
    background: #b0b0b0;
    border-radius: 5px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.stats-sidebar::-webkit-scrollbar-thumb:hover,
.page-container::-webkit-scrollbar-thumb:hover,
.auth-container::-webkit-scrollbar-thumb:hover {
    background: #888;
}

/* ===== UTILITY ===== */
.hidden {
    display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 10px;
    }
    
    .nav-logo img {
        height: 28px !important;
        max-height: 28px !important;
    }

    .chat-container {
        padding: 6px;
    }
    
    .chat-screen {
        border-radius: 12px;
    }

    .chat-controls {
        flex-direction: column;
    }

    .database-selector {
        max-width: 100%;
    }

    .message {
        max-width: 92%;
    }

    .dashboard-container {
        flex-direction: column;
    }

    .stats-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .footer-content,
    .contact-info-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }
}
