/**
 * CUSTOM APPLICATION STYLES
 * Pelengkap Tailwind CSS CDN: penanganan print, scrollbar, dan responsivitas layar kecil (iPhone SE 375px).
 */

/* Mencegah horizontal scroll yang tidak diinginkan di mobile */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}
::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

/* Minimum touch target 44px untuk mobile UX (WCAG 2.1) */
@media (max-width: 640px) {
    button, input, select, textarea {
        min-height: 42px;
    }
    
    /* Tombol ikon kecil tetap memiliki area sentuh yang cukup */
    .touch-target-sm {
        min-height: 38px;
        min-width: 38px;
    }

    /* Tampilan menu resep saat dropdown dibuka di mobile */
    #presetButtonsContainer.is-open {
        display: grid !important;
    }
}

/* Responsive Ingredient Row untuk layar mobile (termasuk iPhone SE 375px) */
@media (max-width: 480px) {
    .ingredient-row {
        flex-wrap: nowrap;
        gap: 0.375rem;
        padding: 0.375rem 0.375rem;
    }

    .ingredient-row .ingredient-index {
        width: 1rem;
        flex-shrink: 0;
        font-size: 0.75rem;
    }

    .ingredient-row .ingredient-name-wrap {
        flex: 1 1 0%;
        min-width: 0;
    }

    .ingredient-row .ingredient-name-wrap textarea,
    .ingredient-row .ingredient-name-wrap input {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        font-size: 0.8125rem;
        min-height: 38px;
        line-height: 1.35;
    }

    .ingredient-row .ingredient-cost-wrap {
        flex: 0 0 5.75rem;
        width: 5.75rem;
        min-width: 0;
        margin-left: 0;
    }

    .ingredient-row .ingredient-cost-wrap input {
        padding-left: 1.5rem;
        padding-right: 0.25rem;
        font-size: 0.8125rem;
    }

    .ingredient-row .ingredient-cost-wrap span {
        left: 0.375rem;
        font-size: 0.6875rem;
    }

    .ingredient-row .delete-ingredient-btn,
    .ingredient-row .convert-ingredient-btn {
        flex: 0 0 auto;
        width: auto;
        min-width: auto;
        height: auto;
        min-height: auto;
    }
}

/* Print Stylesheet (Tanpa pustaka pihak ketiga sesuai AGENT.md) */
@media print {
    body {
        background: #ffffff !important;
        color: #0f172a !important;
        font-size: 11pt !important;
        line-height: 1.4 !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    #printableCostSheet {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    .print-break-inside-avoid {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    table {
        border-collapse: collapse !important;
        width: 100% !important;
    }

    th, td {
        border-color: #cbd5e1 !important;
    }
}

/* Animasi Halus & Glassmorphism */
.glass-panel {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Number input spinner cleaner */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.3;
}
input[type="number"]:hover::-webkit-inner-spin-button,
input[type="number"]:hover::-webkit-outer-spin-button {
    opacity: 0.8;
}

/* ==============================================================================
   CHANGELOG MODAL STYLES (Referensi KKMP 2026)
   ============================================================================== */

.changelog-modal-content {
    max-width: 620px;
    width: 100%;
    max-height: 85vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}

.changelog-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.changelog-modal-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.changelog-modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.changelog-modal-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    letter-spacing: 0.02em;
}

.changelog-modal-body {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: calc(85vh - 120px);
}

/* Timeline Release Block */
.changelog-release-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.changelog-release-block:last-child {
    border-bottom: none;
    padding-bottom: 4px;
}

.changelog-release-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.changelog-version-tag-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.changelog-version-tag {
    font-size: 0.95rem;
    font-weight: 800;
}

.changelog-status-pill {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background-color: rgba(148, 163, 184, 0.15);
    color: #64748b;
}

.dark .changelog-status-pill {
    background-color: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

.changelog-status-pill.latest {
    background-color: rgba(16, 185, 129, 0.14);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.changelog-release-date {
    font-size: 0.78rem;
    font-weight: 500;
}

.changelog-release-summary {
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0;
}

/* Item List */
.changelog-item-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.changelog-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.82rem;
    line-height: 1.45;
}

.changelog-pill-type {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 1px;
}

.changelog-pill-type.feat {
    background-color: rgba(59, 130, 246, 0.12);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.dark .changelog-pill-type.feat {
    color: #60a5fa;
}

.changelog-pill-type.improve {
    background-color: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.dark .changelog-pill-type.improve {
    color: #34d399;
}

.changelog-pill-type.fix {
    background-color: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.dark .changelog-pill-type.fix {
    color: #fbbf24;
}

.changelog-pill-type.security {
    background-color: rgba(168, 85, 247, 0.12);
    color: #9333ea;
    border: 1px solid rgba(168, 85, 247, 0.3);
}
.dark .changelog-pill-type.security {
    color: #c084fc;
}

.changelog-item-text {
    flex: 1;
}

@media (max-width: 640px) {
    .changelog-modal-content {
        max-height: 90vh;
    }
    
    .changelog-modal-header {
        padding: 14px 16px;
    }
    
    .changelog-modal-body {
        padding: 14px 16px;
        gap: 16px;
    }
    
    .changelog-item {
        font-size: 0.8rem;
    }
}

/* ==============================================================================
   SVG DONUT CHART & UNIT CONVERTER STYLES
   ============================================================================== */

/* SVG Donut Chart Transition & Glow */
.donut-slice {
    transition: stroke-dasharray 0.5s cubic-bezier(0.4, 0, 0.2, 1), stroke-dashoffset 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.donut-slice:hover {
    filter: drop-shadow(0 0 4px currentColor);
}

/* Convert Ingredient Button */
.convert-ingredient-btn {
    transition: all 0.15s ease-in-out;
}
.convert-ingredient-btn:hover {
    transform: scale(1.08);
}
.convert-ingredient-btn:active {
    transform: scale(0.95);
}

/* ==============================================================================
   FLOATING ACTION BUTTON: RESEP TERSIMPAN
   Selalu tampil di mobile (<640px), tersembunyi di desktop (≥640px).
   ============================================================================== */

/* Default: tampilkan FAB */
#savedRecipesFab {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Sembunyikan FAB di layar desktop (≥640px) */
@media (min-width: 640px) {
    #savedRecipesFab {
        display: none !important;
    }
}
