/* =========================================================
   LivePro 1.0.0 - Responsive UI
   Desktop, tablet, and mobile
   Storage mobile explorer v2
   ========================================================= */

:root {
    --livepro-mobile-header: 64px;
}

html,
body {
    width: 100%;
    max-width: 100%;
}

body.app-shell,
.app-main,
.app-content {
    min-width: 0;
}

.app-content {
    width: 100%;
    max-width: 1920px;
    margin-left: auto;
    margin-right: auto;
}

.desktop-sidebar {
    flex: 0 0 auto;
}

.mobile-nav-shell {
    display: none;
}

button,
input,
select,
textarea {
    max-width: 100%;
}

button,
select,
input[type="checkbox"],
input[type="radio"] {
    touch-action: manipulation;
}

#task-grid > *,
#tab-storage > .grid > *,
#tab-storage > .grid.grid-cols-2 > * {
    min-width: 0;
}

@media (min-width: 768px) {
    body.app-shell {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .desktop-sidebar {
        position: sticky;
        top: 0;
        align-self: flex-start;
        height: 100vh;
        height: 100dvh;
    }

    .app-main {
        height: 100vh;
        height: 100dvh;
    }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .desktop-sidebar {
        width: 14rem !important;
    }

    .desktop-sidebar > div:first-child {
        padding: 1rem !important;
    }

    .desktop-sidebar nav {
        padding-left: .625rem !important;
        padding-right: .625rem !important;
    }

    .desktop-sidebar .nav-btn {
        padding-left: .75rem !important;
        padding-right: .75rem !important;
        gap: .625rem !important;
    }

    .app-content {
        padding: 1.25rem !important;
    }

    .dashboard-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .dashboard-stats-grid > div:last-child {
        grid-column: 1 / -1;
    }
}

@media (min-width: 1440px) {
    .app-content {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }
}

@media (max-width: 767.98px) {
    html,
    body {
        min-height: 100%;
        overflow-x: hidden;
    }

    body.app-shell {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .desktop-sidebar {
        display: none !important;
    }

    .mobile-nav-shell {
        display: block;
        position: sticky;
        top: 0;
        z-index: 55;
        width: 100%;
        padding-top: max(.625rem, env(safe-area-inset-top));
        padding-right: max(.75rem, env(safe-area-inset-right));
        padding-bottom: .625rem;
        padding-left: max(.75rem, env(safe-area-inset-left));
        background: rgba(255, 255, 255, .96);
        border-bottom: 1px solid #e2e8f0;
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        box-shadow: 0 4px 16px rgba(15, 23, 42, .08);
    }

    .dark .mobile-nav-shell {
        background: rgba(15, 23, 42, .96);
        border-bottom-color: rgba(51, 65, 85, .8);
        box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
    }

    .mobile-nav-inner {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: .625rem;
        width: 100%;
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: .5rem;
        min-width: 0;
    }

    .mobile-brand-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: none;
        width: 2.5rem;
        height: 2.5rem;
        border-radius: .75rem;
        color: #fff;
        background: #6366f1;
        box-shadow: 0 5px 14px rgba(99, 102, 241, .28);
    }

    .mobile-brand-icon svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .mobile-brand-text {
        white-space: nowrap;
        font-size: .8rem;
        line-height: 1;
        font-weight: 900;
        color: #1e293b;
    }

    .dark .mobile-brand-text {
        color: #fff;
    }

    .mobile-nav-select {
        width: 100%;
        min-width: 0;
        height: 2.5rem;
        font-size: .8rem !important;
    }

    .mobile-logout-form {
        flex: none;
    }

    .mobile-logout {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        border: 1px solid #fecaca;
        border-radius: .75rem;
        color: #ef4444;
        background: #fef2f2;
    }

    .dark .mobile-logout {
        border-color: rgba(239, 68, 68, .25);
        color: #f87171;
        background: rgba(239, 68, 68, .1);
    }

    .mobile-logout svg {
        width: 1.1rem;
        height: 1.1rem;
    }

    .app-main {
        flex: 1 1 auto;
        width: 100%;
        height: auto !important;
        min-height: calc(100vh - var(--livepro-mobile-header));
        min-height: calc(100dvh - var(--livepro-mobile-header));
        overflow: visible !important;
    }

    .app-content {
        width: 100%;
        padding-top: .75rem !important;
        padding-right: max(.75rem, env(safe-area-inset-right)) !important;
        padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
        padding-left: max(.75rem, env(safe-area-inset-left)) !important;
    }

    #toast-container {
        top: calc(var(--livepro-mobile-header) + .75rem) !important;
        left: .75rem !important;
        right: .75rem !important;
        width: auto !important;
    }

    #toast-container > div {
        width: 100%;
        max-width: none;
    }

    /* DASHBOARD */

    .dashboard-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: .625rem !important;
        margin-bottom: 1rem !important;
    }

    .dashboard-stats-grid > div {
        min-height: 80px;
        padding: .75rem !important;
        border-radius: .9rem !important;
    }

    .dashboard-stats-grid > div:last-child {
        grid-column: 1 / -1;
    }

    .dashboard-section-head {
        flex-direction: column;
        align-items: stretch !important;
        gap: .75rem;
        margin-bottom: 1rem !important;
    }

    .dashboard-section-head h2 {
        font-size: 1.1rem !important;
    }

    .dashboard-section-head button {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    #task-grid {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: .75rem !important;
        padding-bottom: 1rem !important;
    }

    #task-grid > div {
        min-width: 0;
        padding: 1rem !important;
        border-radius: 1rem !important;
        transform: none !important;
    }

    #task-grid > div > div:nth-child(2) {
        flex-wrap: wrap;
        gap: .625rem;
    }

    #task-grid > div > div:nth-child(2) > div:first-child {
        flex: 1 1 12rem;
        min-width: 0;
        max-width: 100% !important;
    }

    #task-grid > div > div:last-child {
        flex-wrap: wrap;
        gap: .5rem !important;
    }

    #task-grid > div > div:last-child > button {
        flex: 1 1 7rem;
        min-height: 44px;
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }

    #task-empty-state {
        padding: 3rem 1rem !important;
    }

    /* LIVE FORM */

    #tab-buat-live > .mb-6 {
        flex-direction: column;
        align-items: stretch !important;
        gap: .75rem;
        margin-bottom: 1rem !important;
    }

    #tab-buat-live > .mb-6 #btn-cancel-edit {
        width: 100%;
        min-height: 44px;
    }

    #tab-buat-live > .bg-white > .grid > div {
        padding: 1rem !important;
    }

    #tab-buat-live > .bg-white > .p-6 {
        padding: 1rem !important;
    }

    #tab-buat-live input:not([type="checkbox"]):not([type="radio"]),
    #tab-buat-live select {
        min-height: 44px;
    }

    #container-order > .flex {
        flex-wrap: wrap;
        gap: .5rem !important;
    }

    #container-order > .flex > label {
        min-width: 8rem;
    }

    /* STORAGE SUMMARY */

    #tab-storage > .grid.grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: .625rem !important;
        margin-bottom: 1rem !important;
    }

    #tab-storage > .grid.grid-cols-2 > div {
        min-width: 0;
        padding: .75rem !important;
    }

    #tab-storage > div:nth-child(3) {
        padding: .875rem !important;
        margin-bottom: 1rem !important;
    }

    #tab-storage > div:nth-child(3) > div {
        align-items: stretch !important;
    }

    #btn-clean-partials {
        width: 100%;
        min-height: 44px;
    }

    #tab-storage > .grid.grid-cols-1 {
        gap: 1rem !important;
    }

    #tab-storage > .grid.grid-cols-1 > div:first-child > div {
        padding: 1rem !important;
    }

    #tab-storage > .grid.grid-cols-1 > div:last-child > div {
        height: min(65vh, 560px) !important;
        height: min(65dvh, 560px) !important;
        min-height: 360px;
    }

    /* STORAGE EXPLORER V2 */

    #file-container {
        padding: .5rem !important;
    }

    #file-container > .sticky {
        margin-bottom: .5rem !important;
        padding: .55rem .65rem !important;
        border-radius: .75rem !important;
        box-shadow: none !important;
    }

    #file-container > .sticky > div {
        align-items: center !important;
        flex-wrap: wrap;
        gap: .4rem !important;
    }

    #file-container > .group {
        width: 100%;
        min-width: 0;
        margin-bottom: .35rem !important;
        padding: .65rem !important;
        gap: .5rem !important;
        border-radius: .75rem !important;
        box-shadow: none !important;
        border-color: rgba(203, 213, 225, .65) !important;
        background: rgba(255, 255, 255, .72);
    }

    .dark #file-container > .group {
        border-color: rgba(51, 65, 85, .72) !important;
        background: rgba(15, 23, 42, .28);
    }

    /* Folder tetap satu baris: icon + nama + action. */
    #file-container > .group:has(> button:first-child) {
        flex-direction: row !important;
        align-items: center !important;
    }

    #file-container > .group > button:first-child {
        width: auto !important;
        min-width: 0;
        flex: 1 1 auto;
        gap: .7rem !important;
    }

    /* File: info kiri, action compact di bawah kanan. */
    #file-container > .group:has(> div:first-child) {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #file-container > .group > div:first-child {
        width: 100%;
        min-width: 0;
        gap: .7rem !important;
    }

    #file-container > .group .w-12.h-12 {
        width: 2.5rem !important;
        height: 2.5rem !important;
        border-radius: .65rem !important;
    }

    #file-container > .group .w-6.h-6 {
        width: 1.15rem !important;
        height: 1.15rem !important;
    }

    #file-container > .group .text-sm.font-black {
        font-size: .82rem !important;
        line-height: 1.1rem !important;
    }

    /* Path penuh tidak perlu memenuhi layar mobile. */
    #file-container > .group > div:first-child > div.truncate.flex-1 > div:nth-child(2) {
        display: none;
    }

    /* Metadata lebih rapat. */
    #file-container > .group > div:first-child > div.truncate.flex-1 > div:last-child {
        margin-top: .35rem !important;
        gap: .3rem !important;
    }

    #file-container > .group > div:first-child > div.truncate.flex-1 > div:last-child > span {
        padding: .15rem .4rem !important;
        font-size: 9px !important;
        line-height: .85rem !important;
    }

    /* Action selalu terlihat tetapi tidak membentuk kotak besar. */
    #file-container > .group > div:last-child {
        opacity: 1 !important;
        flex: none;
        gap: .2rem !important;
        padding: .2rem !important;
        border-radius: .6rem !important;
        box-shadow: none !important;
    }

    /* Action folder tetap di kanan pada baris yang sama. */
    #file-container > .group > button:first-child + div:last-child {
        align-self: center !important;
        margin-left: auto;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }

    /* Action file rapat di kanan. */
    #file-container > .group > div:first-child + div:last-child {
        align-self: flex-end !important;
        margin-top: -.1rem;
    }

    #file-container > .group > div:last-child > button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        padding: .4rem !important;
        border-radius: .5rem !important;
    }

    #file-container > .group > div:last-child > button svg {
        width: .95rem !important;
        height: .95rem !important;
    }

    /* Badge jumlah file/folder folder lebih kecil. */
    #file-container > .group > button:first-child .flex.gap-2 {
        gap: .3rem !important;
        margin-top: .3rem !important;
    }

    #file-container > .group > button:first-child .flex.gap-2 span {
        padding: .1rem .4rem !important;
        font-size: 9px !important;
    }

    #tab-storage > .grid.grid-cols-1 > div:last-child > div > div:first-child {
        padding: .75rem !important;
    }

    #file-count-badge {
        padding: .25rem .55rem !important;
        font-size: .7rem !important;
    }

    /* MODALS */

    #custom-modal,
    #rename-modal {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    #custom-modal > div,
    #rename-modal > div {
        width: 100% !important;
        max-width: none !important;
        max-height: 90vh;
        max-height: 90dvh;
        overflow-y: auto;
        padding: 1rem !important;
        border-radius: 1.25rem 1.25rem 0 0 !important;
    }

    #video-modal {
        padding: .5rem !important;
    }

    #video-modal > div {
        max-height: 95vh;
        max-height: 95dvh;
        border-radius: 1rem !important;
    }

    #video-modal > div > div:first-child {
        opacity: 1 !important;
    }

    /* LOGIN */

    .login-shell {
        min-height: 100vh;
        min-height: 100dvh;
        padding: .75rem !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .login-card {
        padding: 1.25rem !important;
        border-radius: 1.25rem !important;
    }

    .login-card .mb-8 {
        margin-bottom: 1.5rem !important;
    }

    .login-card input,
    .login-card button[type="submit"] {
        min-height: 46px;
    }
}

@media (max-width: 420px) {
    .mobile-brand-text {
        display: none;
    }

    .mobile-nav-inner {
        grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
    }

    #task-grid > div > div:last-child > button {
        flex-basis: 100%;
    }

    #file-container > .group {
        padding: .6rem !important;
    }

    #file-container > .group .w-12.h-12 {
        width: 2.35rem !important;
        height: 2.35rem !important;
    }
}

@media (max-width: 359px) {
    .dashboard-stats-grid,
    #tab-storage > .grid.grid-cols-2 {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .dashboard-stats-grid > div:last-child {
        grid-column: auto;
    }
}

/* =========================================================
   VIDEO PREVIEW CLEAN HEADER V1
   Header judul dan tombol close berada di luar frame video.
   ========================================================= */

#video-modal > div {
    display: flex !important;
    flex-direction: column !important;
}

#video-modal > div > div:first-child {
    position: static !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    flex: 0 0 auto !important;
    opacity: 1 !important;
    z-index: auto !important;
    padding: .75rem 1rem !important;
    background: rgba(15, 23, 42, .98) !important;
    border-bottom: 1px solid rgb(30 41 59) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

#video-modal > div > div:first-child h3 {
    min-width: 0;
    margin: 0 !important;
}

#video-modal > div > div:first-child button {
    flex: 0 0 auto;
}

#video-modal > div > div:nth-child(2) {
    position: relative !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    background: #000 !important;
}

#video-modal #video-player {
    display: block !important;
    width: 100% !important;
    background: #000 !important;
}

@media (max-width: 767.98px) {
    #video-modal > div > div:first-child {
        padding: .6rem .75rem !important;
    }

    #video-modal > div > div:first-child button {
        padding: .5rem !important;
    }
}

