/* ============================================================
   SUPERTIK - ULTIMATE MOBILE STABILITY & PERFORMANCE CSS
   ============================================================ */

:root {
    --bg-primary: #0a0a12;
    --bg-secondary: #10101a;
    --accent-primary: #00d9ff;
    --accent-secondary: #8a2be2;
    --accent-tertiary: #ff2d75;
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --card-bg: rgba(16, 16, 26, 0.85);
    --card-border: rgba(0, 217, 255, 0.15);
    --success: #00ff9d;
    --warning: #ffb800;
    --error: #ff4757;
    --glow-primary: 0 0 20px rgba(0, 217, 255, 0.3);
    --glow-secondary: 0 0 20px rgba(138, 43, 226, 0.2);
}

/* ============================================================
   GLOBAL RESET & ANTI-OVERFLOW FOUNDATION
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Cegah scroll horizontal di semua browser (fallback clip -> hidden) */
html {
    overflow-x: hidden;
    overflow-x: clip; /* Didukung modern, fallback hidden sudah ada */
    width: 100%;
    max-width: 100vw;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-x: clip;
    position: relative;
    width: 100%;
    max-width: 100vw;
    /* Nonaktifkan pull-to-refresh yang bisa menyebabkan zoom tak terduga */
    overscroll-behavior: none;
}

/* ============================================================
   BACKGROUND OPTIMIZATION (LOW GPU IMPACT)
   ============================================================ */
.bg-geometric {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
    /* GPU acceleration hanya untuk container */
    transform: translateZ(0);
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.12; /* Kurangi opacity untuk mengurangi beban blending */
    /* Hapus filter blur di mobile via media query, gunakan fallback box-shadow untuk efek lembut */
    filter: blur(60px);
    /* Batasi area render dengan will-change hanya jika diperlukan */
    will-change: auto;
    /* Animasi dihentikan di mobile */
    animation: none;
    /* Batasi ukuran absolut */
    max-width: 100vw;
    max-height: 100vh;
}

/* Desktop hanya: aktifkan animasi & blur */
@media (min-width: 769px) {
    .shape {
        animation: float 25s infinite linear;
        will-change: transform;
    }
}

.shape-1 {
    width: min(500px, 70vw);
    height: min(500px, 70vw);
    background: radial-gradient(circle, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    top: -10vh;
    left: -10vw;
}

.shape-2 {
    width: min(400px, 60vw);
    height: min(400px, 60vw);
    background: radial-gradient(circle, var(--accent-tertiary) 0%, var(--accent-secondary) 100%);
    bottom: -10vh;
    right: -10vw;
}

.shape-3 {
    width: min(300px, 50vw);
    height: min(300px, 50vw);
    background: radial-gradient(circle, var(--accent-primary) 0%, var(--accent-tertiary) 100%);
    top: 60%;
    right: 5%;
}

.grid-lines {
    position: fixed;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 217, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 217, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: -1;
    opacity: 0.2;
    pointer-events: none;
    transform: translateZ(0);
}

/* ============================================================
   MAIN LAYOUT - ZERO OVERFLOW GUARANTEE
   ============================================================ */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 0.7fr;
    gap: 25px;
    min-height: 100vh;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
    /* Fallback untuk clip */
    overflow-x: hidden;
    overflow-x: clip;
}

/* ============================================================
   CARDS - NO BACKDROP BLUR ON MOBILE (PERFORMANCE)
   ============================================================ */
.card {
    background: var(--card-bg);
    /* Backdrop blur hanya di desktop */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    transition: none;
    width: 100%;
    box-sizing: border-box;
    /* Fallback background solid jika rgba tidak didukung */
    background-color: #10101a;
}

@media (min-width: 769px) {
    .card {
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .card:hover {
        transform: translateY(-3px);
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    }
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

/* ============================================================
   MAIN SECTION - STABLE HEIGHT PREVENT LAYOUT SHIFT
   ============================================================ */
.main-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Tinggi minimum mencegah loader mengubah layout */
    min-height: 480px;
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(1.5rem, 6vw, 1.8rem);
    font-weight: 800;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.logo-icon {
    font-size: 2rem;
    color: var(--accent-primary);
}

.version-badge {
    background: rgba(0, 217, 255, 0.1);
    border: 1px solid rgba(0, 217, 255, 0.3);
    padding: 6px 15px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.hero-title {
    font-size: clamp(2rem, 8vw, 3.2rem);
    line-height: 1.15;
    font-weight: 800;
    margin-bottom: 5px;
    background: linear-gradient(to right, #fff, var(--accent-primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-subtitle {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 3.5vw, 1rem);
    max-width: 600px;
    line-height: 1.5;
}

/* ============================================================
   INPUT - NO ZOOM (16px FONT)
   ============================================================ */
.input-container {
    margin-top: 10px;
}

.input-wrapper {
    display: flex;
    background: rgba(10, 10, 18, 0.9);
    border-radius: 20px;
    border: 2px solid rgba(0, 217, 255, 0.2);
    overflow: hidden;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
}

.input-icon {
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 217, 255, 0.05);
    color: var(--accent-primary);
    font-size: 1.2rem;
}

#urlInput {
    flex: 1;
    padding: 18px 15px;
    background: transparent;
    border: none;
    color: white;
    font-size: 16px; /* Wajib 16px anti-zoom */
    font-family: 'JetBrains Mono', monospace;
    outline: none;
    min-width: 0;
}

#urlInput::placeholder {
    color: rgba(160, 160, 192, 0.5);
    font-size: 16px;
}

/* ============================================================
   BUTTONS - OPTIMIZED TOUCH & NO TRANSFORM GLITCH
   ============================================================ */
.btn-hexagon {
    margin-top: 20px;
    position: relative;
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 18px;
    color: white;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    letter-spacing: 1px;
    box-shadow: var(--glow-primary);
    overflow: hidden;
    z-index: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    transition: none;
}

/* Desktop hover */
@media (min-width: 769px) {
    .btn-hexagon {
        transition: transform 0.2s, box-shadow 0.2s;
    }
    .btn-hexagon:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 25px rgba(0, 217, 255, 0.4);
    }
}

.btn-hexagon:active {
    transform: scale(0.98);
    transition: transform 0.1s;
}

.btn-hexagon:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: var(--glow-primary) !important;
}

.btn-hexagon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    z-index: -1;
    opacity: 0;
    transition: opacity 0.2s;
}

.btn-hexagon:hover::before {
    opacity: 1;
}

/* ============================================================
   RESULT PANEL - SMOOTH APPEARANCE
   ============================================================ */
.result-panel {
    margin-top: 25px;
    display: none;
    animation: fadeInUp 0.3s ease;
    width: 100%;
}

.video-card-modern {
    background: rgba(20, 20, 30, 0.8);
    border-radius: 24px;
    padding: 20px;
    border: 1px solid rgba(0, 217, 255, 0.1);
    width: 100%;
}

.video-content {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 20px;
    align-items: center;
}

.thumbnail-container {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.thumbnail-container img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.video-title {
    font-size: clamp(1rem, 4vw, 1.3rem);
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-author {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.download-options {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.btn-download-option {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 14px; /* sedikit di bawah 16px tidak masalah untuk tombol kecil */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: none;
}

@media (min-width: 769px) {
    .btn-download-option {
        font-size: 15px;
        transition: transform 0.2s, box-shadow 0.2s;
    }
    .btn-download-option:hover {
        transform: translateY(-2px);
    }
}

.btn-download-option:active {
    transform: scale(0.97);
}

.btn-hd {
    background: linear-gradient(135deg, var(--accent-primary), #0066ff);
    color: white;
}

.btn-audio {
    background: linear-gradient(135deg, var(--accent-secondary), #b300ff);
    color: white;
}

/* ============================================================
   SIDEBAR - STABLE
   ============================================================ */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.stats-widget {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-item {
    background: rgba(20, 20, 30, 0.7);
    border-radius: 18px;
    padding: 18px 10px;
    text-align: center;
    border: 1px solid rgba(0, 217, 255, 0.1);
}

.stat-value {
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    font-weight: 800;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.activity-widget {
    height: 260px;
    display: flex;
    flex-direction: column;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 10px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--success);
    font-size: 0.75rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.activity-log {
    flex: 1;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.85rem;
}

.log-time {
    font-family: monospace;
    color: var(--accent-primary);
    min-width: 65px;
}

.features-widget {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px;
    background: rgba(0, 217, 255, 0.05);
    border-radius: 18px;
}

.feature-icon {
    font-size: 1.8rem;
    color: var(--accent-primary);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
}

/* ============================================================
   LOADER - NO LAYOUT SHIFT
   ============================================================ */
.loader {
    margin-top: 20px;
    display: none;
}

.loader-bar {
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
}

.loader-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    width: 0%;
    animation: loading 1.2s infinite;
    transform: translateZ(0); /* GPU accelerate */
}

.loader-text {
    text-align: center;
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ============================================================
   ERROR MESSAGE
   ============================================================ */
.error-message {
    margin-top: 15px;
    padding: 14px;
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 12px;
    color: var(--error);
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}

/* ============================================================
   ANIMATIONS - LOW IMPACT
   ============================================================ */
@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(15px, 15px) rotate(45deg); }
    50% { transform: translate(0, 25px) rotate(90deg); }
    75% { transform: translate(-15px, 15px) rotate(135deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

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

/* ============================================================
   RESPONSIVE BREAKPOINTS - GUARANTEE NO OVERFLOW
   ============================================================ */
@media (max-width: 1100px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 15px;
        gap: 20px;
    }
    .card {
        padding: 20px;
    }
    .main-section {
        min-height: 440px;
    }
    .video-content {
        grid-template-columns: 1fr;
    }
    .thumbnail-container img {
        height: auto;
        max-height: 220px;
    }
    .download-options {
        flex-direction: column;
    }
    /* Matikan blur di mobile */
    .shape {
        filter: none;
        opacity: 0.08;
        background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.8rem;
    }
    .btn-hexagon {
        padding: 16px;
        font-size: 15px;
    }
    .input-wrapper {
        flex-direction: column;
    }
    .input-icon {
        padding: 12px;
    }
}

/* ============================================================
   ULTIMATE FIXES FOR OLD BROWSERS
   ============================================================ */
@supports not (overflow-x: clip) {
    html, body {
        overflow-x: hidden;
    }
}

/* Pastikan semua elemen interaktif tidak menyebabkan zoom */
input, button, textarea, select {
    font-size: 16px;
}

/* Batasi penggunaan touch-action global */
body {
    touch-action: pan-y; /* Hanya scroll vertikal */
}

button, .btn-hexagon, .btn-download-option, .input-wrapper {
    touch-action: manipulation;
}

/* Nonaktifkan pull-to-refresh di Chrome */
body {
    overscroll-behavior-y: contain;
}
