/**
 * FLY Sales Bot Styles
 * Mobile-first responsive design with FLY branding
 */

/* ===== RESET & BASE STYLES ===== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333333;
    background-color: #F5F5F5;
    overflow: hidden;
}

/* ===== LAYOUT ===== */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    background-color: #FFFFFF;
}

.app-header {
    flex-shrink: 0;
    padding: 1rem;
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    height: 32px;
    width: auto;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-footer {
    flex-shrink: 0;
    padding: 1rem;
    background-color: #FFFFFF;
    border-top: 1px solid #E0E0E0;
    /* Safe area for iOS notch */
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* ===== WELCOME MESSAGE ===== */

.welcome-message {
    text-align: center;
    padding: 2rem 1rem;
    color: #666666;
}

.welcome-message h2 {
    font-size: 1.5rem;
    color: #4A90E2;
    margin-bottom: 0.5rem;
}

.welcome-message p {
    font-size: 1rem;
    color: #666666;
}

/* ===== MESSAGES ===== */

.message {
    display: flex;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease-in;
}

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

.user-message {
    justify-content: flex-end;
}

.assistant-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.assistant-message .message-content {
    max-width: 95%;
}

.user-message .message-content {
    background-color: #4A90E2;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.assistant-message .message-content {
    background-color: #F5F5F5;
    color: #333333;
    border-bottom-left-radius: 0.25rem;
}

/* Markdown rendering */
.message-content h1, .message-content h2, .message-content h3 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content ul, .message-content ol {
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.message-content code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.75rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
}

/* Hide raw mermaid code during streaming, show placeholder */
.message-content.streaming pre.mermaid-pending code {
    display: none;
}

.message-content.streaming pre.mermaid-pending {
    position: relative;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
    border: 1px dashed #b0c4de;
}

.message-content.streaming pre.mermaid-pending::after {
    content: "Rendering diagram\2026";
    color: #6b7c93;
    font-style: italic;
    font-size: 0.9rem;
}

/* Inline mermaid container (rendered diagrams) */
.inline-mermaid-container {
    margin: 0.75rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
}

.message-content a {
    color: #4A90E2;
    text-decoration: underline;
}

/* ===== ARTIFACTS ===== */

.artifact {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 0.75rem;
    background-color: #FFFFFF;
    border: 1px solid #E0E0E0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Concept Card */
.concept-card {
    border-left: 4px solid #4A90E2;
}

.concept-header {
    margin-bottom: 1rem;
}

.concept-number {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    background-color: #4A90E2;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.concept-title {
    font-size: 1.25rem;
    color: #333333;
    margin: 0;
}

.concept-diagram-container {
    margin-top: 1rem;
    overflow: visible;
}

.concept-diagram-container svg {
    width: 100%;
    height: auto;
    display: block;
}

.concept-diagram {
    width: 100%;
    height: auto;
    border-radius: 0.5rem;
    display: block;
}

.diagram-placeholder {
    padding: 2rem;
    text-align: center;
    color: #999999;
    background-color: #F5F5F5;
    border-radius: 0.5rem;
}

/* Testimonial Card */
.testimonial-card {
    border-left: 4px solid #F39C12;
    background: linear-gradient(135deg, #FFF8F0 0%, #FFFFFF 100%);
}

.testimonial-quote {
    font-size: 1.125rem;
    font-style: italic;
    color: #333333;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.quote-mark {
    color: #F39C12;
    font-size: 1.5rem;
    font-weight: bold;
}

.testimonial-source {
    font-weight: 600;
    color: #666666;
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
}

.testimonial-context {
    color: #666666;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Progress Card */
.progress-card {
    border-left: 4px solid #9B59B6;
    background: linear-gradient(135deg, #F9F5FF 0%, #FFFFFF 100%);
}

.progress-header {
    font-size: 1rem;
    font-weight: 600;
    color: #9B59B6;
    margin-bottom: 0.5rem;
}

.progress-stage {
    font-size: 1.125rem;
    color: #333333;
    margin-bottom: 0.75rem;
}

.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.progress-bar {
    flex: 1;
    height: 0.5rem;
    background-color: #E0E0E0;
    border-radius: 0.25rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #9B59B6 0%, #8E44AD 100%);
    border-radius: 0.25rem;
    transition: width 0.5s ease-in-out;
}

.progress-percentage {
    font-size: 0.875rem;
    font-weight: 600;
    color: #9B59B6;
    min-width: 3rem;
    text-align: right;
}

.progress-next {
    font-size: 0.9375rem;
    color: #666666;
}

.progress-next strong {
    color: #333333;
}

/* CTA Card */
.cta-card {
    border-left: 4px solid #F39C12;
    background: linear-gradient(135deg, #FFF8F0 0%, #FFFFFF 100%);
    text-align: center;
}

.cta-headline {
    font-size: 1.25rem;
    color: #333333;
    margin-bottom: 1rem;
}

.cta-button {
    display: inline-block;
    padding: 0.875rem 1.75rem;
    min-height: 44px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.cta-book {
    background-color: #F39C12;
    color: white;
}

.cta-book:hover {
    background-color: #E67E22;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(243, 156, 18, 0.3);
}

.cta-event {
    background-color: #4A90E2;
    color: white;
}

.cta-event:hover {
    background-color: #357ABD;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3);
}

/* ===== TYPING INDICATOR ===== */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0 1rem 1rem 1rem;
    background-color: #F5F5F5;
    border-radius: 1rem;
    width: fit-content;
    max-width: 80px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #666666;
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ===== CHAT FORM ===== */

.chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 16px; /* Prevent iOS zoom on focus */
    border: 1px solid #E0E0E0;
    border-radius: 1.5rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.chat-input:disabled {
    background-color: #F5F5F5;
    cursor: not-allowed;
}

.send-button {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4A90E2;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.send-button:hover:not(:disabled) {
    background-color: #357ABD;
    transform: scale(1.05);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.send-button:disabled {
    background-color: #CCCCCC;
    cursor: not-allowed;
}

/* ===== ERROR CONTAINER ===== */

.error-container {
    padding: 0.75rem 1rem;
    margin: 0 1rem 1rem 1rem;
    background-color: #FFF5F5;
    border: 1px solid #E74C3C;
    border-radius: 0.5rem;
    color: #E74C3C;
    font-size: 0.9375rem;
}

/* ===== SCROLLBAR STYLING ===== */

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

/* ===== MODAL CONTAINER ===== */

.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet (768px+) */
@media (min-width: 768px) {
    .app-container {
        max-width: 768px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }

    .app-title {
        font-size: 1.5rem;
    }

    .welcome-message h2 {
        font-size: 1.75rem;
    }

    .user-message .message-content {
        max-width: 70%;
    }

    .assistant-message .message-content {
        max-width: 95%;
    }

    .chat-messages {
        padding: 1.5rem;
    }

    .chat-footer {
        padding: 1.5rem;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .app-container {
        max-width: 900px;
    }

    body {
        font-size: 18px;
    }

    .user-message .message-content {
        max-width: 60%;
    }

    .assistant-message .message-content {
        max-width: 95%;
    }

    .chat-messages {
        padding: 2rem;
    }

    .chat-footer {
        padding: 1.5rem 2rem;
    }

    .artifact {
        padding: 1.5rem;
    }
}

/* ===== ACCESSIBILITY ===== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.chat-input:focus,
.send-button:focus,
.cta-button:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* Skip to content link for keyboard navigation */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #4A90E2;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* ===== SOURCES PANEL ===== */

/* Sources toggle button on assistant messages */
.sources-toggle {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    font-size: 0.8rem;
    color: #4A90E2;
    background: rgba(74, 144, 226, 0.08);
    border: 1px solid rgba(74, 144, 226, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sources-toggle:hover {
    background: rgba(74, 144, 226, 0.15);
    border-color: #4A90E2;
}

/* Sources slide-out pane */
.sources-pane {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 100%;
    height: 100%;
    background-color: #FFFFFF;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
    z-index: 999;
    display: flex;
    flex-direction: column;
    animation: sourcesSlideIn 0.3s ease-out;
}

@keyframes sourcesSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.sources-pane-header {
    position: sticky;
    top: 0;
    background-color: #FFFFFF;
    border-bottom: 2px solid #E0E0E0;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.sources-pane-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333333;
    margin: 0;
}

.sources-pane-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
}

.sources-pane-close:hover {
    color: #333333;
}

.sources-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Source card */
.source-card {
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #FFFFFF;
}

.source-card:hover {
    border-color: #4A90E2;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.15);
}

.source-card:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

.source-card-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Rank badge */
.source-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #FFFFFF;
    background-color: #BDC3C7;
}

.source-rank.rank-gold { background-color: #F39C12; }
.source-rank.rank-silver { background-color: #95A5A6; }
.source-rank.rank-bronze { background-color: #CD7F32; }

/* Source file name */
.source-file {
    font-size: 0.85rem;
    font-weight: 500;
    color: #333333;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Content type pill */
.source-type-pill {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.7rem;
    color: #666666;
    background: #F5F5F5;
    border: 1px solid #E0E0E0;
    border-radius: 10px;
    text-transform: lowercase;
}

/* Score */
.source-score {
    font-size: 0.75rem;
    color: #666666;
    font-weight: 500;
}

/* Topic tags */
.source-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.source-tag {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.65rem;
    color: #4A90E2;
    background: rgba(74, 144, 226, 0.08);
    border-radius: 8px;
}

/* Source detail overlay + panel */
.source-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    display: flex;
    justify-content: flex-end;
}

.source-detail-panel {
    width: 480px;
    max-width: 100%;
    height: 100%;
    background-color: #FFFFFF;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    animation: sourcesSlideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.source-detail-header {
    position: sticky;
    top: 0;
    background-color: #FFFFFF;
    border-bottom: 2px solid #E0E0E0;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.source-detail-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333333;
    margin: 0;
}

.source-detail-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #666666;
    cursor: pointer;
    padding: 0;
}

.source-detail-close:hover {
    color: #333333;
}

.source-detail-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.source-detail-section {
    margin-bottom: 24px;
}

.source-detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: #333333;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #E0E0E0;
}

/* Metadata definition list */
.source-meta-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 4px 12px;
    font-size: 0.85rem;
}

.source-meta-list dt {
    color: #666666;
    font-weight: 500;
}

.source-meta-list dd {
    color: #333333;
    margin: 0;
}

/* Content block */
.source-content-block {
    background: #F8F9FA;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    padding: 12px;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* Graph edges */
.source-edges-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.source-edge-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #F8F9FA;
    border-radius: 6px;
    font-size: 0.8rem;
}

.source-edge-type {
    display: inline-block;
    padding: 1px 8px;
    font-size: 0.7rem;
    color: #FFFFFF;
    background: #9B59B6;
    border-radius: 10px;
    min-width: 50px;
    text-align: center;
}

.source-edge-file {
    flex: 1;
    color: #333333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-edge-weight {
    color: #999999;
    font-size: 0.7rem;
}

/* Loading/error states */
.source-loading, .source-error {
    text-align: center;
    padding: 40px 20px;
    color: #666666;
    font-size: 0.9rem;
}

.source-error {
    color: #E74C3C;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .sources-pane {
        width: 100%;
    }

    .source-detail-panel {
        width: 100%;
    }

    .source-meta-list {
        grid-template-columns: 100px 1fr;
    }
}
