/**
 * LetFlo — Custom Styles with Dark Mode
 * Mobile-first responsive overrides, micro-animations, and dark mode.
 *
 * Dark mode: Diaktifkan dengan class "dark" pada <html> element.
 * Transisi smooth saat switch mode menggunakan class "theme-transitioning".
 *
 * @author LetFlo
 * @since 1.0
 */

/* ============================================================
   THEME TRANSITION
   Smooth color transition saat switch dark/light mode.
   ============================================================ */

.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ============================================================
   STRICT RESPONSIVE LAYOUT LOCKING & OVERFLOW GUARDS
   ============================================================ */
html, body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    touch-action: manipulation;
    -webkit-overflow-scrolling: touch;
}

/* Enforce fluid responsiveness for images and media */
img, video, iframe, canvas, svg {
    max-width: 100%;
}

/* Hide Yii Debug Toolbar */
#yii-debug-toolbar, #yii-debug-toolbar-min, .yii-debug-toolbar {
    display: none !important;
}

/* ============================================================
   FORM ELEMENTS — guard overflow (bukan aturan dark mode)
   ============================================================ */

input,
select,
textarea {
    box-sizing: border-box !important;
    max-width: 100% !important;
    min-width: 0 !important;
}

input[type="date"] {
    display: block;
    width: 100%;
}


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

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-scale-in {
    animation: scaleIn 0.2s ease-out forwards;
}

.animate-pulse-soft {
    animation: pulse-soft 2s ease-in-out infinite;
}

.animate-spin-slow {
    animation: spin-slow 1s linear infinite;
}

/* Stagger children animations */
.stagger-children > * {
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.10s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.20s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.30s; }

/* ============================================================
   CUSTOM SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================================
   GLASSMORPHISM CARD
   ============================================================ */

.glass-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ============================================================
   MOBILE TOUCH TARGETS (min 44px)
   ============================================================ */

@media (max-width: 640px) {
    button, a.btn, [role="button"],
    input[type="button"], input[type="submit"] {
        min-height: 44px;
    }

    /* Full-width buttons on mobile */
    .mobile-full {
        width: 100%;
    }

    /* Bottom sheet modal style on mobile */
    .modal-mobile-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 90vh;
        border-radius: 1.5rem 1.5rem 0 0;
        animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Safe area for notch phones */
    .safe-bottom {
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
}

/* ============================================================
   TABLE RESPONSIVE HELPERS
   ============================================================ */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   BADGE STYLES
   ============================================================ */

.badge-in {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-out {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-low-stock {
    background-color: #fef3c7;
    color: #92400e;
    animation: pulse-soft 2s ease-in-out infinite;
}

/* ============================================================
   BARCODE SCANNER STYLES
   ============================================================ */

.scanner-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.scanner-container video {
    width: 100%;
    border-radius: 12px;
}

.scanner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-frame {
    width: 250px;
    height: 150px;
    border: 2px solid rgba(99, 102, 241, 0.8);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.scanner-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #6366f1, transparent);
    animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
    0%, 100% { top: 20%; }
    50% { top: 80%; }
}

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */

.theme-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* ============================================================
   INVOICE GROUP CARD
   ============================================================ */

.invoice-group {
    border-left: 3px solid #6366f1;
    padding-left: 12px;
    margin-bottom: 16px;
}

.dark .invoice-group {
    border-left-color: #818cf8;
}

/* ============================================================
   PERIOD FILTER BUTTONS
   ============================================================ */

.period-btn {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.period-btn.active {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.period-btn:not(.active) {
    background: #f1f5f9;
    color: #64748b;
}

.period-btn:not(.active):hover {
    background: #e2e8f0;
    color: #334155;
}

.dark .period-btn:not(.active) {
    background: #334155;
    color: #94a3b8;
}

.dark .period-btn:not(.active):hover {
    background: #475569;
    color: #e2e8f0;
}

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

.chart-container {
    position: relative;
    width: 100%;
    min-height: 280px;
    max-height: 340px;
}

@media (max-width: 640px) {
    .chart-container {
        min-height: 240px;
        max-height: 270px;
    }
}

/* ============================================================
   GRADIENT HELPERS
   ============================================================ */

.gradient-blue {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.gradient-emerald {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.gradient-amber {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.gradient-rose {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
}

.gradient-purple {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

/* ============================================================
   GEN Z & CYBERPUNK PREMIUM UTILITIES
   ============================================================ */

/* Glassmorphism Cards */
.glass-card {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
}

.dark .glass-card {
    background: rgba(15, 23, 42, 0.45) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
}

/* Hover Scale Animation */
.hover-scale {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease !important;
}

.hover-scale:hover {
    transform: translateY(-4px) scale(1.015) !important;
}

/* Glowing Neon Shadows */
.shadow-neon-primary:hover {
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.25), 0 0 15px rgba(99, 102, 241, 0.2) !important;
    border-color: rgba(99, 102, 241, 0.5) !important;
}

.dark .shadow-neon-primary:hover {
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.35), 0 0 10px rgba(129, 140, 248, 0.25) !important;
    border-color: rgba(129, 140, 248, 0.5) !important;
}

.shadow-neon-cyan:hover {
    box-shadow: 0 10px 25px -5px rgba(6, 182, 212, 0.15), 0 8px 10px -6px rgba(6, 182, 212, 0.15) !important;
}

.dark .shadow-neon-cyan:hover {
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.25) !important;
}

/* Custom Minimalist Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.2);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.4);
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   FIX: KONTEN KARTU (BADGES) TERPOTONG
   Kartu summary memakai `overflow-hidden` untuk mengkliping
   ornamen blur, tapi ikut memotong baris badge di bagian bawah.
   Beri ruang bawah + izinkan badge membungkus (wrap) agar tidak
   terpotong pada layar sempit / grid 2 kolom.
   ============================================================ */
.card-badges {
    flex-wrap: wrap;
    column-gap: 0.75rem; /* pengganti space-x-3 yang rusak saat wrap */
    row-gap: 0.375rem;
}

/* ============================================================
   OFFSET HEADER TETAP
   Header ber-position:fixed setinggi 64px, jadi konten di bawahnya
   perlu padding atas sebesar itu. Didefinisikan di SATU tempat ini
   (sebelumnya juga disalin ke blok <style> inline di main.php).
   ============================================================ */
.fixed-header-padding {
    padding-top: 64px;
}

