/**
 * Prompts Frontend Styling
 * Public-facing pages for browsing and viewing prompts
 * 
 * @package Experts123
 */

/* =============================================================================
   CRITICAL: Prevent Layout Shift (CLS Fix)
   ============================================================================= */

/* Force wrappers to be full width from initial render */
body.single-hai-prompt .site-main,
body.single-hai-prompt .page-content,
body.archive-hai-prompt .site-main,
body.archive-hai-prompt .page-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
}

/* Override ANY container constraints on prompts pages - target all possible selectors */
body.single-hai-prompt .container,
body.single-hai-prompt .site-main .container,
body.single-hai-prompt .page-content .container,
body.single-hai-prompt main .container,
body.single-hai-prompt #content .container,
body.archive-hai-prompt .container,
body.archive-hai-prompt .site-main .container,
body.archive-hai-prompt .page-content .container,
body.archive-hai-prompt main .container,
body.archive-hai-prompt #content .container {
    max-width: 1200px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding-left: 2rem !important;
    padding-right: 2rem !important;
    box-sizing: border-box !important;
}

/* Prevent any wrapper from constraining width */
body.single-hai-prompt > *,
body.archive-hai-prompt > *,
body.single-hai-prompt #content,
body.archive-hai-prompt #content {
    max-width: 100% !important;
    width: 100% !important;
}

/* Ensure prompt containers are full width */
body.single-hai-prompt .hai-prompt-single,
body.archive-hai-prompt .hai-prompts-archive {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
}

/* =============================================================================
   Archive Page: Browse All Prompts
   ============================================================================= */

.hai-prompts-archive {
    background: #f9fafb;
    min-height: calc(100vh - 200px);
}

/* Hero Section */
.hai-prompts-hero {
    background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
    color: white;
    padding: 60px 0;
    text-align: center;
}

.hai-prompts-hero h1 {
    font-size: 48px;
    font-weight: 700;
    margin: 0 0 15px 0;
}

.hai-prompts-hero .hero-subtitle {
    font-size: 20px;
    opacity: 0.95;
    margin: 0 0 30px 0;
}

/* Search Bar */
.hai-prompts-search {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
}

.hai-prompts-search .search-input {
    flex: 1;
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
}

.hai-prompts-search .search-button {
    padding: 15px 30px;
    background: #F59E0B;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.hai-prompts-search .search-button:hover {
    background: #D97706;
}

/* Filters Section */
.hai-prompts-filters {
    background: white;
    border-bottom: 1px solid #E5E7EB;
    padding: 24px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 600;
    color: #374151;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-size: 14px;
    min-width: 180px;
}

.filter-results {
    margin-left: auto;
}

.result-count {
    font-size: 14px;
    color: #6B7280;
    font-weight: 500;
}

/* Prompts Grid */
.hai-prompts-grid-section {
    padding: 48px 0;
}

.hai-prompts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

/* No Results */
.no-prompts {
    text-align: center;
    padding: 80px 20px;
}

.no-prompts .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    opacity: 0.3;
}

.no-prompts h3 {
    margin: 20px 0 10px 0;
    color: #374151;
}

.no-prompts p {
    color: #6B7280;
    margin-bottom: 20px;
}

/* =============================================================================
   Prompt Card Component
   ============================================================================= */

.hai-prompt-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.hai-prompt-card:hover {
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.15);
    transform: translateY(-4px);
}

.prompt-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    padding: 24px;
}

/* Tier Badge */
.prompt-tier-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
}

.tier-free {
    background: #E5E7EB;
    color: #374151;
}

.tier-basic {
    background: #DBEAFE;
    color: #1E40AF;
}

.tier-premium {
    background: linear-gradient(135deg, #8B5CF6, #6366F1);
    color: white;
}

.tier-enterprise {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
}

/* Validation Badge */
.prompt-validated-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #10B981;
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 10;
}

.prompt-validated-badge .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

/* Card Header */
.prompt-card-header {
    margin-bottom: 12px;
    padding-right: 80px; /* Space for tier badge */
    padding-top: 28px; /* Space for validation badge above title */
}

.prompt-card-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    line-height: 1.4;
}

/* Card Body */
.prompt-card-body {
    margin-bottom: 16px;
}

.prompt-card-description {
    font-size: 14px;
    color: #6B7280;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

/* Categories */
.prompt-card-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.category-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #F3F4F6;
    color: #374151;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Card Footer */
.prompt-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid #F3F4F6;
}

.prompt-card-stats {
    display: flex;
    gap: 12px;
}

.stat-item {
    font-size: 12px;
    color: #6B7280;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-new {
    color: #10B981;
    font-weight: 600;
}

.prompt-card-cta {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #8B5CF6;
    font-size: 14px;
    font-weight: 600;
}

.prompt-card-cta .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
    transition: transform 0.2s;
}

.hai-prompt-card:hover .prompt-card-cta .dashicons {
    transform: translateX(4px);
}

/* =============================================================================
   Single Prompt Page
   ============================================================================= */

/* Breadcrumb */
.prompt-breadcrumb {
    background: #F9FAFB;
    padding: 16px 0;
    border-bottom: 1px solid #E5E7EB;
    font-size: 14px;
}

.prompt-breadcrumb a {
    color: #8B5CF6;
    text-decoration: none;
}

.prompt-breadcrumb a:hover {
    text-decoration: underline;
}

.prompt-breadcrumb .separator {
    margin: 0 8px;
    color: #9CA3AF;
}

.prompt-breadcrumb .current {
    color: #6B7280;
}

/* Prompt Header */
.prompt-header {
    background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
    color: white;
    padding: 48px 0;
    margin: 0;
    width: 100%;
}

.prompt-header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 2rem;
    padding-right: 2rem;
}

.prompt-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.prompt-header .prompt-tier-badge {
    position: static;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.prompt-header .prompt-validated-badge {
    position: static;
    display: inline-flex;
}

.prompt-header .prompt-categories {
    display: flex;
    gap: 8px;
}

.prompt-header .category-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.prompt-title {
    font-size: 42px;
    font-weight: 700;
    margin: 0 0 16px 0;
    line-height: 1.2;
}

.prompt-description {
    font-size: 18px;
    opacity: 0.95;
    margin: 0 0 24px 0;
    line-height: 1.6;
}

/* Stats Bar */
.prompt-stats-bar {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.prompt-stats-bar .stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.prompt-stats-bar .stat-icon {
    font-size: 20px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.prompt-stats-bar .stat-value {
    font-weight: 700;
    font-size: 20px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.prompt-stats-bar .stat-label {
    color: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Content Section */
.prompt-content-section {
    padding: 48px 0;
    background: white;
}

.prompt-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 48px;
    align-items: start;
}

@media (max-width: 1024px) {
    .prompt-layout {
        grid-template-columns: 1fr;
        gap: 32px;
    }
}

/* Main Content */
.prompt-main {
    min-width: 0; /* Prevent grid blowout */
    max-width: none; /* Remove max-width to fill available space */
    position: relative; /* Create positioning context */
    z-index: 1; /* Lower than sidebar */
}

.prompt-section {
    margin-bottom: 40px;
}

.prompt-section h2 {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 16px 0;
}

/* Code Block */
.prompt-code-block {
    position: relative;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 20px;
    padding-right: 200px; /* Extra space for copy button to ensure it fits */
    padding-top: 56px; /* Space at top for button (button height ~36px + 20px padding) */
    overflow: hidden; /* Clip button to rounded corners - CRITICAL */
    isolation: isolate; /* Create stacking context for proper clipping */
    contain: layout style paint; /* Improve clipping performance */
}

.prompt-code-block pre {
    margin: 0;
    padding: 0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #374151;
    max-width: 100%; /* Prevent overflow */
}

/* Copy Button - MUST stay within .prompt-code-block rounded container */
.copy-prompt-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 8px 14px;
    background: #8B5CF6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    z-index: 1; /* Lower z-index so it doesn't overlap sidebar */
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Critical: Ensure button never exceeds container bounds */
    max-width: min(180px, calc(100% - 32px)); /* Hard limit: 180px or container width minus padding, whichever is smaller */
    box-sizing: border-box;
    /* Ensure button is clipped by parent */
    overflow: visible; /* Button itself can overflow, but parent clips it */
}

.copy-prompt-btn:hover {
    background: #7C3AED;
}

.copy-prompt-btn .dashicons {
    width: 18px;
    height: 18px;
    font-size: 18px;
}

.prompt-keywords {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #E5E7EB;
    font-size: 14px;
    color: #6B7280;
}

/* Reviews */
.prompt-reviews {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.review-item {
    padding: 20px;
    background: #F9FAFB;
    border-radius: 8px;
}

.review-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.review-rating {
    font-size: 16px;
}

.review-author {
    font-weight: 600;
    color: #111827;
}

.review-date {
    font-size: 13px;
    color: #9CA3AF;
}

.review-title {
    font-size: 16px;
    font-weight: 600;
    margin: 8px 0;
}

.review-text {
    color: #374151;
    line-height: 1.6;
    margin: 0;
}

/* Sidebar */
.prompt-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 350px;
    position: sticky;
    top: 20px;
    z-index: 5; /* Higher than button to ensure sidebar content appears above */
}

.prompt-action-card,
.prompt-info-card,
.prompt-share-card {
    background: #F9FAFB;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #E5E7EB;
}

.prompt-action-card h3,
.prompt-info-card h3,
.prompt-share-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: #111827;
}

.prompt-action-card p {
    color: #6B7280;
    margin: 0 0 16px 0;
    line-height: 1.5;
}

.prompt-action-card .button-primary {
    width: 100%;
    justify-content: center;
    padding: 12px 24px;
    background: linear-gradient(135deg, #8B5CF6, #6366F1);
    border: none;
}

.prompt-action-card .button-primary:hover {
    background: linear-gradient(135deg, #7C3AED, #4F46E5);
}

.tier-notice {
    margin-top: 12px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    color: #6B7280;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    padding: 10px 0;
    border-bottom: 1px solid #E5E7EB;
    font-size: 14px;
}

.info-list li:last-child {
    border-bottom: none;
}

.info-list strong {
    color: #111827;
}

.share-buttons {
    display: flex;
    gap: 10px;
}

.share-btn {
    flex: 1;
    padding: 10px;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.share-btn:hover {
    background: #F3F4F6;
    border-color: #8B5CF6;
}

.share-btn .dashicons {
    width: 20px;
    height: 20px;
    font-size: 20px;
    color: #6B7280;
}

/* Related Prompts */
.prompt-related-section {
    padding: 60px 0;
    background: #F9FAFB;
}

.prompt-related-section h2 {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 32px 0;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    body.single-hai-prompt .container,
    body.archive-hai-prompt .container,
    .prompt-header .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .hai-prompts-hero h1 {
        font-size: 32px;
    }
    
    .prompt-title {
        font-size: 28px;
    }
    
    .hai-prompts-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-results {
        margin-left: 0;
    }
    
    .prompt-sidebar {
        width: 100%;
        position: static;
    }
    
    .prompt-content-section {
        padding: 32px 0;
    }
    
    .prompt-layout {
        gap: 32px;
    }
    
    .prompt-code-block {
        padding-right: 20px; /* Remove extra padding on mobile */
        padding-bottom: 60px; /* Space for button below */
    }
    
    .copy-prompt-btn {
        position: absolute;
        top: auto;
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
        margin-top: 0;
        justify-content: center;
        max-width: none;
    }
}

