/**
 * Frontend Styles for Premium Prompts Library
 */

/* Virtual Page Styles */
.ppl-virtual-page {
    width: 100%;
    max-width: 100%;
}

.ppl-virtual-page .site-main {
    width: 100%;
}

/* Navigation Menu Item Styles */
.menu-item-prompts-library {
    position: relative;
}

.ppl-menu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.ppl-menu-icon {
    font-size: 18px;
    line-height: 1;
}

.menu-item-prompts-library .ppl-menu-link:hover {
    color: #f65c4b !important;
}

/* Main Container */
.ppl-library-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* Header Section */
.ppl-library-header {
    width: 100%;
    padding: 60px 40px;
    text-align: center;
    color: #fff;
}

.ppl-header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.ppl-header-title {
    font-size: 48px;
    font-weight: 700;
    margin: 0 0 15px 0;
    line-height: 1.2;
    color: #ffffff !important;
}

.ppl-header-subtitle {
    font-size: 20px;
    margin: 0 0 40px 0;
    opacity: 0.95;
    font-weight: 400;
    color: #ffffff !important;
}

/* Chatbot Container */
.ppl-chatbot-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Chatbot with Discussion History */
.ppl-chatbot-wrapper {
    display: flex;
    flex-direction: row;
    gap: 20px;
    min-height: 500px;
    align-items: flex-start;
}

.ppl-discussions-sidebar {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    max-height: 600px;
    border: 1px solid #e1e4e8;
}

.ppl-chatbot-main {
    flex: 1;
    min-width: 0;
    background: transparent;
}

/* Mobile: Stack vertically */
@media (max-width: 768px) {
    .ppl-chatbot-wrapper {
        flex-direction: column;
    }
    
    .ppl-discussions-sidebar {
        width: 100%;
        min-width: 100%;
        border-radius: 8px;
        max-height: 200px;
    }
    
    .ppl-chatbot-main {
        width: 100%;
        border-radius: 8px;
    }
}

/* Force proper layout for AI Engine discussions */
.ppl-discussions-sidebar .mwai-discussions {
    width: 100% !important;
}

.ppl-chatbot-wrapper > * {
    box-sizing: border-box;
}

/* Filters Section */
.ppl-filters-section {
    background: #f8f9fa;
    padding: 30px 40px;
    border-bottom: 1px solid #e1e4e8;
}

.ppl-filters-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Search Bar */
.ppl-search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.ppl-search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 16px;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.ppl-search-input:focus {
    outline: none;
    border-color: #f65c4b;
    box-shadow: 0 0 0 3px rgba(246, 92, 75, 0.1);
}

.ppl-search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    pointer-events: none;
}

/* Category Filters */
.ppl-category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.ppl-category-badge {
    padding: 8px 18px;
    border: none;
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.ppl-category-badge:hover,
.ppl-category-badge.active {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Tag Filters */
.ppl-tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.ppl-tag-chip {
    padding: 6px 16px;
    border: 2px solid #e1e4e8;
    border-radius: 16px;
    background: #fff;
    color: #586069;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ppl-tag-chip:hover,
.ppl-tag-chip.active {
    border-color: #f65c4b;
    color: #f65c4b;
    background: #fff5f4;
}

/* Clear Filters */
.ppl-clear-filters {
    padding: 8px 20px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    transition: opacity 0.3s ease;
}

.ppl-clear-filters:hover {
    opacity: 0.7;
}

/* Prompts Section */
.ppl-prompts-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 40px 60px;
}

/* Prompts Grid */
.ppl-prompts-grid {
    display: grid;
    gap: 30px;
    margin-bottom: 40px;
}

.ppl-grid-cols-1 {
    grid-template-columns: 1fr;
}

.ppl-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.ppl-grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.ppl-grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Prompt Card */
.ppl-prompt-card {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.ppl-prompt-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.ppl-card-category {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 6px 14px;
    border-radius: 16px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.ppl-card-title {
    font-size: 20px;
    font-weight: 700;
    margin: 35px 0 12px 0;
    color: #0D0D2B;
    line-height: 1.3;
}

.ppl-card-description {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ppl-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}

.ppl-card-tag {
    padding: 4px 10px;
    background: #f1f3f5;
    border-radius: 12px;
    font-size: 11px;
    color: #586069;
    font-weight: 500;
}

/* Hide tags that are empty or just numbers (likely IDs shown by mistake) */
.ppl-card-tag:empty,
.ppl-tag-chip:empty {
    display: none !important;
}

/* Additional safeguard: hide tags/chips that look like pure numbers */
.ppl-card-tag[data-numeric="true"],
.ppl-tag-chip[data-numeric="true"] {
    display: none !important;
}

.ppl-card-actions {
    display: flex;
    gap: 10px;
}

/* Copy button styling */
.ppl-copy-card {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    background: #fff;
    color: #0D0D2B;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ppl-copy-card:hover {
    border-color: #0D0D2B;
    background: #f8f9fa;
    transform: translateY(-2px);
}

/* Favorite heart icon */
.ppl-favorite-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ppl-favorite-icon:hover {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ppl-favorite-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #666;
    stroke-width: 2;
    transition: all 0.3s ease;
}

.ppl-favorite-icon.favorited svg {
    fill: #ff6b6b;
    stroke: #ff6b6b;
}

.ppl-favorite-icon:hover svg {
    stroke: #ff6b6b;
}

.ppl-button {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.ppl-button-primary {
    background: #f65c4b;
    color: #fff;
}

.ppl-button-primary:hover {
    background: #e54a39;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(246, 92, 75, 0.3);
}

.ppl-button-secondary {
    background: #fff;
    color: #0D0D2B;
    border: 2px solid #e1e4e8;
}

.ppl-button-secondary:hover {
    border-color: #0D0D2B;
    background: #f8f9fa;
}

/* Pagination */
.ppl-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.ppl-pagination button {
    padding: 10px 16px;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    background: #fff;
    color: #0D0D2B;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ppl-pagination button:hover:not(:disabled) {
    border-color: #f65c4b;
    color: #f65c4b;
}

.ppl-pagination button.active {
    background: #f65c4b;
    color: #fff;
    border-color: #f65c4b;
}

.ppl-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Modal */
.ppl-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
}

.ppl-modal.active {
    display: flex;
}

.ppl-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.ppl-modal-content {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

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

.ppl-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: #f1f3f5;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1;
}

.ppl-modal-close:hover {
    background: #e1e4e8;
    transform: rotate(90deg);
}

.ppl-modal-header {
    padding: 30px 70px 20px 30px; /* Extra padding on right for close button */
    border-bottom: 1px solid #e1e4e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.ppl-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #0D0D2B;
    margin: 0;
    flex: 1;
    padding-right: 15px; /* Extra spacing */
}

.ppl-modal-category-badge {
    padding: 6px 14px;
    border-radius: 16px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0; /* Prevent shrinking */
}

.ppl-modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.ppl-modal-description {
    background: #E8F4FD;
    border-left: 4px solid #3498db;
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 25px;
    font-size: 15px;
    line-height: 1.6;
    color: #0D0D2B;
}

.ppl-modal-description p {
    margin: 0;
}

.ppl-modal-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #586069;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ppl-modal-prompt-text {
    background: #F5F7FA;
    padding: 25px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.8;
    color: #0D0D2B;
}

/* Improved formatting for prompt text */
.ppl-modal-prompt-text p {
    margin: 0 0 15px 0;
}

.ppl-modal-prompt-text p:last-child {
    margin-bottom: 0;
}

.ppl-modal-prompt-text ul,
.ppl-modal-prompt-text ol {
    margin: 15px 0;
    padding-left: 30px;
}

.ppl-modal-prompt-text li {
    margin-bottom: 12px;
    line-height: 1.7;
    padding-left: 8px;
}

/* Better indentation for nested items */
.ppl-modal-prompt-text li li {
    margin-top: 8px;
    padding-left: 15px;
}

.ppl-modal-prompt-text strong {
    font-weight: 600;
    color: #0D0D2B;
}

.ppl-modal-prompt-text em {
    font-style: italic;
}

/* Highlight placeholders in square brackets */
.ppl-modal-prompt-text .ppl-placeholder,
.ppl-placeholder {
    background: #FFF4E6;
    border: 1px solid #FFB84D;
    color: #CC6600;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 14px;
    font-weight: 500;
    white-space: normal; /* Changed from nowrap to allow wrapping */
    word-wrap: break-word; /* Break long words if needed */
    display: inline; /* Keep inline but allow wrapping */
    line-height: 1.6;
}

/* Better spacing for brackets/placeholders */
.ppl-modal-prompt-text code,
.ppl-modal-prompt-text [class*="bracket"] {
    background: #e1e4e8;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.ppl-modal-footer {
    padding: 20px 30px 30px;
    display: flex;
    gap: 15px;
    border-top: 1px solid #e1e4e8;
}

.ppl-modal-footer .ppl-button {
    flex: 1;
}

/* Loading State */
.ppl-loading {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

.ppl-loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Empty State */
.ppl-empty-state {
    text-align: center;
    padding: 80px 20px;
}

.ppl-empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.ppl-empty-state-text {
    font-size: 18px;
    color: #666;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .ppl-grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .ppl-header-title {
        font-size: 32px;
    }
    
    .ppl-header-subtitle {
        font-size: 16px;
    }
    
    .ppl-library-header,
    .ppl-filters-section,
    .ppl-prompts-section {
        padding-left: 20px;
        padding-right: 20px;
    }
    
    .ppl-grid-cols-3,
    .ppl-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ppl-prompts-grid {
        gap: 20px;
    }
    
    .ppl-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .ppl-modal-header,
    .ppl-modal-body,
    .ppl-modal-footer {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .ppl-header-title {
        font-size: 24px;
    }
    
    .ppl-grid-cols-2,
    .ppl-grid-cols-3,
    .ppl-grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    .ppl-card-actions {
        flex-direction: column;
    }
    
    .ppl-modal-footer {
        flex-direction: column;
    }
}

/* Pulse animation for Send button */
@keyframes ppl-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
        transform: scale(1);
    }
}

.ppl-pulse-button {
    animation: ppl-pulse 1.5s infinite !important;
    position: relative !important;
    z-index: 9999 !important;
}
