/* Results Overview Styles */

/* Main Container */
.sap-results-overview {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Overview Title */
.sap-overview-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
    color: #1a202c;
    position: relative;
    padding-bottom: 15px;
}

.sap-overview-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

/* Two Column Layout - Table Style */
.sap-results-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

/* Column Styles */
.sap-results-column {
    position: relative;
    min-height: 400px;
}

/* Divider between columns */
.sap-results-column.sap-recent-column::after {
    content: '';
    position: absolute;
    right: -15px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #e5e7eb;
}

/* Column Titles */
.sap-column-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a202c;
    margin: 0 0 20px 0;
    padding: 0 0 12px 0;
    border-bottom: 2px solid #f3f4f6;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sap-column-title .sap-icon {
    font-size: 20px;
    color: #667eea;
}

/* Results List - No scroll */
.sap-results-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Result Card - Clean Table Style */
.sap-result-card {
    display: grid;
    grid-template-columns: 60px 1fr 45px;
    align-items: center;
    gap: 15px;
    padding: 14px 16px;
    background: #fafbfc;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
    border: 1px solid #e5e7eb;
    min-height: 65px;
}

.sap-result-card:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* Score Badge - Minimal Style */
.sap-result-score-badge {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: white;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sap-result-score-badge .sap-score-value {
    font-size: 14px;
    font-weight: 600;
}

/* Color based on score value - Fixed for proper score ranges */
.sap-result-score-badge {
    background: #ef4444; /* Default red for low scores */
}

/* Scores 50-79 */
.sap-result-score-badge[data-score^="5"],
.sap-result-score-badge[data-score^="6"],
.sap-result-score-badge[data-score^="7"] {
    background: #f59e0b;
}

/* Scores 80-99 */
.sap-result-score-badge[data-score^="8"],
.sap-result-score-badge[data-score^="9"] {
    background: #10b981;
}

/* Score 100 */
.sap-result-score-badge[data-score="100"] {
    background: #10b981;
}

/* Result Content */
.sap-result-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sap-result-domain {
    font-size: 14px;
    font-weight: 600;
    color: #1a202c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
    margin-bottom: 3px;
}

.sap-result-meta {
    font-size: 12px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sap-result-meta .sap-date {
    display: flex;
    align-items: center;
}

/* Styles for repeated domain cards */
.sap-result-card.same-domain {
    background: linear-gradient(to right, #f0f9ff 0%, #fafbfc 10%);
    border-left: 3px solid #3b82f6;
    padding-left: 13px;
}

/* Retest badge */
.sap-retest-badge {
    margin-left: 8px;
    font-size: 14px;
    opacity: 0.7;
}

/* Trend indicator */
.sap-trend {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 12px;
    background: white;
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.sap-trend.improvement {
    background: #dcfce7;
}

.sap-trend.decline {
    background: #fee2e2;
}

.sap-trend.stable {
    background: #f3f4f6;
}

/* Link Icon */
.sap-result-link-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: #64748b;
    border: 1.5px solid #e5e7eb;
    transition: all 0.2s ease;
    text-decoration: none;
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.sap-result-link-icon:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.sap-result-link-icon .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 1;
}

.sap-result-link-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
}

/* Fallback arrow if no icon loads */
.sap-result-link-icon:empty::after {
    content: "→";
    font-size: 18px;
    font-weight: bold;
}

/* Top Results Specific */
.sap-top-card {
    display: grid;
    grid-template-columns: 45px 1fr 45px;
    gap: 15px;
    background: #fafbfc;
    min-height: 70px;
}

.sap-top-card.sap-speed-card {
    grid-template-columns: 45px 1fr 45px;
    min-height: 70px;
}

.sap-top-card:nth-child(1) {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.08) 0%, rgba(255, 215, 0, 0.03) 100%);
}

.sap-top-card:nth-child(2) {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.08) 0%, rgba(192, 192, 192, 0.03) 100%);
}

.sap-top-card:nth-child(3) {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.08) 0%, rgba(205, 127, 50, 0.03) 100%);
}

/* Position Badge */
.sap-position-badge {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sap-medal {
    font-size: 24px;
}

.sap-position-number {
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    background: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1.5px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Score display for top results */
.sap-top-card .sap-result-content {
    min-width: 0;
}

/* Score Bar for top results */
.sap-score-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.sap-score-bar {
    flex: 1;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
    max-width: 120px;
}

.sap-score-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 1s ease;
}

/* Fixed color for score bar based on actual score values */
.sap-score-bar-fill {
    background: #ef4444; /* Default red for low scores */
}

/* Medium scores 50-79 */
.sap-top-card[data-score^="5"] .sap-score-bar-fill,
.sap-top-card[data-score^="6"] .sap-score-bar-fill,
.sap-top-card[data-score^="7"] .sap-score-bar-fill,
.sap-speed-card[data-score^="5"] .sap-score-bar-fill,
.sap-speed-card[data-score^="6"] .sap-score-bar-fill,
.sap-speed-card[data-score^="7"] .sap-score-bar-fill {
    background: #f59e0b;
}

/* High scores 80-99 */
.sap-top-card[data-score^="8"] .sap-score-bar-fill,
.sap-top-card[data-score^="9"] .sap-score-bar-fill,
.sap-speed-card[data-score^="8"] .sap-score-bar-fill,
.sap-speed-card[data-score^="9"] .sap-score-bar-fill {
    background: #10b981;
}

/* Score 100 */
.sap-top-card[data-score="100"] .sap-score-bar-fill,
.sap-speed-card[data-score="100"] .sap-score-bar-fill {
    background: #10b981;
}

.sap-score-text {
    font-size: 13px;
    font-weight: 600;
    color: #1a202c;
    min-width: 35px;
    text-align: right;
}

/* Speed Overview Container */
.sap-speed-overview {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Speed Test Specific Styles */
.sap-speed-card {
    grid-template-columns: 45px 1fr 45px;
    min-height: 70px;
}

.sap-speed-card.sap-recent-speed-card {
    grid-template-columns: 40px 1fr 40px;
}

.sap-speed-card .sap-result-content {
    min-width: 0;
}

.sap-speed-card .sap-result-domain {
    font-size: 14px;
    font-weight: 500;
    color: #1a202c;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Average Score Badge for Speed Tests */
.sap-speed-avg-badge {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Color based on average score */
.sap-speed-avg-badge {
    background: #ef4444;
}

.sap-speed-avg-badge[data-score^="5"],
.sap-speed-avg-badge[data-score^="6"],
.sap-speed-avg-badge[data-score^="7"] {
    background: #f59e0b;
}

.sap-speed-avg-badge[data-score^="8"],
.sap-speed-avg-badge[data-score^="9"] {
    background: #10b981;
}

.sap-speed-avg-badge[data-score="100"] {
    background: #10b981;
}

/* Inline Speed Scores - Unified Style */
.sap-speed-scores-inline {
    display: flex;
    gap: 8px;
    margin: 6px 0;
    font-size: 13px;
}

.sap-speed-scores-inline span {
    padding: 3px 6px;
    background: #f3f4f6;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
}

.sap-speed-scores-inline .mobile-score {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.sap-speed-scores-inline .desktop-score {
    background: rgba(118, 75, 162, 0.1);
    color: #764ba2;
}

.sap-speed-scores-inline .avg-score {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    color: #333;
    font-weight: 600;
}

/* No Results Message */
.sap-no-results {
    text-align: center;
    padding: 30px 20px;
    color: #94a3b8;
    font-size: 14px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
}

/* History Modal Styles */
.sap-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.sap-modal-content {
    background-color: #fff;
    margin: 50px auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s;
}

.sap-modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    padding: 5px;
}

.sap-modal-close:hover {
    color: #1a202c;
}

.sap-modal-title {
    margin: 0 0 20px 0;
    color: #1a202c;
    font-size: 24px;
    font-weight: 600;
}

.sap-modal-domain {
    color: #667eea;
}

/* History table */
.sap-history-table {
    margin: 20px 0;
    overflow-x: auto;
}

.sap-history-table table {
    width: 100%;
    border-collapse: collapse;
}

.sap-history-table th {
    background: #f8fafc;
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e5e7eb;
}

.sap-history-table td {
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    color: #475569;
}

.sap-history-table tr:hover {
    background: #f8fafc;
}

.sap-score-cell {
    font-weight: 600;
    color: #1a202c;
}

/* History summary */
.sap-history-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.sap-history-summary p {
    margin: 5px 0;
    color: #475569;
}

.sap-change.positive {
    color: #10b981;
    font-weight: 600;
}

.sap-change.negative {
    color: #ef4444;
    font-weight: 600;
}

.sap-change.neutral {
    color: #6b7280;
}

/* History chart */
.sap-history-chart {
    margin: 20px 0;
    padding: 15px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

#sap-history-canvas {
    max-width: 100%;
    height: auto;
}

/* Loading state */
.sap-loading {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

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

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sap-results-columns {
        grid-template-columns: 1fr;
    }

    .sap-results-column.sap-recent-column::after {
        display: none;
    }

    .sap-overview-title {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .sap-column-title {
        font-size: 16px;
    }

    .sap-result-card {
        padding: 10px 12px;
    }

    .sap-result-score-badge {
        width: 40px;
        height: 40px;
    }

    .sap-speed-scores-inline {
        flex-wrap: wrap;
    }
}

/* Loading Animation */
@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

.sap-loading {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    height: 80px;
    margin-bottom: 12px;
}