/* ==========================================
   1. VARIABEL & RESET GLOBAL
   ========================================== */
:root {
    --primary: #111111;
    --primary-hover: #333333;
    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --text: #171717;
    --text-light: #666666;
    --border: #E5E5E5;
    --danger: #DC2626;
    --radius: 12px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-size: 16px;
    overflow-x: hidden;
    /* Hilangkan padding-bottom dan max-width dari body agar Header bisa full width */
}

/* ==========================================
   2. SPA VIEW MANAGER (Logika Transisi Layar)
   ========================================== */
.spa-view {
    display: none;
    opacity: 0;
}

.spa-view.active {
    display: block;
    animation: fadeViewIn 0.3s forwards;
}

@keyframes fadeViewIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utilitas untuk Laman Login & Preview */
.flex-center {
    display: flex !important;
    /* Wajib pakai Flexbox untuk Centering */
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    /* 100dvh lebih baik dari vh di mobile */
    padding: 20px;
}

/* ==========================================
   3. LOGIN & PREVIEW CARD
   ========================================== */
.login-card,
.preview-card {
    background: var(--surface);
    padding: 40px 32px;
    border-radius: 24px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.icon-login {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-subtitle {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 28px;
}

.preview-card {
    max-width: 800px;
    padding: 30px;
}

.preview-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.preview-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

#previewIframe {
    width: 100%;
    height: 60vh;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}

/* ==========================================
   4. LAYOUT DASHBOARD (Sistem Kontainer)
   ========================================== */
.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    z-index: 40;
}

.header-container {
    max-width: 1000px;
    /* Lebar maksimal area baca */
    margin: 0 auto;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--danger);
    transition: var(--transition);
}

.btn-logout:hover {
    background: #FEF2F2;
    border-color: #FECACA;
}

.workspace-container {
    max-width: 1000px;
    margin: 64px auto 0;
    /* Hindari tertutup header */
    padding-bottom: 120px;
    /* Ruang untuk tombol FAB */
}

/* ==========================================
   5. TOOLBAR & SEARCH BOX
   ========================================== */
.toolbar-section {
    position: sticky;
    top: 64px;
    z-index: 30;
    background: rgba(250, 250, 250, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

.breadcrumb button {
    background: none;
    border: none;
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: var(--transition);
    font-size: 0.95rem;
}

.breadcrumb button:hover {
    background: #E5E5E5;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    fill: #999;
}

.search-box input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    outline: none;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.05);
}

/* ==========================================
   6. FILE LIST & DROPDOWN
   ========================================== */
.list-container {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-item {
    display: flex;
    align-items: center;
    background: var(--surface);
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    gap: 14px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

.list-item:has(.dropdown-menu.show) {
    z-index: 25;
}

@media (hover: hover) {
    .list-item:hover {
        box-shadow: var(--shadow-sm);
        border-color: #D4D4D4;
        transform: translateY(-1px);
    }
}

.item-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    background: var(--bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}

.item-info {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.item-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-actions {
    flex: 0 0 auto;
    position: relative;
}

.btn-icon {
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.btn-icon svg {
    width: 22px;
    height: 22px;
}

.btn-icon:hover,
.btn-icon.active {
    background: #E5E5E5;
    color: var(--primary);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    z-index: 999;
    min-width: 200px;
    padding: 8px 0;
    transform: translateZ(0);
    animation: fadeInDrop 0.15s ease-out;
}

.dropdown-menu.show {
    display: block;
}

@keyframes fadeInDrop {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    gap: 12px;
    transition: 0.2s;
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: currentColor;
}

.dropdown-item:hover {
    background-color: #F5F5F5;
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background-color: #FEF2F2;
}

/* ==========================================
   7. FLOATING ACTION BUTTONS (FAB)
   ========================================== */
.fab-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 20;
}

.fab {
    width: 60px;
    height: 60px;
    background: var(--primary);
    color: var(--surface);
    border: none;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.fab svg {
    width: 28px;
    height: 28px;
    fill: var(--surface);
}

.fab:hover {
    background: var(--primary-hover);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.fab:active {
    transform: scale(0.95);
}

.fab-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    width: 50px;
    height: 50px;
    margin-left: 5px;
    box-shadow: var(--shadow-sm);
}

.fab-secondary svg {
    fill: var(--text);
    width: 24px;
    height: 24px;
}

.fab-secondary:hover {
    background: var(--bg);
}

/* ==========================================
   8. MODALS & FORMS (Focus, Scroll Lock)
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--surface);
    padding: 28px;
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: slideUpModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpModal {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal h3 {
    margin-bottom: 20px;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.modal-desc {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 24px;
    line-height: 1.5;
}

.meta-text {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 12px;
    word-break: break-all;
}

.input-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.input-modern {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    font-size: 16px;
    background: var(--surface);
    color: var(--text);
    transition: 0.2s;
    margin-bottom: 16px;
}

.input-modern:focus,
#passwordInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

#passwordInput {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    font-size: 16px;
    margin-bottom: 16px;
    background: var(--bg);
    transition: 0.2s;
}

#passwordInput:focus {
    background: var(--surface);
}

.drop-zone {
    border: 2px dashed #D4D4D4;
    border-radius: 16px;
    padding: 36px 16px;
    text-align: center;
    background: var(--bg);
    cursor: pointer;
    margin-bottom: 20px;
    transition: var(--transition);
}

.drop-zone:hover {
    border-color: var(--primary);
    background: #F5F5F5;
}

.drop-icon {
    width: 32px;
    height: 32px;
    fill: var(--text-light);
    margin-bottom: 8px;
}

.file-list-preview {
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.85rem;
    background: var(--bg);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 16px;
    display: none;
    border: 1px solid var(--border);
}

.status-text {
    font-size: 0.85rem;
    margin-bottom: 16px;
    font-weight: 600;
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

.btn {
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
}

.btn-cancel {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-cancel:hover {
    background: #E5E5E5;
}

.btn-primary {
    background: var(--primary);
    color: var(--surface);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-danger {
    background: var(--danger);
    color: var(--surface);
}

.btn-danger:hover {
    background: #B91C1C;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ==========================================
   9. TOAST NOTIFICATIONS (Non-Intrusive UX)
   ========================================== */
#toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--text);
    color: var(--surface);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: slideUpToast 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.error {
    background: var(--danger);
}

.toast.fade-out {
    animation: fadeOutToast 0.3s forwards;
}

@keyframes slideUpToast {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutToast {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* ==========================================
   10. EMPTY STATES & LOADERS
   ========================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.5;
}

.loader {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ==========================================
   11. MOBILE RESPONSIVE (Bottom Sheet Modals)
   ========================================== */
@media (max-width: 720px) {
    .app-header {
        height: 60px;
    }

    .toolbar-section {
        top: 60px;
        padding: 12px 16px;
    }

    .workspace-container {
        margin-top: 60px;
    }

    .list-container {
        padding: 12px 16px;
    }

    .fab-container {
        right: 16px;
        bottom: 20px;
    }

    #toast-container {
        bottom: 100px;
        width: 90%;
    }

    /* Modals become bottom sheets */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        padding: 32px 20px 40px 20px;
        animation: slideUpSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    @keyframes slideUpSheet {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .modal-actions {
        flex-direction: column;
        gap: 12px;
    }

    .btn {
        width: 100%;
        padding: 14px;
    }

    .btn-cancel {
        order: 2;
    }

    .btn-primary,
    .btn-danger {
        order: 1;
    }
}