/*
API Card Component Styles
Scoped styling for the Most Popular APIs section and individual API cards
*/

/* Popular APIs Section */
.popular-apis-section {
    padding: 60px 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border-light);
}

.popular-apis-header {
    text-align: center;
    margin-bottom: 36px;
}

.popular-apis-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 12px;
}

.popular-apis-description {
    font-size: 1rem;
    color: var(--color-text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* API Cards Grid */
.api-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 36px;
}

/* Individual API Card */
.api-card {
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    transition: all 0.3s ease;
    position: relative;
    overflow: visible; /* Allow tooltips to show */
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Remove default link styling */
    text-decoration: none;
    color: inherit;
}

/* Ensure link behavior for right-click and middle-click */
a.api-card:link,
a.api-card:visited,
a.api-card:hover,
a.api-card:active {
    text-decoration: none;
    color: inherit;
}

/* CTA cards shouldn't use flexbox layout */
.api-card.cta-card {
    display: block;
    height: auto;
}

.api-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
}

/* Lift card above everything when peek is open */
.api-card.peek-active {
    z-index: 999999;
}

/* API Card Header - Scoped to prevent conflicts */
.api-card .api-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.api-card .api-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.api-card .api-icon-img {
    width: 36px !important;
    height: 36px !important;
    object-fit: contain;
    border-radius: var(--radius-sm);
    max-width: 100%;
    max-height: 100%;
}

.api-card .api-icon-img-large {
    width: 80px !important;
    height: 80px !important;
    object-fit: contain;
    border-radius: var(--radius-md);
    max-width: 100%;
    max-height: 100%;
}

/* Loading spinner for page loading - Scoped to specific context */
.api-loading .loading-spinner-large {
    width: 60px;
    height: 60px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.api-loading .loading-overlay {
    text-align: center;
    color: var(--color-text-secondary);
}

.api-loading .loading-overlay p {
    font-size: 1.1rem;
    font-weight: 500;
}

.api-card .api-info {
    flex: 1;
    min-width: 0;
}

/* Scoped API name to prevent conflicts with pricing.css */
.api-card .api-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 2px 0;
    line-height: 1.3;
}

.api-card .new-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #fff;
    background: #ef4444;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    z-index: 1;
}

/* Meta row - Updated + Unified */
.api-card .api-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--color-text-tertiary);
    margin: 8px 0;
}

.api-card .fresh-text {
    display: flex;
    align-items: center;
    gap: 4px;
}

.api-card .fresh-text i {
    font-size: 0.5rem;
    color: var(--color-text-quaternary, var(--color-text-tertiary));
    opacity: 0.7;
}

.api-card .fresh-text.fresh-realtime i {
    color: #10b981;
    animation: pulse-dot 2s ease-in-out infinite;
}

.api-card .fresh-text .fresh-stat {
    color: var(--color-text-secondary);
}

.api-card .unified-text {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #16a34a;
}

.api-card .unified-text i {
    font-size: 0.55rem;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.api-card .api-category {
    font-size: 0.65rem;
    color: var(--color-text-tertiary);
    font-weight: 500;
    background: var(--color-surface-alt);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-bottom: 5px;
}

/* Star Rating - Scoped to API cards */
.api-card .api-rating {
    margin-top: 2px;
}

.api-card .stars {
    display: flex;
    gap: 1px;
}

.api-card .star {
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
    transition: color 0.2s ease;
}

.api-card .star.filled {
    color: #fbbf24;
}

/* API Description - Scoped to prevent conflicts with api-view.css */
.api-card .api-description {
    font-size: 0.76rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
    margin-bottom: 0;
    flex: 1; /* Take up available space */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* API Metrics - Scoped to API cards */
.api-card .api-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    flex-shrink: 0; /* Don't shrink the metrics */
}

.api-card .metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    transition: all 0.2s ease;
    position: relative;
    cursor: default;
}

.api-card .metric-pill:hover {
    background: var(--color-surface-alt);
}

.api-card .metric-icon {
    font-size: 0.65rem;
    opacity: 0.7;
    color: var(--color-text-secondary);
}

.api-card .api-metric-value {
    color: var(--color-text-primary);
    font-weight: 600;
}

/* Special metric pill states - removed, keeping all gray */

/* Hover Effects for Cards - Already properly scoped */
.api-card:hover .api-name {
    color: var(--color-primary);
}

.api-card:hover .metric-pill {
    border-color: var(--color-primary);
    background: rgba(0, 102, 204, 0.05);
}

/* Responsive Design */
@media (max-width: 768px) {
    .popular-apis-section {
        padding: 50px 0;
    }
    
    .popular-apis-title {
        font-size: 1.8rem;
    }
    
    .popular-apis-description {
        font-size: 0.9rem;
    }
    
    .api-cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-top: 28px;
    }
    
    .api-card {
        padding: 16px;
    }
    
    .api-card .api-card-header {
        gap: 10px;
        margin-bottom: 10px;
    }
    
    .api-card .api-icon {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }
    
    .api-card .api-name {
        font-size: 1rem;
    }
    
    .api-card .api-description {
        font-size: 0.75rem;
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .api-card .api-card-header {
        flex-direction: row;
        align-items: flex-start;
        gap: 10px;
    }

    .api-card .api-icon {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }

    .api-card .api-icon-img {
        width: 32px !important;
        height: 32px !important;
    }

    .api-card .api-metrics {
        gap: 6px;
    }

    .api-card .metric-pill {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
}

/* Dark theme adjustments */
[data-theme="dark"] .api-card:hover .metric-pill {
    background: rgba(96, 165, 250, 0.1);
    border-color: var(--color-primary);
}

/* Removed slideInUp animation for cleaner loading */

/* Focus states for accessibility */
.api-card:focus-within {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Smooth transitions for theme changes - Already properly scoped */
.api-card,
.api-card .api-icon,
.api-card .metric-pill {
    transition: all 0.3s ease,
                background-color 0.3s ease,
                border-color 0.3s ease,
                color 0.3s ease;
}

/* ===== Peek Fold Feature - Desktop Only ===== */

/* Folded corner that appears on hover */
.api-card .peek-fold {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 48px;
    height: 48px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    z-index: 10;
}

/* Visual fold triangle */
.api-card .peek-fold::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, transparent 50%, var(--color-primary) 50%);
    border-radius: 0 0 var(--radius-lg) 0;
    transition: transform 0.2s ease, background 0.2s ease;
}

.api-card .peek-fold i {
    position: relative;
    color: #fff;
    font-size: 0.7rem;
    opacity: 0.9;
    padding: 6px;
    z-index: 1;
}

/* Show fold on card hover */
.api-card:hover .peek-fold {
    opacity: 1;
}

.api-card .peek-fold:hover::before {
    transform: scale(1.1);
    background: linear-gradient(135deg, transparent 45%, var(--color-primary) 45%);
}

/* Hide on mobile */
@media (max-width: 768px) {
    .api-card .peek-fold {
        display: none;
    }
}

/* Peek Popover */
.api-card .peek-popover {
    position: absolute;
    right: 0;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl, 0 20px 40px rgba(0,0,0,0.15));
    z-index: 999999;
    overflow: hidden;
}

/* Position above card (default) */
.api-card .peek-popover-above {
    bottom: 100%;
    margin-bottom: 8px;
    animation: peekSlideInUp 0.2s ease;
}

/* Position below card */
.api-card .peek-popover-below {
    top: 100%;
    margin-top: 8px;
    animation: peekSlideInDown 0.2s ease;
}

@keyframes peekSlideInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes peekSlideInDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Closing animations */
.api-card .peek-popover-closing.peek-popover-above {
    animation: peekSlideOutUp 0.15s ease forwards;
}

.api-card .peek-popover-closing.peek-popover-below {
    animation: peekSlideOutDown 0.15s ease forwards;
}

@keyframes peekSlideOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes peekSlideOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

.api-card .peek-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.api-card .peek-method {
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: #22c55e;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* HTTP Method colors */
.api-card .peek-method-get {
    background: #22c55e; /* Green */
}

.api-card .peek-method-post {
    background: #3b82f6; /* Blue */
}

.api-card .peek-method-put {
    background: #f59e0b; /* Amber/Orange */
}

.api-card .peek-method-patch {
    background: #8b5cf6; /* Purple */
}

.api-card .peek-method-delete {
    background: #ef4444; /* Red */
}

.api-card .peek-endpoint {
    flex: 1;
    font-size: 0.75rem;
    color: var(--color-text-primary);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.api-card .peek-close {
    background: none;
    border: none;
    color: var(--color-text-tertiary);
    cursor: pointer;
    padding: 4px;
    font-size: 0.75rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.api-card .peek-close:hover {
    color: var(--color-text-primary);
    background: var(--color-surface-alt);
}

.api-card .peek-body {
    padding: 12px 14px;
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.api-card .peek-body::-webkit-scrollbar {
    width: 6px;
}

.api-card .peek-body::-webkit-scrollbar-track {
    background: transparent;
}

.api-card .peek-body::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.api-card .peek-body::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-tertiary);
}

.api-card .peek-body-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.api-card .peek-body-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.api-card .peek-copy-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-tertiary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.65rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.api-card .peek-copy-btn:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: rgba(0, 102, 204, 0.05);
}

.api-card .peek-copy-btn .fa-check {
    color: #22c55e;
}

.api-card .peek-json {
    font-size: 0.7rem;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    color: var(--color-text-secondary);
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.api-card .peek-json code {
    font-family: inherit;
    font-size: inherit;
    background: transparent;
}

.api-card .peek-json .token {
    background: transparent !important;
}

/* Light mode Prism token colors for peek popover */
.api-card .peek-json .token.property {
    color: #6f42c1;
}

.api-card .peek-json .token.string {
    color: #22863a;
}

.api-card .peek-json .token.number,
.api-card .peek-json .token.boolean {
    color: #005cc5;
}

.api-card .peek-json .token.null {
    color: #d73a49;
}

.api-card .peek-json .token.punctuation,
.api-card .peek-json .token.operator {
    color: #6a737d;
}

/* Dark mode Prism token colors for peek popover */
[data-theme="dark"] .api-card .peek-json .token.property {
    color: #d2a8ff;
}

[data-theme="dark"] .api-card .peek-json .token.string {
    color: #a5d6ff;
}

[data-theme="dark"] .api-card .peek-json .token.number,
[data-theme="dark"] .api-card .peek-json .token.boolean {
    color: #79c0ff;
}

[data-theme="dark"] .api-card .peek-json .token.null {
    color: #ff7b72;
}

[data-theme="dark"] .api-card .peek-json .token.punctuation,
[data-theme="dark"] .api-card .peek-json .token.operator {
    color: #8b949e;
}

.api-card .peek-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
}

.api-card .peek-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: peekSpin 0.7s linear infinite;
}

@keyframes peekSpin {
    to { transform: rotate(360deg); }
}

.api-card .peek-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: var(--color-text-tertiary);
    font-size: 0.8rem;
}

.api-card .peek-error i {
    color: #ef4444;
}

.api-card .peek-footer {
    padding: 10px 14px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 8px;
}

.api-card .peek-docs-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--color-background);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.api-card .peek-docs-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(0, 102, 204, 0.05);
}

.api-card .peek-try-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.api-card .peek-try-btn:hover {
    background: var(--color-primary-hover, #0052a3);
    transform: translateY(-1px);
}

.api-card .peek-try-btn i {
    font-size: 0.65rem;
    transition: transform 0.15s ease;
}

.api-card .peek-try-btn:hover i {
    transform: translateX(2px);
}

/* Dark theme adjustments for peek */
[data-theme="dark"] .api-card .peek-popover {
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

[data-theme="dark"] .api-card .peek-json {
    color: var(--color-text-secondary);
}