/**
 * Article Metrics Styles
 * Mobile-responsive styles for metrics display
 */

/* ============================================================================
   METRIC ANIMATIONS
   ============================================================================ */

@keyframes metricPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes spinRefresh {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.metric-updated {
    animation: metricPulse 0.6s ease-in-out;
    color: #28a745 !important;
    font-weight: bold;
}

.spinning {
    animation: spinRefresh 1s linear infinite;
}

/* ============================================================================
   METRIC DISPLAY
   ============================================================================ */

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.3s ease;
}

.metric-item:last-child {
    border-bottom: none;
}

.metric-item:hover {
    background-color: #f8f9fa;
    padding-left: 8px;
    padding-right: 8px;
    margin-left: -8px;
    margin-right: -8px;
    border-radius: 4px;
}

.metric-label {
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    color: #495057;
    font-weight: 500;
}

.metric-label i {
    margin-right: 8px;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
    transition: all 0.3s ease;
}

/* ============================================================================
   ALTMETRIC BREAKDOWN
   ============================================================================ */

.formula-box {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.formula-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.formula-title i {
    margin-right: 8px;
    color: #007bff;
}

.formula-content code {
    display: block;
    background: white;
    padding: 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #e83e8c;
    font-family: 'Monaco', 'Courier New', monospace;
    overflow-x: auto;
    white-space: nowrap;
}

/* Weight explanation items */
.weight-explanation {
    margin-top: 15px;
}

.weight-item {
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.weight-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateX(5px);
}

.weight-item:nth-child(1) { border-left-color: #007bff; }
.weight-item:nth-child(2) { border-left-color: #28a745; }
.weight-item:nth-child(3) { border-left-color: #17a2b8; }
.weight-item:nth-child(4) { border-left-color: #6c757d; }

.weight-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-weight: 500;
}

.weight-label i {
    font-size: 1.2rem;
}

.weight-label .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
}

.weight-desc {
    font-size: 0.85rem;
    color: #6c757d;
    padding-left: 28px;
}

/* Calculation details */
.calculation-details {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
}

.calc-row.total {
    border-top: 2px solid #dee2e6;
    margin-top: 8px;
    padding-top: 12px;
    font-size: 1rem;
}

.total-score {
    color: #007bff;
    font-weight: 700;
    font-size: 1.2rem;
}

/* Score guide */
.guide-content {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
}

.guide-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f3f5;
}

.guide-item:last-child {
    border-bottom: none;
}

.score-range {
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    min-width: 80px;
    text-align: center;
}

.score-range.low {
    background: #e9ecef;
    color: #6c757d;
}

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

.score-range.high {
    background: #ffeaa7;
    color: #d63031;
}

.score-range.exceptional {
    background: #ffe0e0;
    color: #c0392b;
}

.score-meaning {
    font-size: 0.85rem;
    color: #495057;
    flex: 1;
    margin-left: 12px;
}

/* ============================================================================
   MOBILE RESPONSIVE STYLES
   ============================================================================ */

/* Tablets and below (768px) */
@media (max-width: 768px) {
    .metric-value {
        font-size: 1.25rem;
    }
    
    .metric-label {
        font-size: 0.875rem;
    }
    
    .formula-content code {
        font-size: 0.75rem;
        padding: 8px;
    }
    
    .weight-item {
        padding: 8px;
        margin-bottom: 10px;
    }
    
    .weight-label {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .weight-desc {
        padding-left: 0;
        margin-top: 5px;
    }
    
    /* Compact calculation display on mobile */
    .calculation-details {
        padding: 10px;
    }
    
    .calc-row {
        font-size: 0.8rem;
        padding: 6px 0;
    }
    
    .total-score {
        font-size: 1.1rem;
    }
    
    /* Score guide adjustments */
    .guide-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .score-range {
        min-width: auto;
    }
    
    .score-meaning {
        margin-left: 0;
    }
    
    /* Sidebar adjustments */
    .article-sidebar.mobile-view {
        margin-top: 20px;
    }
    
    .sidebar-section {
        margin-bottom: 20px;
    }
    
    .sidebar-section h3 {
        font-size: 1.1rem;
    }
    
    /* Make Altmetric section collapsible on mobile */
    .altmetric-breakdown.mobile-compact {
        max-height: 300px;
        overflow-y: auto;
    }
}

/* Mobile phones (480px and below) */
@media (max-width: 480px) {
    .metric-value {
        font-size: 1.1rem;
    }
    
    .metric-label {
        font-size: 0.8rem;
    }
    
    .metric-label i {
        font-size: 1rem;
        width: 18px;
    }
    
    .formula-content code {
        font-size: 0.7rem;
        padding: 6px;
    }
    
    .weight-item {
        padding: 6px;
    }
    
    .weight-label {
        font-size: 0.85rem;
    }
    
    .weight-desc {
        font-size: 0.75rem;
    }
    
    .calculation-details {
        padding: 8px;
    }
    
    .calc-row {
        font-size: 0.75rem;
    }
    
    .total-score {
        font-size: 1rem;
    }
    
    /* Collapse buttons should be full width */
    .btn.btn-outline-primary,
    .btn.btn-outline-secondary {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    
    /* Metric info text */
    .metric-info small {
        font-size: 0.7rem;
    }
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.metric-value .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15rem;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .metric-item {
        border-bottom-width: 2px;
    }
    
    .formula-box {
        border-width: 3px;
    }
    
    .weight-item {
        border-left-width: 4px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .metric-updated,
    .spinning,
    .weight-item {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .metric-item {
        page-break-inside: avoid;
    }
    
    .weight-item:hover {
        transform: none;
        box-shadow: none;
    }
    
    .calculation-example,
    .score-guide {
        page-break-inside: avoid;
    }
    
    /* Expand collapsed sections for print */
    .collapse:not(.show) {
        display: block !important;
        height: auto !important;
    }
}

/* ============================================================================
   DARK MODE SUPPORT (if theme supports it)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .formula-box {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .formula-content code {
        background: #1a202c;
        color: #f687b3;
    }
    
    .weight-item {
        background: #2d3748;
    }
    
    .calculation-details,
    .guide-content {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .metric-value {
        color: #e2e8f0;
    }
    
    .metric-label {
        color: #cbd5e0;
    }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.text-success {
    color: #28a745 !important;
}

.text-primary {
    color: #007bff !important;
}

.text-info {
    color: #17a2b8 !important;
}

.text-secondary {
    color: #6c757d !important;
}

/* Responsive visibility helpers */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}