/**
 * PlantPedia Smart Linking System Styles
 * ระบบเชื่อมโยงอัตโนมัติ
 */

/* ========================================
   BASE STYLES - กล่องหลัก
   ======================================== */

.smart-link-box {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    margin: 30px 0;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    transition: all 0.3s ease;
}

.smart-link-box:hover {
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.12);
}

.smart-link-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.smart-link-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.smart-link-subtitle {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin: 0;
}

.smart-link-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
    text-align: center;
}

.see-all-link {
    color: #27ae60;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.see-all-link:hover {
    color: #1e8449;
    text-decoration: underline;
}

/* ========================================
   PRODUCT RECOMMENDATIONS - สินค้าแนะนำ
   ======================================== */

.product-recommendations {
    background: linear-gradient(135deg, #ffffff 0%, #f8fff8 100%);
    border-left: 4px solid #27ae60;
}

.product-recommendations .smart-link-title {
    color: #27ae60;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 991px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

.product-card-mini {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e8e8e8;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.product-card-mini:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.15);
    border-color: #27ae60;
}

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

.product-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #f5f5f5;
    overflow: hidden;
}

.product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card-mini:hover .product-thumb img {
    transform: scale(1.05);
}

.badge-top {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.product-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 6px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
}

.product-brand {
    display: inline-block;
    background: #ecf0f1;
    color: #7f8c8d;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-rating {
    color: #f39c12;
    font-weight: 600;
    font-size: 0.85rem;
}

.product-price {
    color: #27ae60;
    font-weight: 700;
    font-size: 0.9rem;
}

.product-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 12px;
}

.btn-review,
.btn-buy {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-review {
    background: #ecf0f1;
    color: #2c3e50;
}

.btn-review:hover {
    background: #bdc3c7;
}

.btn-buy {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.btn-buy:hover {
    background: linear-gradient(135deg, #1e8449, #27ae60);
    transform: scale(1.02);
}

/* ========================================
   RELATED DISEASES - โรคที่เกี่ยวข้อง
   ======================================== */

.related-diseases {
    border-left: 4px solid #e74c3c;
    background: linear-gradient(135deg, #ffffff 0%, #fff8f8 100%);
}

.related-diseases .smart-link-title {
    color: #e74c3c;
}

/* Disease Cards Grid (แบบใหม่ มีรูป) */
.diseases-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1024px) {
    .diseases-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 991px) {
    .diseases-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

.disease-card-mini {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e8e8e8;
    transition: all 0.3s ease;
    text-decoration: none;
    display: block;
}

.disease-card-mini:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.15);
    border-color: #e74c3c;
}

.disease-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #fdf2f2;
    overflow: hidden;
}

.disease-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.disease-card-mini:hover .disease-thumb img {
    transform: scale(1.05);
}

.disease-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: linear-gradient(135deg, #fdf2f2, #fee);
}

.disease-thumb .severity-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

.disease-thumb .severity-badge.critical {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
}

.disease-thumb .severity-badge.severe {
    background: linear-gradient(135deg, #d35400, #e67e22);
}

.disease-thumb .severity-badge.moderate {
    background: linear-gradient(135deg, #f39c12, #f1c40f);
    color: #333;
}

.disease-thumb .severity-badge.mild {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.disease-info {
    padding: 12px;
}

.disease-info .disease-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 6px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.disease-link-text {
    font-size: 0.8rem;
    color: #e74c3c;
    font-weight: 500;
}

.disease-card-mini:hover .disease-link-text {
    text-decoration: underline;
}

/* Disease Tags (แบบเดิม - เก็บไว้ใช้ได้) */
.disease-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.disease-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #ffffff;
    border: 2px solid #e8e8e8;
    border-radius: 25px;
    text-decoration: none;
    color: #2c3e50;
    font-weight: 500;
    transition: all 0.3s ease;
}

.disease-tag:hover {
    border-color: #e74c3c;
    background: #fff5f5;
    transform: translateY(-2px);
}

.disease-tag.critical {
    border-color: #c0392b;
    background: #fdf2f2;
}

.disease-tag.severe {
    border-color: #e67e22;
    background: #fef9f3;
}

.disease-tag.moderate {
    border-color: #f1c40f;
    background: #fffef3;
}

.disease-tag.mild {
    border-color: #27ae60;
    background: #f3fef6;
}

.disease-icon {
    font-size: 1.2rem;
}

/* ========================================
   AFFECTED PLANTS - พืชที่ได้รับผลกระทบ
   ======================================== */

.affected-plants {
    border-left: 4px solid #3498db;
    background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
}

.affected-plants .smart-link-title {
    color: #3498db;
}

.plants-grid-mini {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
}

.plant-mini-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.plant-mini-card:hover {
    border-color: #3498db;
    background: #f8faff;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.15);
}

.plant-thumb-mini {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 8px;
    background: #ecf0f1;
}

.plant-thumb-mini img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.plant-thumb-mini.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.plant-name-mini {
    font-size: 0.8rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
    line-height: 1.2;
}

/* ========================================
   RELATED GUIDES - คู่มือที่เกี่ยวข้อง
   ======================================== */

.related-guides {
    border-left: 4px solid #9b59b6;
    background: linear-gradient(135deg, #ffffff 0%, #faf8ff 100%);
}

.related-guides .smart-link-title {
    color: #9b59b6;
}

.guides-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.guide-item:hover {
    border-color: #9b59b6;
    background: #faf8ff;
    transform: translateX(5px);
}

.guide-icon {
    font-size: 1.5rem;
}

.guide-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.guide-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
}

.guide-difficulty {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    width: fit-content;
}

.guide-difficulty.easy {
    background: #d5f5e3;
    color: #1e8449;
}

.guide-difficulty.medium {
    background: #fef9e7;
    color: #9a7b0a;
}

.guide-difficulty.hard {
    background: #fadbd8;
    color: #943126;
}

.guide-arrow {
    color: #9b59b6;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.guide-item:hover .guide-arrow {
    transform: translateX(5px);
}

/* ========================================
   SIDEBAR WIDGET - สินค้าขายดี
   ======================================== */

.bestsellers-widget {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
}

.bestsellers-widget .widget-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e74c3c;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.bestseller-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bestseller-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rank-badge {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.bestseller-item:nth-child(1) .rank-badge {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
}

.bestseller-item:nth-child(2) .rank-badge {
    background: linear-gradient(135deg, #bdc3c7, #95a5a6);
}

.bestseller-item:nth-child(3) .rank-badge {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.bestseller-link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    text-decoration: none;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.bestseller-link:hover {
    background: #f8f9fa;
}

.bestseller-thumb {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
}

.bestseller-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bestseller-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.2;
}

.bestseller-rating {
    font-size: 0.75rem;
    color: #f39c12;
}

.widget-more-link {
    display: block;
    text-align: center;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    color: #27ae60;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9rem;
}

.widget-more-link:hover {
    color: #1e8449;
}

/* ========================================
   SMART LINKS SECTION - Container
   ======================================== */

.smart-links-section {
    margin: 40px 0;
}

.smart-links-section .smart-link-box {
    margin-bottom: 24px;
}

.smart-links-section .smart-link-box:last-child {
    margin-bottom: 0;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 991px) {
    .smart-link-box {
        padding: 16px;
        margin: 20px 0;
    }
    
    .smart-link-title {
        font-size: 1.2rem;
    }
    
    .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .product-thumb {
        height: 120px;
    }
    
    .plants-grid-mini {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .disease-tags {
        gap: 8px;
    }
    
    .disease-tag {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .plants-grid-mini {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .product-actions {
        flex-direction: column;
    }
    
    .btn-review,
    .btn-buy {
        width: 100%;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.smart-link-box {
    animation: slideIn 0.5s ease-out;
}

.smart-links-section .smart-link-box:nth-child(2) {
    animation-delay: 0.1s;
}

.smart-links-section .smart-link-box:nth-child(3) {
    animation-delay: 0.2s;
}

/* ========================================
   GUIDE LINKS - สำหรับหน้า Product Review
   ======================================== */

.guides-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.guide-link-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.guide-link-card:hover {
    background: #fff;
    border-color: #27ae60;
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.15);
}

.guide-link-card .guide-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.guide-link-card .guide-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.guide-link-card .guide-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
}

.guide-link-card .guide-difficulty {
    font-size: 0.8rem;
    color: #7f8c8d;
}

.guide-link-card .guide-arrow {
    font-size: 1.2rem;
    color: #27ae60;
    transition: transform 0.3s;
}

.guide-link-card:hover .guide-arrow {
    transform: translateX(5px);
}

/* Forward Links Box Variations */
.product-treats-diseases .smart-link-title {
    color: #e74c3c;
}

.product-for-plants-forward .smart-link-title {
    color: #27ae60;
}

.product-related-guides .smart-link-title {
    color: #3498db;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .smart-link-box {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    
    .btn-buy,
    .btn-review {
        display: none;
    }
}
