/* =====================================================
   MISC COMPONENTS (Cards, Buttons, Agents, Link Display)
   WCAG 2.1 AA Compliant
   ===================================================== */

/* =====================================================
   COMMUNITY CARD
   Uses .post.community-card for specificity over .post base styles
   (CommunityBox.razor uses both classes: <article class="post community-card">)
   ===================================================== */

.post.community-card {
    background: var(--bg-white);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.community-header-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    border-radius: 1rem 1rem 0 0;
    margin: 0;
    max-width: 100%;
}

.community-logo-wrapper {
    position: absolute;
    top: 70px;
    left: 1.5rem;
    width: 128px;
    height: 128px;
    background: white;
    border-radius: 0.5rem;
    padding: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.community-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.community-info {
    padding: 3.5rem 1.5rem 1.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.community-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.community-name {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.community-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.community-action-btn {
    padding: 0.5rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    background: transparent;
    border: none;
    color: var(--primary-color);
    min-width: 44px;
    min-height: 44px;
}

.community-action-btn i {
    font-size: 1.125rem;
}

.community-action-btn:hover {
    background: var(--glass-white);
    color: var(--accent-color);
}

.community-tagline {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    line-height: 1.5;
}

.community-tagline i {
    font-size: var(--font-size-xs);
}

.community-members {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 600;
}

.community-update {
    font-size: var(--font-size-sm);
    line-height: 1.7;
    color: var(--text-primary);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--glass-border);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* =====================================================
   HAMBURGER BUTTON
   ===================================================== */

.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--primary-color);
    margin: 3px 0;
    transition: all 0.3s ease;
}

.hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Hide hamburger on desktop */
@media (min-width: 1250px) {
    .hamburger-btn {
        display: none;
    }
}

/* =====================================================
   LOGIN BUTTON
   Styled as regular button (similar to Ask/Post type buttons)
   ===================================================== */

.login-button {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--primary-color);
    font-size: var(--font-size-sm);
    background: var(--bg-white);
    border: 1px solid var(--glass-border);
    font-family: inherit;
    line-height: 1.5;
    min-height: 44px;
}

.login-button:hover {
    background: rgba(106, 74, 158, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.login-button:focus-visible {
    outline: 3px solid var(--focus-color, var(--primary-color));
    outline-offset: 2px;
}

.login-button i {
    color: var(--primary-color);
}

.login-button span {
    color: var(--primary-color);
    font-weight: 500;
}

/* =====================================================
   SIDEBAR ERROR (ErrorBoundary fallback)
   Graceful error display when sidebar components fail
   ===================================================== */

.sidebar-error {
    background: var(--bg-white);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    box-shadow: 0px 4px 20px 0px rgba(209, 209, 209, 0.15);
}

.sidebar-error i {
    font-size: 2rem;
    color: var(--bs-warning, #ffc107);
    display: block;
    margin-bottom: 0.75rem;
}

.sidebar-error p {
    margin: 0 0 1rem 0;
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.sidebar-error .btn {
    min-height: 36px;
}

/* =====================================================
   COMMUNITY LOGIN ROUTER
   Full-screen sign-in prompt for restricted communities
   WCAG 2.1 AA Compliant
   ===================================================== */

.login-router-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--community-primary, #6A4A9E) 0%, var(--community-accent, #7BCED7) 100%);
    padding: 2rem;
}

.login-router-container {
    position: relative;
    background: var(--bg-white, #ffffff);
    border-radius: 1.5rem;
    box-shadow: 0 16px 56px rgba(0, 0, 0, 0.25);
    width: 75vw;
    max-width: 1200px;
    padding: 3rem 2.5rem;
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
}

.login-router-header {
    margin-bottom: 2rem;
}

.login-router-logo {
    max-width: 160px;
    max-height: 80px;
    object-fit: contain;
}

.login-router-content {
    margin-bottom: 2rem;
}

.login-router-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
    margin: 0 0 0.75rem 0;
    line-height: 1.3;
}

.login-router-tagline {
    font-size: 1rem;
    color: var(--text-secondary, #4B5563);
    margin: 0 0 1rem 0;
    line-height: 1.5;
    font-style: italic;
}

.login-router-description {
    font-size: 0.875rem;
    color: var(--text-primary, #1f2937);
    margin: 0 0 1.5rem 0;
    line-height: 1.7;
}

.login-router-message {
    background: rgba(106, 74, 158, 0.08);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    text-align: left;
}

.login-router-message i {
    font-size: 1.25rem;
    color: var(--community-primary, #6A4A9E);
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.login-router-message p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-primary, #1f2937);
    line-height: 1.6;
}

.login-router-actions {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    justify-content: center;
}

.login-router-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 48px;
    border: none;
    font-family: inherit;
}

.login-router-btn-primary {
    background: var(--community-primary, #6A4A9E);
    color: var(--community-primary-text, #ffffff);
}

.login-router-btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.login-router-btn-secondary {
    background: transparent;
    color: var(--text-secondary, #4B5563);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.login-router-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-primary, #1f2937);
}

.login-router-btn:focus-visible {
    outline: 3px solid var(--community-primary, #6A4A9E);
    outline-offset: 2px;
}

/* =====================================================
   COMMUNITY HELPER AGENT RESPONSE COMPONENT
   AI assistant response card with thinking animation
   WCAG 2.1 AA Compliant
   ===================================================== */

/* Agent response container - uses same .post base styles */
.agent-response {
    margin-bottom: 1rem;
    background-color: color-mix(in srgb, var(--primary-color) 10%, transparent);
}

.agent-response .post-content {
    padding-bottom: 1.5rem;
}

/* Agent avatar - gradient background to stand out */
.agent-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
}

.agent-avatar img {
    padding: 4px;
}

/* Buzzing animation for thinking state */
@keyframes avatar-buzz {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 0 0 rgba(106, 74, 158, 0.4);
    }
    25% {
        transform: scale(1.05) rotate(-2deg);
        box-shadow: 0 0 0 6px rgba(106, 74, 158, 0.2);
    }
    50% {
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 0 12px rgba(106, 74, 158, 0);
    }
    75% {
        transform: scale(1.05) rotate(2deg);
        box-shadow: 0 0 0 6px rgba(106, 74, 158, 0.2);
    }
}

.avatar-buzzing {
    animation: avatar-buzz 1.5s ease-in-out infinite;
}

/* Thinking text styling */
.agent-thinking-text {
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

/* Animated ellipsis for thinking state */
@keyframes thinking-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.agent-thinking-text::after {
    content: '...';
    animation: thinking-dots 1.5s steps(1, end) infinite;
}

/* Response text styling */
.agent-response-text {
    line-height: 1.7;
    font-size: var(--font-size-base, 1rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.agent-response-text p {
    margin: 0 0 1rem 0;
}

.agent-response-text p:last-child {
    margin-bottom: 0;
}

/* Lists in agent response */
.agent-response-text ul,
.agent-response-text ol {
    margin: 0 0 1rem 1.25rem;
    padding: 0;
}

.agent-response-text li {
    margin-bottom: 0.25rem;
}

/* Citation links from RAG */
.agent-response-text a {
    color: var(--accent-text, #1A7A8A);
    text-decoration: none;
}

.agent-response-text a:hover,
.agent-response-text a:focus {
    text-decoration: underline;
}

.agent-response-text a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Code blocks in agent response */
.agent-response-text code {
    background: var(--bg-gray-light, #f9fafb);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.9em;
}

.agent-response-text pre {
    background: var(--bg-gray-light, #f9fafb);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.agent-response-text pre code {
    background: none;
    padding: 0;
}

/* Blockquotes in agent response */
.agent-response-text blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Agent response - Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .avatar-buzzing {
        animation: none;
    }

    .agent-thinking-text::after {
        animation: none;
        content: '...';
    }
}

/* ==================== Link Display Component ==================== */

.link-display {
    display: flex;
    gap: 1rem;
    padding: 0.875rem;
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    background: var(--bg-white);
    text-decoration: none !important;
    color: var(--text-primary);
    transition: all 0.2s ease;
    margin-top: 0.75rem;
}

.link-display:hover {
    border-color: var(--primary-color);
    background: var(--glass-white);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none !important;
}

.link-display:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.link-display-thumbnail {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 0.375rem;
    overflow: hidden;
    background: var(--glass-white);
}

.link-display-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-display-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0; /* Allow text truncation */
}

.link-display-header {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.link-display-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.4;
    text-decoration: none !important;
}

.link-display-type {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: auto;
}

.link-display-type i {
    font-size: 0.75rem;
}

/* Container for link displays in posts */
.post-links {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--glass-border);
}

/* Container for link displays in agent responses */
.agent-links {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--glass-border);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .link-display-thumbnail {
        width: 60px;
        height: 60px;
    }

    .link-display-title {
        font-size: 0.875rem;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .link-display {
        transition: none;
    }

    .link-display:hover {
        transform: none;
    }
}
