/**
 * Widget Styles for KG Fixedbuy Plan
 */

/* ========================================
   Common Widget Container
   ======================================== */

.kg-widget-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 30px 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.kg-widget-header {
    margin-bottom: 30px;
    text-align: center;
}

.kg-widget-title {
    font-size: 24px;
    font-weight: bold;
    margin: 0 0 10px;
    color: #333;
}

.kg-widget-note {
    font-size: 13px;
    color: #666;
    margin: 0;
}

/* ========================================
   Common Grid Layout
   ======================================== */

.kg-recent-grid,
.kg-rising-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.kg-recent-cols-2 {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.kg-recent-cols-3 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.kg-recent-cols-4 {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* ========================================
   Card Styles
   ======================================== */

.kg-recent-card,
.kg-rising-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.kg-recent-card:hover,
.kg-rising-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #c0c0c0;
}

.kg-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.kg-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #f8f8f8;
    overflow: hidden;
}

.kg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kg-badge-up {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #e74c3c;
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.kg-card-body {
    padding: 15px;
}

.kg-card-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 8px;
    color: #333;
    line-height: 1.4;
    min-height: 2.8em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.kg-card-price {
    font-size: 18px;
    font-weight: bold;
    color: #e74c3c;
    margin: 0;
}

.kg-card-price-info {
    font-size: 14px;
    margin: 0;
}

.kg-price-current {
    font-size: 18px;
    font-weight: bold;
    color: #e74c3c;
    display: block;
    margin-bottom: 4px;
}

.kg-price-prev {
    font-size: 13px;
    color: #999;
}

.kg-card-action {
    padding: 0 15px 15px;
}

.kg-btn-primary {
    display: block;
    width: 100%;
    padding: 12px;
    background: #3498db;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    font-weight: bold;
    transition: background 0.3s ease;
}

.kg-card-link:hover .kg-btn-primary {
    background: #2980b9;
}

/* ========================================
   Widget Actions
   ======================================== */

.kg-widget-actions {
    margin-top: 20px;
    text-align: center;
}

.kg-btn-clear {
    padding: 8px 20px;
    background: #95a5a6;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.kg-btn-clear:hover {
    background: #7f8c8d;
}

/* ========================================
   Product Tags
   ======================================== */

.kg-product-tags {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.kg-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #ecf0f1;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
    font-weight: 500;
}

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

@media screen and (max-width: 768px) {
    .kg-widget-container {
        margin: 20px auto;
        padding: 20px 15px;
    }
    
    .kg-widget-title {
        font-size: 20px;
    }
    
    .kg-recent-grid,
    .kg-rising-grid,
    .kg-recent-cols-2,
    .kg-recent-cols-3,
    .kg-recent-cols-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .kg-card-title {
        font-size: 14px;
    }
    
    .kg-card-price,
    .kg-price-current {
        font-size: 16px;
    }
    
    .kg-btn-primary {
        padding: 10px;
        font-size: 14px;
    }
}

@media screen and (max-width: 480px) {
    .kg-recent-grid,
    .kg-rising-grid,
    .kg-recent-cols-2,
    .kg-recent-cols-3,
    .kg-recent-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Performance Optimizations
   ======================================== */

/* Prevent CLS by reserving space for images */
.kg-card-image::before {
    content: '';
    display: block;
    padding-top: 100%; /* 1:1 aspect ratio */
}

.kg-card-image img {
    position: absolute;
    top: 0;
    left: 0;
}

/* Smooth loading */
.kg-recent-wrapper,
.kg-rising-wrapper {
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}
