/* ==========================================================================
   RECIPE DETAIL MODAL STYLING
   ========================================================================== */

.rd-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rd-modal-overlay.show {
    display: flex;
    opacity: 1;
}

.rd-modal-content {
    background: #f8fafc;
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow-y: auto;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.rd-modal-overlay.show .rd-modal-content {
    transform: translateY(0);
}

.rd-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
    z-index: 10;
}

.rd-close-btn:hover {
    color: #000;
}

.rd-modal-body {
    padding: 30px;
}

/* Breadcrumb */
.rd-breadcrumb {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rd-breadcrumb span.active {
    color: #0f172a;
    font-weight: 500;
}

.rd-title {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

/* Top Section (Image + Meta) */
.rd-top-section {
    display: flex;
    gap: 30px;
    margin-bottom: 25px;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.rd-image-col {
    flex: 0 0 40%;
}

.rd-image-col img {
    width: 100%;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.rd-meta-col {
    flex: 1;
}

.rd-recipe-name {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 20px;
}

.rd-meta-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.rd-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.rd-meta-icon {
    color: #10b981;
    font-size: 18px;
    width: 20px;
    margin-top: 2px;
}

.rd-meta-label {
    font-weight: 600;
    font-size: 13px;
    color: #334155;
    width: 120px;
    flex-shrink: 0;
}

.rd-meta-value {
    font-size: 14px;
    color: #475569;
    line-height: 1.5;
}

/* Actions */
.rd-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.rd-btn-simpan {
    background: #4ade80;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.rd-btn-simpan:hover {
    background: #22c55e;
}

.rd-btn-print {
    background: #ffffff;
    color: #dc2626;
    border: 1.5px solid #fecaca;
    padding: 9px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.rd-btn-print:hover {
    background: #fef2f2;
    border-color: #f87171;
    color: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.12);
}

/* Green Header Sections */
.rd-section {
    margin-bottom: 25px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    border: 1px solid #e2e8f0;
}

.rd-section-header {
    background: #4ade80;
    color: #fff;
    padding: 12px 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rd-section-header.darker {
    background: #22c55e;
}

.rd-section-body {
    padding: 20px;
}

/* Bahan Layout */
.rd-bahan-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 30px;
}

.rd-bahan-list li {
    font-size: 14px;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rd-bahan-list li::before {
    content: "•";
    color: #334155;
}

/* Cara Pembuatan Layout */
.rd-cara-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.rd-cara-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.rd-cara-number {
    background: #4ade80;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.rd-cara-text {
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
    margin-top: 2px;
}

/* Gizi Layout */
.rd-gizi-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    text-align: center;
}

.rd-gizi-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.rd-gizi-icon {
    color: #22c55e;
    font-size: 16px;
    margin-bottom: 5px;
}

.rd-gizi-label {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.rd-gizi-val {
    font-size: 13px;
    color: #64748b;
}

.rd-gizi-header-right {
    margin-left: auto;
    font-size: 12px;
    font-weight: normal;
}

.rd-sumber {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 10px;
}

.rd-footer-btn {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

.rd-btn-kembali {
    background: #fff;
    border: 1px solid #cbd5e1;
    padding: 10px 20px;
    border-radius: 6px;
    color: #475569;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.rd-btn-kembali:hover {
    background: #f1f5f9;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .rd-modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 15px auto !important;
        border-radius: 16px !important;
    }
    .rd-top-section {
        flex-direction: column !important;
        gap: 15px !important;
    }
    .rd-image-col {
        width: 100% !important;
        max-width: 100% !important;
    }
    .rd-image-col img {
        width: 100% !important;
        height: 200px !important;
        object-fit: cover !important;
        border-radius: 12px !important;
    }
    .rd-bahan-list {
        grid-template-columns: 1fr !important;
    }
    .rd-gizi-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }
    .rd-modal-body {
        padding: 16px !important;
    }
}

@media (max-width: 480px) {
    .rd-modal-content {
        width: 96% !important;
        margin: 10px auto !important;
        border-radius: 12px !important;
    }
    .rd-title {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }
    .rd-recipe-name {
        font-size: 17px !important;
    }
    .rd-meta-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    .rd-gizi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .rd-modal-body {
        padding: 12px !important;
    }
    .rd-btn-print, .rd-btn-kembali {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* Print Styles */
@media print {
    /* Pastikan tinggi halaman menyesuaikan konten dan tidak terpengaruh scroll */
    html, body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
        position: static !important;
    }

    /* Sembunyikan elemen lain di halaman saat print */
    body > *:not(.rd-modal-overlay) {
        display: none !important;
    }

    /* Pastikan warna latar belakang tercetak (Chrome/Edge/Safari) */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .rd-modal-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        display: block !important;
        background: none !important;
        box-shadow: none !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
    }

    .rd-modal-content {
        position: static !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        transform: none !important;
        overflow: visible !important;
        max-height: none !important;
    }

    .rd-modal-body {
        padding: 0 !important;
    }

    /* Sembunyikan tombol yang tidak perlu di cetakan */
    .rd-close-btn, .rd-actions, .rd-footer-btn, .rd-breadcrumb {
        display: none !important;
    }

    /* Penyesuaian layout agar tidak terpotong antar halaman */
    .rd-section {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 20px !important;
    }

    /* Perkecil ukuran foto tanpa memotong */
    .rd-image-col {
        flex: 0 0 100% !important; 
        text-align: center;
        margin-bottom: 20px !important;
    }

    .rd-image-col img {
        max-width: 300px !important; /* Batasi lebar agar tidak terlalu besar */
        height: auto !important; /* Biarkan tinggi menyesuaikan proporsi */
        max-height: 250px !important; 
        object-fit: contain !important; /* Jangan dipotong */
        break-inside: avoid;
        page-break-inside: avoid;
        margin: 0 auto !important;
        display: block !important;
        border-radius: 8px !important;
    }

    /* Ubah struktur top section menjadi kolom di cetakan agar lebih rapi */
    .rd-top-section {
        display: block !important;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 20px !important;
        padding: 15px !important;
        border: 1px solid #e2e8f0 !important;
    }

    @page {
        margin: 1cm; /* Kurangi margin halaman agar lebih banyak ruang terisi */
    }
}

/* ================= PDF EXPORT COMPACT STYLES ================= */
.pdf-export-mode {
    padding: 0 !important;
    background: #ffffff !important;
    color: #0f172a !important;
    max-width: 100% !important;
}

.pdf-export-mode .rd-title {
    font-size: 16px !important;
    margin-bottom: 8px !important;
    padding-bottom: 6px !important;
    border-bottom: 2px solid #0f766e !important;
}

.pdf-export-mode .rd-top-section {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px !important;
    margin-bottom: 8px !important;
    padding-bottom: 8px !important;
}

.pdf-export-mode .rd-image-col {
    flex: 0 0 140px !important;
    text-align: left !important;
    margin-bottom: 0 !important;
}

.pdf-export-mode .rd-image-col img {
    width: 140px !important;
    height: 100px !important;
    object-fit: cover !important;
    border-radius: 8px !important;
    margin: 0 !important;
}

.pdf-export-mode .rd-recipe-name {
    font-size: 15px !important;
    margin-bottom: 6px !important;
}

.pdf-export-mode .rd-meta-grid {
    gap: 5px !important;
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
}

.pdf-export-mode .rd-meta-item {
    padding: 5px 8px !important;
    border-radius: 6px !important;
}

.pdf-export-mode .rd-meta-label {
    font-size: 8.5px !important;
}

.pdf-export-mode .rd-meta-value {
    font-size: 10.5px !important;
}

.pdf-export-mode .rd-section {
    margin-bottom: 8px !important;
    border-radius: 6px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-export-mode .rd-section-header {
    padding: 6px 12px !important;
    font-size: 11px !important;
}

.pdf-export-mode .rd-section-body {
    padding: 8px 12px !important;
    font-size: 10.5px !important;
    line-height: 1.4 !important;
}

.pdf-export-mode .rd-gizi-grid {
    gap: 5px !important;
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
}

.pdf-export-mode .rd-gizi-item {
    padding: 5px 3px !important;
}

.pdf-export-mode .rd-gizi-label {
    font-size: 8.5px !important;
}

.pdf-export-mode .rd-gizi-val {
    font-size: 10.5px !important;
}

.pdf-export-mode .rd-sumber {
    padding: 6px 0 !important;
    margin-top: 6px !important;
    font-size: 8.5px !important;
}

