/**
 * Policy Annotation Sidebar Styles
 *
 * Community insights panel for policy documents.
 */

/* ===== Toggle Button ===== */
.annotation-toggle {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-color, #2563eb);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 900;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.annotation-toggle:hover {
    transform: scale(1.05);
    background: var(--accent-hover, #1d4ed8);
}

.annotation-toggle.active {
    background: var(--accent-hover, #1d4ed8);
}

.annotation-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Sidebar Container ===== */
.annotation-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    max-width: 100vw;
    height: 100vh;
    background: var(--surface-color, #ffffff);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.annotation-sidebar.open {
    right: 0;
}

/* ===== Header ===== */
.annotation-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--surface-elevated, #f9fafb);
}

.annotation-sidebar-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary, #111827);
}

.annotation-sidebar-close {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-secondary, #6b7280);
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.annotation-sidebar-close:hover {
    background: var(--hover-bg, #f3f4f6);
}

/* ===== Tab Navigation ===== */
.annotation-sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    margin-bottom: 0;
    flex-shrink: 0;
    background: var(--surface-color, #ffffff);
}

.annotation-sidebar-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: all 0.15s ease;
}

.annotation-sidebar-tab svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.annotation-sidebar-tab:hover {
    color: var(--text-primary, #111827);
    background: var(--hover-bg, #f3f4f6);
}

.annotation-sidebar-tab.active {
    color: var(--accent-color, #2563eb);
    border-bottom-color: var(--accent-color, #2563eb);
    background: transparent;
}

.annotation-sidebar-tab.active svg {
    color: var(--accent-color, #2563eb);
}

/* ===== Filters ===== */
.annotation-sidebar-filters {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.filter-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    border-color: var(--accent-color, #2563eb);
    color: var(--accent-color, #2563eb);
}

.filter-btn.active {
    background: var(--accent-color, #2563eb);
    border-color: var(--accent-color, #2563eb);
    color: white;
}

/* ===== Content Area ===== */
.annotation-sidebar-content {
    flex: 1;
    min-height: 0; /* Allow shrinking below content size */
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.annotation-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===== Empty State ===== */
.annotation-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-tertiary, #9ca3af);
}

.annotation-empty p {
    margin: 0.5rem 0 0;
}

.annotation-empty-cta {
    font-size: 0.875rem;
    color: var(--accent-color, #2563eb);
}

/* ===== Loading State ===== */
.annotation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e5e7eb);
    border-top-color: var(--accent-color, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== Annotation Card ===== */
.annotation-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 1rem;
    transition: box-shadow 0.2s ease;
}

.annotation-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.annotation-card.expert {
    border-color: var(--accent-color, #2563eb);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.02), transparent);
}

.annotation-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.annotation-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
}

.annotation-type {
    font-size: 1rem;
}

.annotation-author {
    font-weight: 500;
    color: var(--text-primary, #111827);
}

.verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: var(--accent-color, #2563eb);
    color: white;
    border-radius: 50%;
    font-size: 9px;
    margin-left: 2px;
}

.annotation-time {
    color: var(--text-tertiary, #9ca3af);
}

.expert-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* ===== Annotation Content ===== */
.annotation-title {
    margin: 0 0 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.annotation-content {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary, #374151);
    white-space: pre-wrap;
}

.annotation-quote {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--quote-bg, #f9fafb);
    border-left: 3px solid var(--accent-color, #2563eb);
    font-size: 0.8125rem;
    color: var(--text-secondary, #6b7280);
    font-style: italic;
}

.quote-mark {
    font-size: 1.25rem;
    color: var(--accent-color, #2563eb);
    opacity: 0.5;
}

.annotation-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.annotation-link {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: var(--link-bg, #eff6ff);
    color: var(--accent-color, #2563eb);
    font-size: 0.75rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.annotation-link:hover {
    background: var(--link-hover-bg, #dbeafe);
}

/* ===== Actions ===== */
.annotation-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.vote-buttons {
    display: flex;
    gap: 0.5rem;
}

.vote-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 4px;
    color: var(--text-tertiary, #9ca3af);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vote-btn:hover {
    border-color: var(--text-secondary, #6b7280);
    color: var(--text-secondary, #6b7280);
}

.vote-btn.voted.vote-up {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.vote-btn.voted.vote-down {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.action-buttons {
    display: flex;
    gap: 0.25rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-tertiary, #9ca3af);
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--hover-bg, #f3f4f6);
    color: var(--text-secondary, #6b7280);
}

/* ===== Replies ===== */
.show-replies {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--accent-color, #2563eb);
    font-size: 0.8125rem;
    cursor: pointer;
    text-align: left;
}

.show-replies:hover {
    text-decoration: underline;
}

.annotation-replies {
    display: none;
    margin-top: 0.75rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color, #e5e7eb);
}

.annotation-replies.expanded {
    display: block;
}

.annotation-reply {
    padding: 0.5rem 0;
}

.annotation-reply + .annotation-reply {
    border-top: 1px solid var(--border-light, #f3f4f6);
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
}

.reply-author {
    font-weight: 500;
    color: var(--text-primary, #111827);
}

.reply-time {
    color: var(--text-tertiary, #9ca3af);
}

.reply-content {
    font-size: 0.8125rem;
    color: var(--text-secondary, #374151);
    line-height: 1.4;
}

.nested-replies {
    margin-top: 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--border-light, #e5e7eb);
}

/* Reply Form */
.reply-form-container {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.reply-form-container textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 4px;
    font-size: 0.875rem;
    resize: vertical;
    font-family: inherit;
}

.reply-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.reply-form-actions button {
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    cursor: pointer;
}

.cancel-reply {
    background: transparent;
    border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-secondary, #6b7280);
}

.submit-reply {
    background: var(--accent-color, #2563eb);
    border: none;
    color: white;
}

/* ===== Footer ===== */
.annotation-sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    background: var(--surface-elevated, #f9fafb);
}

.add-annotation-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--accent-color, #2563eb);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.add-annotation-btn:hover {
    background: var(--accent-hover, #1d4ed8);
}

/* ===== New Annotation Form ===== */
.annotation-form-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface-color, #ffffff);
    overflow-y: auto;
}

.annotation-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.annotation-form-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.annotation-form-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-tertiary, #9ca3af);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.annotation-form {
    padding: 1.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary, #111827);
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.expert-fields label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.btn-cancel {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-cancel:hover {
    background: var(--hover-bg, #f3f4f6);
}

.btn-submit {
    flex: 1;
    padding: 0.75rem;
    background: var(--accent-color, #2563eb);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-submit:hover {
    background: var(--accent-hover, #1d4ed8);
}

.btn-submit:disabled {
    background: var(--text-tertiary, #9ca3af);
    cursor: not-allowed;
}

/* ===== Toast Notifications ===== */
.annotation-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.25rem;
    background: #1f2937;
    color: white;
    border-radius: 8px;
    font-size: 0.875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    opacity: 0;
    transition: all 0.3s ease;
}

.annotation-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.annotation-toast.error {
    background: #ef4444;
}

/* ===== Error State ===== */
.annotation-error {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary, #6b7280);
}

.annotation-error button {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--accent-color, #2563eb);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
    .annotation-sidebar {
        width: 100vw;
        right: -100vw;
    }

    .annotation-toggle {
        right: 16px;
        bottom: 80px;
    }
}

/* ===== Inline Annotation Markers ===== */
.annotation-marker {
    background: linear-gradient(to bottom, rgba(37, 99, 235, 0.15), rgba(37, 99, 235, 0.08));
    border-bottom: 2px solid var(--accent-color, #2563eb);
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease;
}

.annotation-marker:hover {
    background: rgba(37, 99, 235, 0.25);
}

.annotation-marker.expert-marker {
    background: linear-gradient(to bottom, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.08));
    border-bottom-color: #f59e0b;
}

.annotation-marker.expert-marker:hover {
    background: rgba(245, 158, 11, 0.25);
}

.annotation-indicator {
    position: absolute;
    top: -8px;
    right: -4px;
    font-size: 10px;
    pointer-events: none;
}

.annotation-marker.pulse {
    animation: marker-pulse 0.5s ease-in-out 3;
}

@keyframes marker-pulse {
    0%, 100% { background: rgba(37, 99, 235, 0.15); }
    50% { background: rgba(37, 99, 235, 0.4); }
}

/* Selection Popup */
.annotation-selection-popup {
    background: var(--surface-color, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.25rem;
}

.create-annotation-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--accent-color, #2563eb);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.create-annotation-btn:hover {
    background: var(--accent-hover, #1d4ed8);
}

/* Highlighted annotation card */
.annotation-card.highlighted {
    animation: card-highlight 0.5s ease-in-out 2;
}

@keyframes card-highlight {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
    50% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3); }
}

/* ===== Exploration Suggestions ===== */
.exploration-suggestions {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--surface-elevated, #f9fafb);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e5e7eb);
}

.exploration-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary, #6b7280);
    font-size: 0.8125rem;
}

.exploration-icon {
    display: flex;
    color: var(--accent-color, #2563eb);
}

.exploration-title {
    font-weight: 500;
}

.exploration-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.exploration-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.625rem 0.875rem;
    background: var(--surface-color, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.exploration-item:hover {
    border-color: var(--accent-color, #2563eb);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.exploration-item-title {
    font-size: 0.875rem;
    color: var(--text-primary, #111827);
    flex: 1;
}

.exploration-item-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-tertiary, #9ca3af);
}

.exploration-count {
    white-space: nowrap;
}

.exploration-bar {
    width: 50px;
    height: 4px;
    background: var(--border-color, #e5e7eb);
    border-radius: 2px;
    overflow: hidden;
}

.exploration-bar-fill {
    height: 100%;
    background: var(--accent-color, #2563eb);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ===== Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
    .annotation-sidebar {
        --surface-color: #1f2937;
        --surface-elevated: #111827;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-tertiary: #9ca3af;
        --border-color: #374151;
        --border-light: #4b5563;
        --hover-bg: #374151;
        --card-bg: #111827;
        --quote-bg: #374151;
        --link-bg: rgba(37, 99, 235, 0.2);
        --link-hover-bg: rgba(37, 99, 235, 0.3);
    }

    .annotation-card {
        border-color: var(--border-color);
    }

    .annotation-card.expert {
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), transparent);
    }
}
