/* All-in-One Rating Widget Styles - Metzler Design */
/* Widget-specific variables to prevent global conflicts */
.metzler-aio-rating-widget {
    /* Map widget tokens to Metzler design system variables */
    --primary-color: var(--btn-pr-b, #015253);
    --primary-gradient: linear-gradient(135deg, var(--btn-pr-b, #015253) 0%, var(--btn-pr-b, #015253) 100%);
    --secondary-color: var(--btn-df-b, #eee);
    --accent-color: var(--btn-in-b, #6fa6ff);
    --text-primary: var(--lab-t, #333);
    --text-secondary: var(--bod-t, #555);
    --text-muted: var(--pbx-tt, #555);
    --background: var(--bod-b, #fff);
    --background-secondary: var(--plh-b, #f6f6f6);
    --background-accent: var(--csm-b-l, #f5f7fa);
    --border-color: var(--brd-b, #eee);
    --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    --shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 24px -10px rgba(0, 0, 0, 0.18);
    --shadow-hover: 0 12px 30px -12px rgba(0, 0, 0, 0.22);
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --star-color: var(--btn-wa-b, #ffc041);
    --star-gradient: linear-gradient(45deg, var(--btn-wa-b, #ffc041), #f59e0b);
    --metzler-steel: #95a5a6;
    --metzler-dark: var(--bod-l-h, #015253);
    --crd-bg: #f6f6f6;
}

/* Demo styles - only used for the demo page, not for embedded widgets */
/* These styles will be moved to a separate demo.css file */
#rating-widget-demo * {
    box-sizing: border-box;
}

#rating-widget-demo {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--background-secondary) 0%, var(--background-accent) 100%);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

#rating-widget-demo .demo-container {
    max-width: 1200px;
    margin: 0 auto;
}

#rating-widget-demo .demo-container h1 {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--metzler-dark);
    text-shadow: none;
}

#rating-widget-demo .demo-container p {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 3rem;
    font-weight: 400;
}

/* Widget Styles - these will be used when embedded */

/* Rating Widget Styles */
.metzler-aio-rating-widget {
    margin: 2rem 0;
}

/* .rating-widget:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-8px) scale(1.02);
} */

/* Disable hover/lift effect for the specific demo container */
/* #rating-widget-container .rating-widget:hover {
    box-shadow: var(--shadow-lg);
} */

/* .rating-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-gradient);
    opacity: 0.03;
    pointer-events: none;
} */

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1.5rem;
    position: relative;
}

.widget-header.minimal {
    justify-content: center;
    margin-bottom: 0.5rem;
}

.widget-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.overall-rating {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--background-secondary);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.overall-rating.centered {
    justify-content: center;
    gap: 0.5rem;
    margin: 1.5rem 0 2rem 0;
    padding: 0;
    background: none;
    border: none;
    align-items: baseline;
}

.overall-rating.centered .rating-score {
    font-size: 2rem;
    font-weight: 700;
    color: var(--metzler-dark);
    line-height: 0.9;
}

.overall-rating.centered .stars {
    margin: 0;
}

.overall-rating.centered .stars .star {
    width: 28px;
    height: 28px;
}

.overall-rating.centered .review-count {
    font-size: 0.9rem;
    color: var(--bod-t-l, var(--text-secondary));
    font-weight: 400;
    align-self: center;
}

/* removed decorative line for a cleaner look */

.rating-score {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--metzler-dark);
    line-height: 1;
}

.rating-details {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
}

/* Header row with tabs and CTA */
.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0 1rem 0;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .header-row {
        flex-direction: column;
        gap: 1rem;
    }
}

.tabs-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    max-width: min(80%, 940px);
    margin: 0 auto;
}

.source-tabs {
    display: flex;
    gap: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none; /* Firefox */
    position: relative;
    padding-left: 12px;
    padding-right: 12px;
    scroll-behavior: smooth;
    justify-content: center;
}

.source-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

@media (max-width: 768px) {
    .source-tabs {
        width: 100%;
        justify-content: flex-start;
        gap: 0.5rem;
    }
    
    .tabs-container {
        max-width: 100%;
    }
}

/* Gradient overlays to indicate scrollability */
.tabs-shadow-left,
.tabs-shadow-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tabs-shadow-left {
    left: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}

.tabs-shadow-right {
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
    opacity: 1; /* Show right shadow by default */
}

/* Scroll buttons */
.tabs-scroll-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.tabs-scroll-button:hover {
    transform: translateY(-50%) scale(1.1);
}

.tabs-scroll-button.left {
    left: 4px;
}

.tabs-scroll-button.right {
    right: 4px;
    opacity: 1; /* Show right button by default */
}

@media (max-width: 768px) {
    .tabs-scroll-button.right {
        opacity: 1;
    }
    .tabs-shadow-right {
        opacity: 1;
    }
}

.source-tabs .tab {
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 0;
    position: relative;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .source-tabs .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
}

.source-tabs .tab .tab-score {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.95em;
}

.source-tabs .tab .tab-count {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.85em;
}

.source-tabs .tab .tab-icon {
    display: flex;
    align-items: center;
}

.source-tabs .tab .tab-label {
    white-space: nowrap;
}

.source-tabs .tab.active {
    color: var(--text-primary);
}

.source-tabs .tab.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--brd-l-h, var(--metzler-dark));
}

.cta-btn {
    background: #1f6feb;
    color: #fff;
    text-decoration: none;
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.cta-btn:hover {
    background: #1a5fd0;
}

.stars {
    display: flex;
    gap: 1px;
    margin: 0.25rem 0 0.75rem 0;
    align-items: center;
    line-height: 1;
    overflow: visible;
    min-height: 24px;
    padding: 2px 0;
}

.star {
    width: 20px;
    height: 20px;
    color: #fbbf24;
    transition: all 0.2s ease;
    display: block;
    flex-shrink: 0;
    overflow: visible;
}

.star.empty {
    color: #e5e7eb;
}

.star.half {
    color: #fbbf24;
}

.review-count {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
}

.sources-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.source-item {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(248, 250, 252, 0.9));
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.source-item:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 1));
    transform: translateY(-4px) scale(1.05);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: var(--shadow);
}

.source-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-gradient);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.source-item:hover::before {
    transform: translateX(0);
}

.source-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.source-rating {
    color: var(--primary-color);
    font-weight: 600;
}

.reviews-container {
    margin-top: 2rem;
}

.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.reviews-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.reviews-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0.5rem 0 0.75rem 0;
    line-height: 1.3;
}

.reviews-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    gap: 1rem;
}

.reviews-footer:has(.load-more-btn):not(:has(.show-less-btn)) {
    justify-content: center;
}

.reviews-footer:has(.show-less-btn):not(:has(.load-more-btn)) {
    justify-content: flex-end;
}

@media (max-width: 576px) {
    .reviews-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .reviews-footer button {
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    .reviews-footer:has(.load-more-btn):not(:has(.show-less-btn)),
    .reviews-footer:has(.show-less-btn):not(:has(.load-more-btn)) {
        align-items: stretch;
    }
}

.load-more-btn,
.show-less-btn,
.view-all-btn {
    background: transparent;
    color: var(--metzler-dark);
    border: 2px solid var(--metzler-dark);
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: normal;
}

.load-more-btn:hover,
.show-less-btn:hover,
.view-all-btn:hover {
    background: var(--metzler-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(1, 82, 83, 0.3);
}

.load-more-btn:active,
.show-less-btn:active,
.view-all-btn:active {
    transform: translateY(0);
    transition: all 0.1s;
}

.show-less-btn {
    border-color: #6b7280;
    color: #6b7280;
}

.show-less-btn:hover {
    background: #6b7280;
    color: white;
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

.review-card {
    background: var(--crd-b, #fff);
    border: 1px solid var(--crd-r, var(--border-color));
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: visible;
}

.review-card:hover {
    transform: none;
    box-shadow: var(--shadow);
    border-color: var(--brd-r-h, #cfd8dc);
}

.review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.reviewer-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.reviewer-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.reviewer-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-fallback {
    width: 100%;
    height: 100%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.reviewer-details {
    flex: 1;
    min-width: 0;
}

.reviewer-name {
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.read-more {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: inline;
    font-family: inherit;
}

.read-more:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.read-less {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: inline;
    font-family: inherit;
}

.read-less:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.review-source {
    display: inline-flex;
    opacity: 1;
    top: -1.0rem;
    left: 1.25rem;
    background: white;
    position: relative;
    border-radius: 50%;
    padding: .05rem;

}

.review-source img {
    width: 20px;
    height: 20px;
    border-radius: 2px;
}

.source-emoji {
    font-size: 16px;
}

.review-text {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0.75rem 0;
}

.review-footer {
    /* display: flex; */
    /* align-items: center; */
    /* justify-content: space-between; */
    margin-top: 1rem;
}

.review-origin {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.review-date {
    font-size: 0.8125rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.embed-code {
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(31, 41, 55, 0.9));
    backdrop-filter: blur(20px);
    color: #f9fafb;
    padding: 2rem;
    border-radius: var(--radius-lg);
    margin-top: 3rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.embed-code::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-gradient);
}

.embed-code h3 {
    margin: 0 0 1.5rem 0;
    color: #f3f4f6;
    font-size: 1.25rem;
    font-weight: 600;
}

.embed-code code {
    display: block;
    font-family: 'Monaco', 'Menlo', monospace;
    line-height: 1.8;
    color: #34d399;
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid #34d399;
}

/* Floating Elements Animation */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

/* Pulse animation for stars */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* .star:nth-child(1) { animation: pulse 2s ease-in-out 0s infinite; }
.star:nth-child(2) { animation: pulse 2s ease-in-out 0.2s infinite; }
.star:nth-child(3) { animation: pulse 2s ease-in-out 0.4s infinite; }
.star:nth-child(4) { animation: pulse 2s ease-in-out 0.6s infinite; }
.star:nth-child(5) { animation: pulse 2s ease-in-out 0.8s infinite; } */

/* Enhanced mobile styles */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .rating-widget {
        padding: 2rem 1.5rem;
        margin: 1rem 0;
        animation: none; /* Disable float on mobile */
    }
    
    .widget-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .widget-title {
        font-size: 1.5rem;
    }
    
    .overall-rating {
        flex-direction: column;
        text-align: center;
        width: 100%;
        gap: 1rem;
    }
    
    .rating-score {
        font-size: 2.5rem;
    }
    
    .sources-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .reviews-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .review-card {
        padding: 1.5rem;
    }
    
    .demo-container h1 {
        font-size: 2rem;
    }
    
    .demo-container p {
        font-size: 1rem;
    }
}

/* Loading Animation */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fade in animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.6s ease-out;
}
