/* ============================================
   MODERN AI CHAT INTERFACE - ChatGPT Style
   ============================================ */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Modern Color Palette - ChatGPT Inspired */
    --bg-primary: #343541;
    --bg-secondary: #444654;
    --bg-tertiary: #202123;
    --text-primary: #ececf1;
    --text-secondary: #c5c5d2;
    --text-muted: #8e8ea0;
    --accent-primary: #10a37f;
    --accent-secondary: #19c37d;
    --border-color: #565869;
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Constrain search to narrower width */
.search-container {
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

/* Header full width */
.header {
    max-width: 100%;
    width: 100%;
}

/* ============================================
   HEADER - Minimal & Clean
   ============================================ */
.header {
    background: var(--bg-tertiary);
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.logo img {
    width: 40px !important;
    height: 40px !important;
    filter: drop-shadow(0 2px 8px rgba(16, 163, 127, 0.3));
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 400;
}

/* ============================================
   SEARCH CONTAINER - ChatGPT Input Style
   ============================================ */
.search-container {
    padding: 20px;
    max-width: 768px;
    margin: 0 auto;
    width: 100%;
}

.search-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    padding: 8px 0;
    outline: none;
}

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

.search-btn {
    background: var(--accent-primary);
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.search-btn:hover:not(:disabled) {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

.search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Suggestions Pills */
.suggestions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    justify-content: center;
}

.suggestion {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* ============================================
   RESULTS CONTAINER - Chat Messages Style
   ============================================ */
.results-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

#answer {
    margin: 0 auto;
    width: 100%;
    padding: 20px 40px;
    box-sizing: border-box;
}

@media (min-width: 1600px) {
    #answer {
        padding: 20px 60px;
    }
}

@media (max-width: 1023px) {
    #answer {
        padding: 20px;
    }
}

/* Response header and typing container */
.response-header,
.typing-container {
    max-width: 100%;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

/* Typing Animation - Realistic Keyboard Effect */
.typing-container {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    min-height: 60px;
    display: flex;
    align-items: center;
    border-radius: 0 0 12px 12px;
}

.typing-text {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
    display: inline-block;
}

.typing-text::after {
    content: '|';
    color: var(--accent-primary);
    animation: blink 0.8s infinite;
    margin-left: 2px;
}

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

/* Response header styles */
.response-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
}

/* Response header + typing container wrapper */
.response-wrapper {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    max-width: 100%;
    width: 100%;
}

.ai-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 8px;
    font-size: 16px;
}

.ai-dot {
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.ai-pulse {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0;
    animation: radarPulse 2s infinite;
}

.query-preview {
    color: var(--text-secondary);
    font-size: 14px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
}

@keyframes radarPulse {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.5;
    animation: float 3s ease-in-out infinite;
}

.empty-state h2 {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ============================================
   LOADING ANIMATION - Modern AI Thinking
   ============================================ */
.loading {
    display: none;
    padding: 60px 20px;
    text-align: center;
}

.ai-thinking {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    max-width: 400px;
    margin: 0 auto;
}

.thinking-dots {
    display: flex;
    gap: 10px;
}

.thinking-dot {
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: thinking 1.4s ease-in-out infinite both;
}

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

.analyzing-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

.processing-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.processing-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.processing-step.active {
    opacity: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-primary);
    transform: scale(1.05);
}

.step-icon {
    font-size: 24px;
}

.step-text {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
}

/* ============================================
   PWA INSTALL BUTTON
   ============================================ */
.install-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 12px;
    box-shadow: var(--shadow-md);
}

.install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 163, 127, 0.3);
}

/* ============================================
   OFFLINE INDICATOR
   ============================================ */
.offline-indicator {
    position: fixed;
    top: 16px;
    right: 16px;
    background: #ef4444;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow-md);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes thinking {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .header {
        padding: 20px 16px;
    }

    .logo {
        font-size: 18px;
    }

    .logo img {
        width: 36px !important;
        height: 36px !important;
    }

    .subtitle {
        font-size: 13px;
    }

    .search-container {
        padding: 16px;
    }

    .search-box {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .search-input {
        padding: 8px 0;
    }

    .search-btn {
        width: 100%;
        padding: 12px;
    }

    .suggestions {
        justify-content: flex-start;
    }

    .processing-steps {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    #answer {
        padding: 24px 16px;
    }

    .empty-state {
        padding: 60px 16px;
    }

    .empty-icon {
        font-size: 48px;
    }

    .install-btn {
        position: fixed;
        bottom: 16px;
        left: 16px;
        right: 16px;
        margin: 0;
        z-index: 50;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 16px;
    }

    .subtitle {
        font-size: 12px;
    }

    .search-input {
        font-size: 15px;
    }

    .processing-steps {
        grid-template-columns: 1fr;
    }

    .processing-step {
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
    }

    .step-text {
        text-align: left;
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

.slide-up {
    animation: slideUp 0.4s ease-out;
}

/* ============================================
   FOOTER
   ============================================ */
.main-footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    padding: 32px 20px 20px;
    margin-top: 60px;
}

.footer-container {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

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

.footer-copyright {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.footer-disclaimer {
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

@media (max-width: 768px) {
    .footer-links {
        flex-direction: column;
        gap: 12px;
    }

    .main-footer {
        margin-top: 40px;
        padding: 24px 20px 16px;
    }
}
