/**
 * Jleddit Answers - Styles
 * Reddit Answers-style Q&A interface
 */

/* ===================================
   Search Bar Enhancements
   =================================== */

.search-container.enhanced {
    position: relative;
}

.search-mode-indicator {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(calc(-50% + 3px));
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.search-container.enhanced:focus-within .search-mode-indicator,
.search-container.enhanced.has-query .search-mode-indicator {
    opacity: 1;
}

.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mode-badge.ai-mode {
    background: transparent;
    padding: 0;
}

.mode-badge.search-mode {
    background: var(--color-border);
    color: var(--color-text-secondary);
}

.mode-badge svg {
    width: 24px;
    height: 24px;
}

/* Search Suggestions Dropdown */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 12px;
    margin-top: 4px;
    z-index: 100;
    display: none;
}

.search-container.enhanced:focus-within .search-suggestions {
    display: block;
}

.search-container.enhanced.has-query .search-suggestions {
    display: none;
}

.suggestion-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestion-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    margin: 4px 0;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: #FF4500;
    color: white;
    border-color: #FF4500;
}

/* ===================================
   Answers Panel (alongside nav/sidebar)
   =================================== */

.answers-panel {
    position: fixed;
    top: var(--header-height, 56px);
    left: var(--sidebar-width, 240px);
    right: 0;
    bottom: 0;
    z-index: 100;
    display: none;
    flex-direction: column;
    background: white;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.answers-panel.active {
    display: flex;
}

.answers-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Simple Header - Back button + New question */
.answers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    background: white;
    flex-shrink: 0;
}

.answers-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-text);
    transition: all 0.2s ease;
}

.answers-back:hover {
    background: var(--color-border);
}

.answers-back svg {
    width: 20px;
    height: 20px;
}

.answers-new-question {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.answers-new-question:hover {
    background: var(--color-background);
}

.answers-new-question svg {
    width: 18px;
    height: 18px;
}

/* Hide old header elements */
.answers-logo,
.answers-close {
    display: none;
}

/* Answers Body */
.answers-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    justify-content: center;
}

.answers-conversation {
    width: 100%;
    max-width: 800px;
    padding: 24px 32px;
}

/* Welcome State */
.answers-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    min-height: 400px;
}

.answers-welcome h3 {
    font-size: 24px;
    color: var(--color-text);
    margin-bottom: 12px;
}

.answers-welcome p {
    color: var(--color-text-secondary);
    margin-bottom: 32px;
    font-size: 16px;
    max-width: 400px;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.welcome-suggestion {
    padding: 10px 18px;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 24px;
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.welcome-suggestion:hover {
    background: #FF4500;
    color: white;
    border-color: #FF4500;
}

/* Question Title */
.question-title {
    font-size: 26px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 16px;
    line-height: 1.3;
}

/* Sources Row */
.sources-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-background);
    border-radius: 24px;
    margin-bottom: 24px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sources-row:hover {
    background: #f0f0f0;
}

.sources-avatars {
    display: flex;
}

.sources-avatars .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    margin-left: -8px;
    background: var(--color-border);
}

.sources-avatars .avatar:first-child {
    margin-left: 0;
}

.sources-text {
    flex: 1;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.sources-text strong {
    color: var(--color-text);
}

.sources-arrow {
    color: var(--color-text-secondary);
    font-size: 18px;
    transition: transform 0.2s ease;
}

/* Expanded sources list */
.sources-expanded {
    display: none;
    padding: 12px 0;
}

.sources-expanded.expanded {
    display: block;
}

.sources-row:has(+ .sources-expanded.expanded) .sources-arrow {
    transform: rotate(90deg);
}

/* Answer Content */
.answer-content {
    font-size: 16px;
    line-height: 1.8;
    color: var(--color-text);
}

.answer-content h2,
.answer-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 28px 0 16px 0;
    color: var(--color-text);
}

.answer-content h2:first-child,
.answer-content h3:first-child {
    margin-top: 0;
}

.answer-content p {
    margin-bottom: 16px;
}

.answer-content ul,
.answer-content ol {
    margin: 16px 0;
    padding-left: 0;
    list-style: none;
}

.answer-content li {
    margin-bottom: 16px;
    padding-left: 20px;
    position: relative;
}

.answer-content li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--color-text-secondary);
}

.answer-content strong {
    font-weight: 600;
}

/* Source Links in Content */
.source-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #FF4500;
    text-decoration: none;
    font-size: 14px;
}

.source-link:hover {
    text-decoration: underline;
}

.source-link .arrow {
    font-size: 12px;
    opacity: 0.7;
}

/* Nested source links list */
.answer-content li ul {
    margin: 8px 0 0 0;
}

.answer-content li ul li {
    margin-bottom: 6px;
    padding-left: 0;
}

.answer-content li ul li::before {
    display: none;
}

/* Citations in text */
.citation {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #FF4500;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    margin: 0 2px;
    vertical-align: super;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.citation:hover {
    transform: scale(1.2);
}

/* Loading state */
.answer-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 0;
    color: var(--color-text-secondary);
}

.loading-dots {
    display: flex;
    gap: 4px;
}

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

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

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

/* Follow-up Input */
.followup-input-container {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.followup-label {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

/* Demo notice */
.demo-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 10px;
    padding: 14px;
    margin-top: 24px;
    font-size: 13px;
    color: #856404;
}

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

/* Hide old elements */
.question-bubble,
.answer-bubble,
.answers-input-container {
    display: none;
}

/* Followup Suggestions Chips */
.followup-suggestions {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.followup-suggestions .followup-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.followup-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.followup-chip {
    padding: 10px 18px;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 24px;
    font-size: 14px;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.followup-chip:hover {
    background: #FF4500;
    color: white;
    border-color: #FF4500;
}

/* Input shown in welcome state only */
.answers-welcome + .answers-input-area,
.input-mode .answers-input-area {
    display: flex;
}

.answers-input-area {
    display: none;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
    padding: 24px;
}

.answers-input-area .answers-input {
    flex: 1;
    padding: 14px 20px;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 28px;
    font-size: 15px;
    transition: all 0.2s ease;
}

.answers-input-area .answers-input:focus {
    outline: none;
    border-color: #FF4500;
    background: white;
}

.answers-input-area .answers-send {
    width: 52px;
    height: 52px;
    background: #FF4500;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.answers-input-area .answers-send:hover {
    background: #e03d00;
}

/* ===================================
   Responsive Styles
   =================================== */

@media (max-width: 1200px) {
    .answers-panel {
        left: 72px; /* Collapsed sidebar width */
    }
}

@media (max-width: 768px) {
    .answers-panel {
        left: 0;
        top: var(--header-height, 56px);
    }

    .answers-header {
        padding: 10px 16px;
    }

    .answers-conversation {
        padding: 20px 16px;
    }

    .question-title {
        font-size: 22px;
    }

    .answer-content {
        font-size: 15px;
    }

    .sources-row {
        padding: 10px 14px;
    }

    .search-mode-indicator {
        display: none;
    }
}

@media (max-width: 480px) {
    .question-title {
        font-size: 20px;
    }

    .answer-content {
        font-size: 16px;
        line-height: 1.7;
    }

    .answer-content h2,
    .answer-content h3 {
        font-size: 17px;
    }

    .answers-conversation {
        padding: 16px 12px;
    }

    .followup-chip {
        padding: 12px 16px;
        font-size: 15px;
    }

    .welcome-suggestion {
        padding: 12px 16px;
        font-size: 15px;
    }
}
