/**
 * SourceCard Component Styles - COMPACT REDESIGN
 * OWNER: Frontend team
 * SINGLE SOURCE OF TRUTH for all source card styling
 * 
 * Updated: Compact layout with hover-to-reveal description
 */

/* =============================================================================
   CONTAINER & LAYOUT
   ============================================================================= */

.sources-preview-section {
    margin: 1.5rem 0;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.4s ease-out;
}

/* Dismiss button positioned at top-right */
.source-dismiss-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
    opacity: 0.6;
}

.source-dismiss-btn:hover {
    background: var(--destructive);
    color: white;
    opacity: 1;
}

.source-dismiss-btn svg {
    display: block;
}

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

.preview-header {
    background: linear-gradient(135deg, var(--primary), var(--muted-foreground));
    color: var(--primary-foreground);
    padding: 1.5rem;
    text-align: center;
}

.preview-header h3 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-foreground);
    font-size: 1.25rem;
    font-weight: var(--font-weight-medium);
}

.preview-header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    margin: 0;
}

/* =============================================================================
   LICENSING SUMMARY
   ============================================================================= */

.licensing-summary {
    background: linear-gradient(135deg, #fff7d1 0%, #fff38D 100%);
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.licensing-summary h4 {
    color: var(--accent-foreground);
    margin-bottom: 0.75rem;
    font-weight: var(--font-weight-medium);
}

.licensing-counts {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.licensed-count, .unlicensed-count {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: var(--font-weight-medium);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.licensed-count {
    background: rgba(34, 197, 94, 0.1);
    color: #059669;
    border: 1px solid #10b981;
}

.unlicensed-count {
    background: rgba(249, 115, 22, 0.1);
    color: #ea580c;
    border: 1px solid #f97316;
}

/* =============================================================================
   FILTER CHIPS
   ============================================================================= */

.source-type-filters {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--muted);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}

.filter-label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    font-weight: var(--font-weight-medium);
    margin-right: 0.25rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8125rem;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    border: 1.5px solid transparent;
    background: var(--card);
    color: var(--foreground);
    transition: all 0.15s ease;
    user-select: none;
}

.filter-chip:hover {
    background: var(--accent);
    border-color: var(--primary);
}

.filter-chip.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.filter-chip .count {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.filter-chip.active .count {
    background: rgba(255, 255, 255, 0.2);
}

/* =============================================================================
   COMPACT SOURCE CARD
   ============================================================================= */

.source-card {
    background: var(--card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 12px 16px !important;
    margin-bottom: 8px !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    font-family: 'Montserrat', var(--font-sans, sans-serif) !important;
    min-height: 85px; /* More height to accommodate actions below title */
}

.source-card.filtered-hidden {
    display: none;
}

.source-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.source-card:hover .source-excerpt {
    display: block !important;
}

.source-card:last-child {
    margin-bottom: 0;
}

/* Selected state */
.source-card.selected {
    border-color: var(--primary) !important;
    background-color: var(--primary-light, #f0f9ff) !important;
}

/* =============================================================================
   COMPACT LAYOUT (REORGANIZED)
   ============================================================================= */

.source-card-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

/* Top row: Checkbox + Content */
.source-card-top-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-right: 24px; /* Space for dismiss button */
}

/* Checkbox */
.source-checkbox-compact {
    flex-shrink: 0;
    padding-top: 2px; /* Align with title baseline */
}

.source-selection-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    appearance: none;
}

.source-selection-checkbox:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.source-selection-checkbox:checked::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    font-size: 12px;
    font-weight: bold;
}

.source-selection-checkbox:hover {
    border-color: var(--accent);
}

/* Content */
.source-card-content {
    flex: 1;
    min-width: 0;
}

.source-title {
    color: var(--card-foreground);
    font-size: 15px;
    line-height: 1.4;
    font-weight: 600;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =============================================================================
   METADATA LINE
   ============================================================================= */

.source-metadata-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted-foreground);
    line-height: 1;
}

.meta-domain {
    color: var(--muted-foreground);
}

.meta-separator {
    color: var(--muted-foreground);
    opacity: 0.5;
}

.meta-license {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
}

.meta-license.license-free {
    color: #059669;
}

.meta-license.license-paid {
    color: #2563eb;
}

.meta-license.license-demo {
    color: #8b5cf6;
}

.meta-license.license-loading {
    color: #6b7280;
}

.meta-rating {
    color: #fbbf24;
    font-weight: 600;
}

/* Credibility badges - NEW: Show domain authority */
.meta-credibility {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.05);
}

.meta-credibility.credibility-premium {
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.1);
}

.meta-credibility.credibility-verified {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
}

.meta-credibility.credibility-academic {
    color: #059669;
    background: rgba(5, 150, 105, 0.1);
}

.meta-credibility.credibility-government {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

/* =============================================================================
   ICON-ONLY ACTIONS (Below title/metadata)
   ============================================================================= */

.source-icon-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 30px; /* Align with content (checkbox width + gap) */
    margin-top: 4px;
}

.icon-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--foreground);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    text-decoration: none;
}

.icon-action-btn:hover {
    background: var(--muted);
    border-color: var(--accent);
}

.icon-action-btn svg {
    display: block;
}

.icon-action-btn.unlock-icon-btn:hover {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #2563eb;
}

.icon-action-btn.add-to-outline-btn:hover {
    background: #f3e8ff;
    border-color: #a855f7;
    color: #7c3aed;
}

.icon-action-btn.add-to-outline-btn.active {
    background: #7c3aed;
    border-color: #7c3aed;
    color: white;
}

.icon-action-btn.add-to-outline-btn.active:hover {
    background: #6d28d9;
    border-color: #6d28d9;
}

/* =============================================================================
   SOURCE EXCERPT (Hidden by default, shows on hover)
   ============================================================================= */

.source-excerpt {
    color: var(--muted-foreground);
    line-height: 1.5;
    margin-top: 8px;
    font-size: 13px;
    display: none !important;
    animation: fadeInExcerpt 0.2s ease-out;
}

@keyframes fadeInExcerpt {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =============================================================================
   DARK MODE OVERRIDES
   ============================================================================= */

.dark .source-card.selected {
    background-color: #1e3a8a !important;
}

.dark .source-card.selected .source-title,
.dark .source-card.selected .source-metadata-line {
    color: #e0f2fe !important;
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
    .source-card-compact {
        gap: 8px;
    }
    
    .source-title {
        font-size: 14px;
    }
    
    .source-metadata-line {
        font-size: 12px;
    }
    
    .source-icon-actions {
        gap: 4px;
    }
    
    .icon-action-btn {
        width: 28px;
        height: 28px;
    }
    
    .icon-action-btn svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 480px) {
    .source-card {
        padding: 10px 12px !important;
    }
    
    .source-card-compact {
        flex-wrap: wrap;
    }
    
    .source-icon-actions {
        width: 100%;
        justify-content: flex-end;
        margin-left: 30px;
    }
}
