/* =========================================================
   1. CSS VARIABLES (Tema Global SaaS)
   ========================================================= */
:root {
    --sc-mac-red: #ff5f56;
    --sc-mac-yellow: #ffbd2e;
    --sc-mac-green: #27c93f;
    --sc-bg-overlay: rgba(15, 23, 42, 0.4);
    --sc-bg-window: #ffffff;
    --sc-toolbar-bg: #f8fafc;
    --sc-border-color: #e2e8f0;
    --sc-text-color: #64748b;
    --sc-accent-color: #3b82f6;
    --sc-radius-window: 16px;
}

/* =========================================================
   2. POPUP CONTAINER & BACKDROP
   ========================================================= */
.showcase-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
}

.showcase-popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--sc-bg-overlay);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body.showcase-popup-open {
    overflow: hidden !important; /* Satu-satunya yang butuh !important agar web tidak bisa di-scroll saat popup terbuka */
}

/* =========================================================
   3. SAAS WINDOW FRAME (Konsolidasi)
   ========================================================= */
.showcase-popup-content {
    position: relative;
    z-index: 2;
    background: var(--sc-bg-window);
    width: 90vw;
    max-width: 1400px;
    height: 85vh;
    border-radius: var(--sc-radius-window);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.98);
    opacity: 0;
    animation: scPopupIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes scPopupIn {
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* =========================================================
   4. SAAS TOOLBAR HEADER & PROTECTED BUTTONS
   ========================================================= */
.showcase-toolbar {
    background: var(--sc-toolbar-bg);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--sc-border-color);
    flex-shrink: 0;
    box-sizing: border-box;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    width: 120px;
}

.toolbar-right {
    justify-content: flex-end;
    gap: 16px;
}

/* Spesifisitas tinggi agar kebal dari gaya tombol tema bawaan */
.showcase-popup .showcase-toolbar button.showcase-action-btn,
.showcase-popup .showcase-toolbar button.frame-option {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.showcase-popup .showcase-action-btn {
    color: var(--sc-text-color);
    width: 32px;
    height: 32px;
    font-size: 20px;
}

.showcase-popup .showcase-action-btn:hover {
    color: var(--sc-mac-red);
}

.showcase-popup a.showcase-action-btn.external-link {
    color: var(--sc-text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.showcase-popup a.showcase-action-btn.external-link:hover,
.showcase-popup button.showcase-action-btn.toggle-info:hover {
    color: var(--sc-accent-color);
}

/* Traffic Lights (Mac) */
.showcase-traffic-lights {
    display: flex;
    gap: 8px;
}
.showcase-traffic-lights i {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: block;
}
.showcase-traffic-lights i:nth-child(1) { background: var(--sc-mac-red); }
.showcase-traffic-lights i:nth-child(2) { background: var(--sc-mac-yellow); }
.showcase-traffic-lights i:nth-child(3) { background: var(--sc-mac-green); }

/* Frame Options */
.frame-options {
    display: flex;
    gap: 4px;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 8px;
}

.showcase-popup .frame-option {
    width: 40px;
    height: 32px;
    border-radius: 6px;
    color: var(--sc-text-color);
}

.showcase-popup .frame-option:hover {
    color: #0f172a;
}

.showcase-popup .frame-option.active {
    background: var(--sc-bg-window);
    color: var(--sc-accent-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* =========================================================
   5. IFRAME & DEVICE MOCKUP RESPONSIVE (REAL DEVICE FIX)
   ========================================================= */
.iframe-container {
    flex: 1 1 0;
    position: relative;
    background: #f1f5f9;
    display: flex;
    justify-content: center;
    /* PENTING 1: Ubah align-items agar tidak terpotong saat di-scroll */
    align-items: flex-start; 
    padding: 32px;
    box-sizing: border-box;
    /* PENTING 2: Izinkan area abu-abu di-scroll jika layar monitor kekecilan */
    overflow-y: auto; 
    overflow-x: hidden;
}

.device-mockup-frame {
    background: var(--sc-bg-window);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    
    /* PENTING 3: Margin auto menjaga frame tetap di tengah */
    margin: auto; 
    /* PENTING 4: Melarang browser menyusutkan frame ini dengan paksa */
    flex-shrink: 0; 
    
    transition: width 0.4s ease, height 0.4s ease, border-radius 0.4s ease, border 0.4s ease;
}

.showcase-iframe {
    width: 100%;
    height: 100%;
    flex-grow: 1;
    border: none;
    display: block;
    background: #ffffff;
}

/* --- Pengaturan Ukuran Tiap Device --- */

/* Desktop: Boleh menyusut mengikuti ukuran Pop-up */
.view-desktop .device-mockup-frame {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 0 solid transparent;
    flex-shrink: 1; /* Khusus desktop boleh menyusut */
}

/* Tablet: HARGA MATI 768px x 1024px (Proporsi iPad Asli) */
.view-tablet .device-mockup-frame {
    width: 768px;
    height: 1024px;
    border-radius: 12px;
    border: 0 solid transparent;
}

/* Mobile: HARGA MATI 375px x 812px (Proporsi iPhone Asli) */
.view-mobile .device-mockup-frame {
    width: 375px;
    height: 812px;
    border-radius: 24px;
    border: 2px solid #0f172a;
}

/* Indikator Loading */
.iframe-container.is-loading .device-mockup-frame::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--sc-accent-color);
    border-radius: 50%;
    animation: scSpin 0.8s linear infinite;
    z-index: 10;
}
.iframe-container.is-loading .showcase-iframe { opacity: 0; }
@keyframes scSpin { to { transform: rotate(360deg); } }

/* =========================================================
   6. PROJECT INFO SIDEBAR
   ========================================================= */
.showcase-info-sidebar {
    position: absolute;
    top: 60px;
    right: -400px;
    width: 350px;
    height: calc(100% - 60px);
    background: var(--sc-bg-window);
    border-left: 1px solid var(--sc-border-color);
    z-index: 50;
    transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: -10px 0 25px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.showcase-popup-content.sidebar-open .showcase-info-sidebar {
    right: 0;
}

/* Menggeser Iframe saat sidebar terbuka */
.showcase-popup-content.sidebar-open .iframe-container {
    padding-right: 382px; 
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--sc-border-color);
}

.sidebar-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
}

.showcase-popup .close-sidebar {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--sc-text-color);
    cursor: pointer;
    padding: 0;
}

.sidebar-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
    color: #475569;
    font-size: 14px;
    line-height: 1.6;
}

/* =========================================================
   7. SHOWCASE GRID LAYOUT & CARDS
   ========================================================= */
.showcase-grid-wrapper {
    display: grid;
}

/* Specificity boost for grid items */
.showcase-grid-wrapper .showcase-grid-item {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--sc-border-color); 
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    text-align: left;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.showcase-grid-wrapper .showcase-grid-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.showcase-grid-item-image {
    width: 100%;
    aspect-ratio: 16/9;
    position: relative;
    overflow: hidden;
    background: #f1f5f9;
}

.showcase-grid-image-inner {
    width: 100%;
    height: 100%;
}

.showcase-grid-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.showcase-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.showcase-grid-overlay i {
    color: #ffffff;
    font-size: 32px;
    transform: translateY(10px);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.showcase-grid-item:hover .showcase-grid-overlay { opacity: 1; }
.showcase-grid-item:hover .showcase-grid-overlay i { transform: translateY(0); }
.showcase-grid-item:hover .showcase-grid-item-image img { transform: scale(1.05); }

.showcase-grid-item-content {
    padding: 20px 24px;
    background: #ffffff;
    border-top: 1px solid var(--sc-border-color);
    flex-grow: 1;
}

.showcase-grid-item-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
}

/* =========================================================
   8. FILTER BAR
   ========================================================= */
.showcase-filter-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.showcase-filter-bar .showcase-filter-btn {
    padding: 8px 18px;
    background: #f1f5f9;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    color: var(--sc-text-color);
    transition: all 0.3s ease;
}

.showcase-filter-bar .showcase-action-btn.active, 
.showcase-filter-bar .showcase-filter-btn:hover {
    background: var(--sc-accent-color);
    color: #ffffff;
}

/* =========================================================
   DASAR CSS SMART FILTER BUTTON
   ========================================================= */

.showcase-filter-container {
    /* Flexbox dasar agar kontrol alignment elementor berfungsi */
    display: flex;
    flex-wrap: wrap; 
    margin-bottom: 30px; /* Jarak antara filter dan grid portfolio */
}

.showcase-filter-btn {
    cursor: pointer;
    border: none;
    outline: none;
    /* Transisi mulus yang akan mengeksekusi perubahan warna Elementor */
    transition: all 0.3s ease-in-out; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

/* =========================================================
   9. TRIGGER BUTTON ALIGNMENT
   ========================================================= */
.showcase-trigger.elementor-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    gap: 8px;
}

.showcase-trigger.elementor-button .elementor-button-icon {
    display: inline-flex;
    align-items: center;
}

.showcase-trigger.elementor-button .elementor-button-icon i {
    margin: 0;
}

/* =========================================================
   10. DEVICE FRAME STYLES (WINDOWS & MINIMAL)
   ========================================================= */
.showcase-popup-content.style-windows { border-radius: 8px; }
.showcase-popup-content.style-windows .showcase-traffic-lights { display: none; }

/* Menimpa tombol close khusus style windows dengan spesifisitas */
.showcase-popup .showcase-popup-content.style-windows button.showcase-close-button {
    border-radius: 0;
    width: 48px;
    height: 100%;
    margin: -15px -24px -15px 0;
}
.showcase-popup .showcase-popup-content.style-windows button.showcase-close-button:hover {
    background-color: #e81123;
    color: #ffffff;
}

.showcase-popup-content.style-minimal {
    background-color: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
}
.showcase-popup-content.style-minimal .showcase-traffic-lights { display: none; }
.showcase-popup-content.style-minimal .showcase-toolbar {
    background-color: #0f172a;
    border-bottom: 1px solid #1e293b;
}
.showcase-popup-content.style-minimal .iframe-container { background-color: #020617; }

/* Penyesuaian mode gelap */
.showcase-popup .showcase-popup-content.style-minimal button.frame-option { color: #94a3b8; background: transparent; }
.showcase-popup-content.style-minimal .frame-options { background-color: #1e293b; }
.showcase-popup .showcase-popup-content.style-minimal button.frame-option.active { background-color: #334155; color: #38bdf8; box-shadow: none; }

.showcase-popup .showcase-popup-content.style-minimal button.showcase-action-btn,
.showcase-popup .showcase-popup-content.style-minimal a.showcase-action-btn { color: #94a3b8; }

.showcase-popup .showcase-popup-content.style-minimal button.showcase-action-btn:hover,
.showcase-popup .showcase-popup-content.style-minimal a.showcase-action-btn:hover { color: #ffffff; }

.showcase-popup-content.style-minimal .view-mobile .device-mockup-frame { border-color: #1e293b; }

.showcase-popup-content.style-minimal .showcase-info-sidebar {
    background: #0f172a;
    border-left-color: #1e293b;
}
.showcase-popup-content.style-minimal .sidebar-header { border-bottom-color: #1e293b; }
.showcase-popup-content.style-minimal .sidebar-header h4 { color: #e2e8f0; }
.showcase-popup-content.style-minimal .sidebar-body { color: #94a3b8; }

/* =========================================================
   11. RESPONSIVE MOBILE TWEAKS
   ========================================================= */
@media (max-width: 768px) {
    .showcase-popup-content { width: 100vw; height: 100vh; border-radius: 0; }
    .showcase-traffic-lights { display: none; }
    .showcase-toolbar { padding: 0 16px; }
    .iframe-container { padding: 0; }
    .view-mobile .device-mockup-frame, .view-tablet .device-mockup-frame, .view-desktop .device-mockup-frame {
        border: none; border-radius: 0; width: 100%; height: 100%;
    }
    .showcase-info-sidebar { width: 100%; right: -100%; }
    .showcase-popup-content.sidebar-open .iframe-container { padding-right: 0; }
}

/* =========================================================
   ELEMENTOR EDITOR PERFORMANCE FIX
   Mencegah lag/freeze saat pengguna sedang mengedit halaman
   ========================================================= */

/* Matikan efek Blur yang memakan banyak CPU di Editor */
body.elementor-editor-active .showcase-popup-backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: transparent !important;
}

/* Matikan transisi agar tidak terjadi render-loop saat digeser */
body.elementor-editor-active .device-mockup-frame,
body.elementor-editor-active .showcase-grid-item,
body.elementor-editor-active .showcase-grid-item-image img {
    transition: none !important; 
}

/* Kunci mati Pop-up agar tidak mengganggu interaksi klik di Editor */
body.elementor-editor-active .showcase-popup {
    display: none !important; 
    pointer-events: none !important;
}