/* =============================================================================
   PSM Widgets - Main Stylesheet
   ============================================================================= */

/* Base styles for all PSM widgets */
.psm-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
}

.psm-widget * {
    box-sizing: border-box;
}

.psm-widget-title {
    font-size: 1.25em;
    font-weight: 600;
    margin-bottom: 1em;
    color: #2c3e50;
    border-bottom: 1px solid #e7e7e7;
    padding-bottom: 0.3em;
}

.psm-widget-content {
    position: relative;
}

/* Grid System */
.psm-grid {
    display: grid;
    grid-gap: 1rem;
    grid-template-columns: repeat(var(--psm-columns, 3), 1fr);
}

@media (max-width: 768px) {
    .psm-grid {
        grid-template-columns: repeat(var(--psm-columns-tablet, 2), 1fr);
    }
}

@media (max-width: 480px) {
    .psm-grid {
        grid-template-columns: repeat(var(--psm-columns-mobile, 1), 1fr);
    }
}

.psm-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.psm-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* =============================================================================
   Taxonomy List Widget
   ============================================================================= */

.psm-taxonomy-list-widget {
    /* Base styles inherited */
}

.psm-term-item {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.psm-term-item:hover {
    text-decoration: none;
    color: #3498db;
    transform: translateX(5px);
}

.psm-term-link {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.psm-term-link:hover {
    background-color: #f8f9fa;
    text-decoration: none;
}

.psm-term-name {
    font-weight: 500;
    margin-right: 0.5rem;
}

.psm-term-count {
    font-size: 0.875em;
    color: #666;
    background: #e9ecef;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    margin-left: auto;
}

.psm-term-description {
    font-size: 0.875em;
    color: #666;
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* Grid layout for taxonomy list */
.psm-layout-grid .psm-term-item {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.psm-layout-grid .psm-term-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    color: inherit;
}

/* Inline layout */
.psm-layout-inline .psm-term-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.875em;
    white-space: nowrap;
    display: inline-block;
}

.psm-layout-inline .psm-term-item:hover {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    transform: none;
}

/* =============================================================================
   Product Terms Widget
   ============================================================================= */

.psm-product-terms-widget {
    /* Base styles inherited */
}

.psm-product-terms {
    margin-bottom: 1rem;
}

.psm-product-terms-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    display: block;
}

.psm-product-term {
    display: inline-block;
    background: #3498db;
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.875em;
    text-decoration: none;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.psm-product-term:hover {
    background: #2980b9;
    color: #fff;
    text-decoration: none;
    transform: scale(1.05);
}

/* Grid style for product terms */
.psm-style-grid .psm-product-terms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.psm-style-grid .psm-product-term {
    display: block;
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    margin: 0;
}

/* =============================================================================
   Taxonomy Grid Widget
   ============================================================================= */

.psm-taxonomy-grid-widget {
    /* Base styles inherited */
}

.psm-grid-item {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    position: relative;
}

.psm-grid-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.psm-grid-image {
    position: relative;
    overflow: hidden;
    height: 200px;
}

.psm-grid-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.psm-grid-item:hover .psm-grid-image img {
    transform: scale(1.1);
}

.psm-grid-content {
    padding: 1.5rem;
}

.psm-grid-title {
    font-size: 1.125em;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
}

.psm-grid-description {
    font-size: 0.875em;
    color: #666;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.psm-grid-count {
    display: inline-block;
    background: #e74c3c;
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
}

.psm-grid-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25em;
    color: #3498db;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Card styles */
.psm-style-card .psm-grid-item {
    border: 1px solid #e9ecef;
}

.psm-style-modern .psm-grid-item {
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.psm-style-modern .psm-grid-title,
.psm-style-modern .psm-grid-description {
    color: #fff;
}

/* =============================================================================
   Product Meta Widget
   ============================================================================= */

.psm-product-meta-widget {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
}

.psm-meta-field {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

.psm-meta-field:last-child {
    border-bottom: none;
}

.psm-meta-icon {
    width: 24px;
    height: 24px;
    margin-right: 1rem;
    color: #3498db;
    flex-shrink: 0;
}

.psm-meta-label {
    font-weight: 600;
    color: #2c3e50;
    margin-right: 1rem;
    min-width: 120px;
}

.psm-meta-value {
    color: #555;
    font-weight: 500;
}

/* Grid layout for meta fields */
.psm-style-grid .psm-product-meta-widget {
    padding: 0;
    background: transparent;
}

.psm-style-grid .psm-meta-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.psm-style-grid .psm-meta-field {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-direction: column;
    align-items: flex-start;
    text-align: center;
}

.psm-style-grid .psm-meta-icon {
    margin: 0 auto 0.5rem;
    font-size: 1.5em;
}

.psm-style-grid .psm-meta-label {
    margin: 0 0 0.5rem 0;
    min-width: auto;
}

/* =============================================================================
   Taxonomy Filter Widget
   ============================================================================= */

.psm-taxonomy-filter-widget {
    /* Base styles inherited */
}

.psm-filter-form {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.psm-filter-group {
    margin-bottom: 1.5rem;
}

.psm-filter-group:last-child {
    margin-bottom: 0;
}

.psm-filter-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.75rem;
    display: block;
}

.psm-filter-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.3s ease;
}

.psm-filter-select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.psm-filter-checkbox,
.psm-filter-radio {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.psm-filter-option {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    border: 2px solid #e9ecef;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.psm-filter-option:hover {
    border-color: #3498db;
    background: #f0f8ff;
}

.psm-filter-option input {
    margin-right: 0.5rem;
    margin-top: 0;
}

.psm-filter-option.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.psm-filter-submit {
    background: #3498db;
    color: #fff;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
}

.psm-filter-submit:hover {
    background: #2980b9;
}

.psm-filter-results {
    margin-top: 2rem;
}

.psm-loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.psm-loading:before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

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

/* =============================================================================
   Featured Terms Widget
   ============================================================================= */

.psm-featured-terms {
    /* Base styles inherited */
}

.psm-featured-term {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.psm-featured-term:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.psm-featured-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.psm-featured-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.psm-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.psm-featured-term:hover .psm-featured-image img {
    transform: scale(1.1);
}

.psm-featured-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.7) 100%);
    display: flex;
    align-items: flex-end;
    padding: 1.5rem;
}

.psm-featured-content {
    color: #fff;
    width: 100%;
}

.psm-featured-content-only {
    padding: 2rem;
    background: #fff;
    text-align: center;
}

.psm-featured-title {
    font-size: 1.25em;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
}

.psm-featured-count {
    font-size: 0.875em;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.psm-featured-description {
    font-size: 0.875em;
    line-height: 1.4;
    opacity: 0.9;
}

/* Featured terms styles */
.psm-style-card .psm-featured-term {
    background: #fff;
    border: 1px solid #e9ecef;
}

.psm-style-overlay .psm-featured-overlay {
    background: linear-gradient(45deg, rgba(52, 152, 219, 0.8), rgba(142, 68, 173, 0.8));
}

.psm-style-minimal .psm-featured-term {
    box-shadow: none;
    border: 2px solid #e9ecef;
}

.psm-style-minimal:hover {
    border-color: #3498db;
}

.psm-style-hero .psm-featured-image {
    height: 350px;
}

.psm-style-hero .psm-featured-content {
    text-align: center;
}

.psm-style-hero .psm-featured-title {
    font-size: 2em;
    font-weight: 800;
}

/* Layout: List */
.psm-layout-list .psm-featured-terms {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.psm-layout-list .psm-featured-term {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: #fff;
    border: 1px solid #e9ecef;
}

.psm-layout-list .psm-featured-image {
    width: 80px;
    height: 80px;
    margin-right: 1rem;
    flex-shrink: 0;
}

.psm-layout-list .psm-featured-overlay {
    display: none;
}

.psm-layout-list .psm-featured-content {
    color: #333;
}

/* Layout: Carousel */
.psm-layout-carousel .psm-featured-terms {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 1rem;
    scroll-snap-type: x mandatory;
}

.psm-layout-carousel .psm-featured-term {
    min-width: 280px;
    scroll-snap-align: start;
}

/* =============================================================================
   Responsive Design
   ============================================================================= */

@media (max-width: 768px) {
    .psm-widget {
        font-size: 0.9em;
    }
    
    .psm-grid-image,
    .psm-featured-image {
        height: 180px;
    }
    
    .psm-grid-content,
    .psm-featured-overlay {
        padding: 1rem;
    }
    
    .psm-filter-form {
        padding: 1rem;
    }
    
    .psm-filter-checkbox,
    .psm-filter-radio {
        flex-direction: column;
    }
    
    .psm-filter-option {
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .psm-widget-title {
        font-size: 1.125em;
    }
    
    .psm-grid-image,
    .psm-featured-image {
        height: 160px;
    }
    
    .psm-layout-carousel .psm-featured-term {
        min-width: 240px;
    }
    
    .psm-meta-label {
        min-width: 80px;
        font-size: 0.875em;
    }
    
    .psm-style-grid .psm-meta-fields {
        grid-template-columns: 1fr;
    }
}

/* =============================================================================
   Print Styles
   ============================================================================= */

@media print {
    .psm-widget {
        color: #000;
        background: #fff;
    }
    
    .psm-featured-term,
    .psm-grid-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .psm-filter-form,
    .psm-filter-submit {
        display: none;
    }
}

/* =============================================================================
   Accessibility
   ============================================================================= */

.psm-widget a:focus,
.psm-filter-submit:focus,
.psm-filter-select:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .psm-widget *,
    .psm-widget *:before,
    .psm-widget *:after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}