* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0f0f1a;
  color: #fff;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* ============ SIDEBAR ============ */
#sidebar {
  flex: 0 0 300px;
  width: 300px;
  height: 100vh;
  background: #16162a;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
  will-change: margin-left;
  transition: margin-left 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#sidebar.hidden { margin-left: -300px; }

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #1a1a2e;
  min-width: 300px;
  gap: 6px;
}

#sidebar-header h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #a8a8c0;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 4px;
}

#pick-folder-btn,
#upload-btn,
#export-all-btn,
#toggle-sidebar-btn {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pick-folder-btn:hover,
#upload-btn:hover,
#export-all-btn:hover,
#toggle-sidebar-btn:hover {
  background: #e94560;
  transform: scale(1.08);
}

#folder-info {
  padding: 8px 14px;
  background: #1a1a2e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #888;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 300px;
}

/* ============ FILE TREE ============ */
#file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 10px 6px;
  font-size: 13px;
  min-width: 300px;
}

#file-tree::-webkit-scrollbar { width: 6px; }
#file-tree::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.tree-empty {
  padding: 30px 20px;
  text-align: center;
  color: #5a5a7a;
}

.tree-empty .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.tree-empty p {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 6px;
}

.tree-empty .hint {
  font-size: 11px;
  color: #44445a;
  font-style: italic;
}

.tree-node { user-select: none; }

.tree-folder,
.tree-file {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.tree-folder:hover,
.tree-file:hover { background: rgba(255, 255, 255, 0.06); }

.tree-folder.virtual {
  color: #fbbf24;
  font-style: italic;
}

.tree-file.active {
  background: rgba(233, 69, 96, 0.2);
  color: #ff8ba0;
  font-weight: 600;
}

.tree-file.uploaded { color: #7dd3fc; }

.tree-toggle {
  display: inline-block;
  width: 14px;
  font-size: 10px;
  color: #888;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.placeholder { visibility: hidden; }

.tree-icon { font-size: 14px; flex-shrink: 0; }

.tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-badge {
  font-size: 9px;
  background: #0ea5e9;
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  flex-shrink: 0;
}

.tree-badge.virtual-badge {
  background: #fbbf24;
  color: #000;
}

.tree-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}

.tree-file:hover .tree-actions { display: flex; }
.tree-file:hover .tree-badge:not(.virtual-badge) { display: none; }

.tree-action-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.tree-action-btn:hover {
  background: #e94560;
  transform: scale(1.1);
}

.tree-action-btn.delete:hover { background: #ef4444; }
.tree-action-btn.download:hover { background: #10b981; }

.tree-children { padding-left: 16px; }
.tree-children.hidden { display: none; }

#sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #666;
  font-size: 11px;
  background: #1a1a2e;
  min-width: 300px;
}

/* ============ FLOATING SIDEBAR BTN ============ */
#floating-sidebar-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7) translateX(-10px);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#floating-sidebar-btn.visible {
  opacity: 0.9;
  pointer-events: auto;
  transform: scale(1) translateX(0);
}

#floating-sidebar-btn:hover {
  background: #e94560;
  opacity: 1;
  transform: scale(1.08) translateX(0);
}

/* ============ PRESENTASI ============ */
#presentation {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #1a1a2e 0%, #0a0a14 100%);
  overflow: hidden;
}

#slide-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#slide-container.scrollable {
  overflow-y: auto;
  overflow-x: hidden;
  align-items: flex-start;
  padding: 4% 0;
}

#slide-container.scrollable::-webkit-scrollbar { width: 8px; }
#slide-container.scrollable::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.04); }
#slide-container.scrollable::-webkit-scrollbar-thumb {
  background: rgba(233, 69, 96, 0.6);
  border-radius: 4px;
}
#slide-container.scrollable::-webkit-scrollbar-thumb:hover {
  background: rgba(233, 69, 96, 0.9);
}

#pdf-canvas {
  max-width: none;
  max-height: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  border-radius: 6px;
  background: #fff;
  animation: slideIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  display: none;
  flex-shrink: 0;
}

#pdf-canvas.visible { display: block; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px) scale(0.97); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

#empty-state {
  text-align: center;
  color: #4a4a6a;
  pointer-events: none;
}

#empty-state.hidden { display: none; }

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

#empty-state p { font-size: 15px; letter-spacing: 0.5px; }

/* ============ CONTROLS ============ */
#controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  padding: 10px 18px;
  border-radius: 50px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0.4;
  transition: opacity 0.3s ease;
  z-index: 100;
}

#controls:hover { opacity: 1; }

#controls button {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#controls button:hover {
  background: #e94560;
  transform: scale(1.1);
}

#controls button:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  transform: none;
}

#controls button.active { background: #e94560; }

#controls .divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
}

#page-input-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 4px 8px;
  transition: background 0.2s;
}

#page-input-wrapper:focus-within {
  background: rgba(233, 69, 96, 0.15);
  box-shadow: 0 0 0 1px rgba(233, 69, 96, 0.5);
}

#page-input {
  background: transparent;
  border: none;
  color: #fff;
  width: 42px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  outline: none;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

#page-input::-webkit-outer-spin-button,
#page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#page-total {
  color: #888;
  font-size: 12px;
  font-weight: 600;
  min-width: 32px;
}

/* ============ TIMER ============ */
#timer-display {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 95;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  opacity: 0.4;
  transition: opacity 0.3s;
}

#timer-display.running { opacity: 1; color: #4ade80; }
#timer-display.warning { color: #fbbf24; animation: pulse 1s infinite; }
#timer-display.over    { color: #e94560; animation: pulse 0.6s infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

/* ============ PROGRESS ============ */
#progress-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 12px;
  background: transparent;
  z-index: 99;
  cursor: pointer;
  display: flex;
  align-items: center;
}

#progress-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  transition: height 0.2s;
}

#progress-bar:hover::before { height: 6px; }

#progress-fill {
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #e94560, #ff7b54);
  transition: width 0.35s ease;
  position: relative;
  z-index: 1;
  align-self: flex-start;
}

#progress-bar:hover #progress-fill { height: 6px; }

#progress-bar::after {
  content: attr(data-hover-page);
  position: absolute;
  top: 8px;
  left: var(--hover-x, 0px);
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  white-space: nowrap;
}

#progress-bar:hover::after { opacity: 1; }

/* ============ AUTOPLAY ============ */
#autoplay-settings {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 16px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 99;
}

#autoplay-settings.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

#autoplay-settings label {
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#autoplay-settings input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  width: 60px;
  font-size: 13px;
  outline: none;
}

/* ============ LOADING ============ */
#loading {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 26, 0.92);
  backdrop-filter: blur(4px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  z-index: 998;
  transition: opacity 0.3s;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.25s;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: #1a1a2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  animation: modalIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.goto-content { max-width: 340px; }
.confirm-content { max-width: 400px; }

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: #888;
  font-size: 20px;
  cursor: pointer;
  width: 30px; height: 30px;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-label {
  font-size: 12px;
  color: #a8a8c0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

.form-select,
.form-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border 0.2s;
}

.form-select:focus,
.form-input:focus { border-color: #e94560; }

.form-select option {
  background: #1a1a2e;
  color: #fff;
}

.goto-input {
  font-size: 28px !important;
  font-weight: 700;
  text-align: center;
  padding: 14px !important;
  font-variant-numeric: tabular-nums;
}

.goto-input::-webkit-outer-spin-button,
.goto-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.goto-input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.goto-info {
  text-align: center;
  color: #888;
  font-size: 13px;
}

.confirm-text {
  font-size: 14px;
  color: #ddd;
  line-height: 1.6;
  text-align: center;
}

.confirm-text strong {
  color: #ff8ba0;
  word-break: break-all;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.confirm-actions button {
  flex: 1;
  padding: 12px;
}

.new-folder-row {
  display: flex;
  gap: 8px;
}

.new-folder-row .form-input { flex: 1; }

.btn-primary,
.btn-secondary,
.btn-danger {
  background: #e94560;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-secondary { background: rgba(255, 255, 255, 0.08); }
.btn-danger { background: #dc2626; }

.btn-primary:hover { background: #d63850; transform: translateY(-1px); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }
.btn-danger:hover { background: #b91c1c; transform: translateY(-1px); }

.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 30px 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: #e94560;
  background: rgba(233, 69, 96, 0.05);
}

.drop-icon {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.5;
}

.drop-zone p {
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
}

.upload-progress {
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

.progress-label {
  font-size: 12px;
  color: #a8a8c0;
  margin-bottom: 8px;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e94560, #ff7b54);
  transition: width 0.25s ease;
}

.upload-status {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.upload-status.success {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.upload-status.error {
  background: rgba(233, 69, 96, 0.15);
  color: #ff8ba0;
  border: 1px solid rgba(233, 69, 96, 0.3);
}

.hidden { display: none !important; }

/* ============ TOAST ============ */
#toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 320px;
  pointer-events: auto;
}

.toast.success { border-color: rgba(74, 222, 128, 0.5); color: #4ade80; }
.toast.error { border-color: rgba(233, 69, 96, 0.5); color: #ff8ba0; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(50px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
  }
  #sidebar.hidden { margin-left: -300px; }
  #controls { bottom: 16px; }
}