/* Base styles for Kula Social App */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Clickable username styles */
.username-link {
    color: #4a6fa5;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.username-link:hover {
    color: #3d5a91;
    text-decoration: underline;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
}

header {
    background-color: #4a6fa5;
    color: white;
    padding: 1rem 0;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    flex-wrap: wrap;
}

.nav-links {
    display: flex;
    list-style: none;
}

.nav-links li {
    margin-left: 1.5rem;
}

.nav-links a {
    color: white;
    text-decoration: none;
    font-weight: 500;
}

.nav-links a:hover {
    text-decoration: underline;
}

.logo h1 a, .logo h1 a:visited, .logo h1 a:hover, .logo h1 a:active {
    color: white;
    text-decoration: none;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    min-height: calc(100vh - 180px);
}

footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 1rem 0;
}

/* Form styles */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
}

input, textarea, select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
}

button {
    background-color: #4a6fa5;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

/* Card styles */
.card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card-title {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

/* Auth navigation */
.auth-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* User greeting link */
header nav .auth-nav .user-greeting {
    font-size: 0.9rem;
    color: white !important;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: opacity 0.2s;
}

header nav .auth-nav .user-greeting:hover {
    opacity: 0.85;
}

header nav .auth-nav .user-greeting sl-icon {
    font-size: 1.1rem;
}

/* Shoelace button overrides for navigation */
.auth-nav sl-button.login-btn::part(base) {
    color: white;
    font-weight: 500;
}

.auth-nav sl-button.login-btn::part(base):hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.auth-nav sl-button.signup-btn::part(base),
.auth-nav sl-button.logout-btn::part(base) {
    background-color: white;
    color: #4a6fa5;
    border-color: white;
    font-weight: 500;
}

.auth-nav sl-button.signup-btn::part(base):hover,
.auth-nav sl-button.logout-btn::part(base):hover {
    background-color: #f0f0f0;
}

/* Nav links with icons */
.nav-links a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-links sl-icon {
    font-size: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
    }

    .nav-links {
        margin-top: 1rem;
    }

    .nav-links li {
        margin: 0 0.5rem;
    }

    .auth-nav {
        margin-top: 1rem;
        justify-content: center;
        width: 100%;
    }
}

/* Article Detail Page Styles */
.article-detail-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 30px;
}

.article-content, .article-sidebar > div {
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #e1e1e1;
    padding: 20px;
    margin-bottom: 20px;
}

.article-header {
    margin-bottom: 30px;
}

.article-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.category-tag {
    font-size: 0.8rem;
    padding: 3px 10px;
    background-color: #f0f0f0;
    border-radius: 20px;
    color: #444;
    text-decoration: none;
}

.article-header h1 {
    margin: 0 0 15px 0;
    font-size: 1.8rem;
    line-height: 1.3;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 20px;
    align-items: center;
}

.article-submitters {
    font-size: 0.9rem;
    color: #666;
    margin-top: 5px;
    width: 100%;
}

.article-submitters a {
    color: #4a6fa5;
    text-decoration: none;
}

.article-submitters a:hover {
    text-decoration: underline;
}

.trust-score {
    font-size: 0.8rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.trust-score.high {
    background-color: #d4edda;
    color: #155724;
}

.trust-score.medium {
    background-color: #fff3cd;
    color: #856404;
}

.trust-score.low {
    background-color: #f8d7da;
    color: #721c24;
}

.article-summary {
    background-color: #f9f9f9;
    border-left: 4px solid #4a6fa5;
    padding: 15px;
    margin-bottom: 30px;
}

.article-summary h3 {
    margin-top: 0;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.article-summary p {
    margin: 0;
    color: #333;
    font-size: 1rem;
    line-height: 1.5;
}

.article-body {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #333;
    margin-bottom: 30px;
}

.article-source-link {
    margin: 20px 0;
}

.article-source-link a {
    color: #4a6fa5;
    text-decoration: none;
    font-weight: 500;
}

.article-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.comment-section {
    margin-top: 30px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
}

.comment-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: #333;
}

.share-notice {
    color: #666;
    font-style: italic;
    margin: 0;
}

.related-articles h3, .more-categories h3 {
    margin-top: 0;
    font-size: 1.2rem;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.related-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.related-list li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

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

.related-list a {
    display: block;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 5px;
}

.related-list a:hover {
    color: #4a6fa5;
}

.related-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #777;
}

.trust-pill {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.trust-pill.high {
    background-color: #d4edda;
    color: #155724;
}

.trust-pill.medium {
    background-color: #fff3cd;
    color: #856404;
}

.trust-pill.low {
    background-color: #f8d7da;
    color: #721c24;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.category-box {
    background-color: #f5f5f5;
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
}

.category-box:hover {
    background-color: #e0e0e0;
}

.view-all-btn {
    width: 100%;
    text-align: center;
    margin-top: 10px;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    background-color: #f0f0f0;
    color: #333;
    border: none;
}

.primary-btn {
    background-color: #4a6fa5;
    color: white;
}

.secondary-btn {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 24px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.formatting-help {
    display: block;
    margin-top: 5px;
    font-size: 0.8em;
    color: #666;
}

@media (max-width: 768px) {
    .article-detail-container {
        grid-template-columns: 1fr;
    }
}

/* Group Detail Page Styles */
.group-detail-container {
    padding-top: 20px;
}

.group-header {
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #e1e1e1;
    padding: 20px;
    margin-bottom: 20px;
}

.group-description {
    margin: 15px 0;
    line-height: 1.6;
}

.group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 10px 0;
    font-size: 0.9em;
    color: #666;
}

.group-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.group-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.message-section, .sidebar {
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #e1e1e1;
    padding: 20px;
}

.message-form {
    margin: 20px 0;
}

.message-card {
    border-bottom: 1px solid #eee;
    padding: 15px 0;
}

.message-reply {
    margin-left: 30px;
    border-left: 3px solid #4a6fa5;
    padding-left: 15px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-time {
    font-size: 0.85em;
    color: #777;
    font-weight: normal;
    cursor: help;
}

.message-author {
    font-weight: 600;
}

.message-actions-header {
    display: flex;
    gap: 8px;
}

.message-content {
    line-height: 1.5;
}

/* Shared Article Styling in Groups */
.shared-article-container {
    margin-top: 10px;
}

.article-card-inline {
    background-color: #f9f9f9;
    border: 1px solid #e1e1e1;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.article-meta-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.article-card-inline h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    line-height: 1.3;
}

.article-card-inline h4 a {
    color: #333;
    text-decoration: none;
}

.article-card-inline h4 a:hover {
    color: #4a6fa5;
    text-decoration: underline;
}

.article-card-inline .article-summary {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 8px;
    line-height: 1.4;
}

.article-footer-inline {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #777;
}

.share-comment {
    margin-top: 8px;
}

.share-comment .markdown-content {
    margin: 0;
    font-size: 0.95rem;
}

.reply-btn, .edit-btn, .delete-btn {
    background: none;
    border: none;
    font-size: 0.9em;
    color: #4a6fa5;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    display: inline-block;
    margin-right: 8px;
}

.delete-btn {
    color: #dc3545;
}

.message-replies {
    margin-top: 15px;
    margin-left: 20px;
    border-left: 2px solid #eee;
    padding-left: 15px;
}

.reply-card {
    padding: 10px 0;
}

.invite-requests-section {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.invite-requests-section h3 {
    margin-top: 0;
    color: #856404;
    font-size: 1rem;
}

.invite-requests-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.invite-request-card {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px;
}

.invite-request-card .request-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}

.invite-request-card .request-time {
    font-size: 0.8em;
    color: #888;
}

.invite-request-card .request-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.85em;
}

.members-section {
    margin-bottom: 20px;
}

.members-list {
    list-style: none;
    padding: 0;
}

.members-list li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.role-badge {
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 10px;
}

.role-badge.admin {
    background-color: #4a6fa5;
    color: white;
}

.role-badge.member {
    background-color: #eee;
    color: #666;
}

.sidebar-actions {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    text-align: center;
}

.leave-btn {
    width: 100%;
    margin-top: 10px;
    font-size: 0.9em;
}

.admin-badge {
    background-color: #4a6fa5;
    color: white;
    font-size: 0.8em;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 10px;
}

.login-prompt {
    font-size: 0.9em;
    color: #777;
}

.no-messages {
    color: #777;
    font-style: italic;
    text-align: center;
    margin: 30px 0;
}

@media (max-width: 768px) {
    .group-content {
        grid-template-columns: 1fr;
    }
}

/* Analysis Section Styles */
.analysis-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #eee;
}

.analysis-section h2 {
    margin-bottom: 20px;
    font-size: 1.5em;
}

.analysis-form-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.analysis-form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.analysis-form-row .form-select {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
}

.analysis-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    color: #666;
    font-size: 0.9em;
}

.analysis-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.analysis-result-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.analysis-result-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.analysis-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.analysis-result-header h4 {
    margin: 0;
    font-size: 1em;
    font-weight: 600;
}

.status-badge {
    font-size: 0.75em;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-complete {
    background: #d4edda;
    color: #155724;
}

.status-processing {
    background: #fff3cd;
    color: #856404;
}

.status-pending {
    background: #e2e3e5;
    color: #383d41;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

.analysis-result-body {
    padding: 16px;
    min-height: 80px;
}

.analysis-result-body .error-message {
    color: #dc3545;
    font-size: 0.9em;
}

.analysis-result-body .processing-message,
.analysis-result-body .queued-message {
    color: #666;
    font-size: 0.9em;
}

.analysis-result-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85em;
}

.analysis-date {
    color: #888;
}

.view-details-link {
    color: #4a6fa5;
    text-decoration: none;
    font-weight: 500;
}

.view-details-link:hover {
    text-decoration: underline;
}

.no-analyses-message {
    color: #666;
    font-style: italic;
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    border-radius: 8px;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #4a6fa5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #ddd;
    border-top-color: #4a6fa5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .analysis-form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .analysis-form-row .form-select {
        max-width: none;
    }

    .analysis-results-grid {
        grid-template-columns: 1fr;
    }
}