@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0');

:root { 
  --bg-color: #f8fafc; --card-bg: #ffffff; --text-color: #334155; --text-muted: #64748b;
  --heading-color: #0f172a; --border-color: #e2e8f0; --accent-color: #2563eb; --accent-hover: #1d4ed8;
  --btn-bg: #ffffff; --btn-hover: #f1f5f9; --modal-bg: rgba(15, 23, 42, 0.85); 
  --header-glass: rgba(248, 250, 252, 0.8);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05); --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

body.dark-mode { 
  --bg-color: #0f172a; --card-bg: #1e293b; --text-color: #cbd5e1; --text-muted: #94a3b8;
  --heading-color: #f8fafc; --border-color: #334155; --accent-color: #3b82f6; --accent-hover: #60a5fa;
  --btn-bg: #1e293b; --btn-hover: #334155; --modal-bg: rgba(0, 0, 0, 0.9); 
  --header-glass: rgba(15, 23, 42, 0.8);
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.5); --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
}

body { font-family: 'Inter', sans-serif; background-color: var(--bg-color); padding: 0; margin: 0; color: var(--text-color); transition: background-color 0.3s, color 0.3s; }

/* Reset box-sizing agar padding tidak merusak lebar elemen */
*, *::before, *::after { box-sizing: border-box; }

.main-wrapper { padding: 20px; max-width: 1100px; margin: 0 auto; min-height: 80vh; }
h1 { text-align: center; color: var(--heading-color); margin-top: 10px; margin-bottom: 20px; font-weight: 600; font-size: 24px; }
#status { text-align: center; margin-top: 20px; margin-bottom: 20px; color: var(--text-muted); font-size: 14px; font-weight: 500; }

/* ================== HEADER ================== */
.sticky-header-wrapper { position: sticky; top: 0; z-index: 100; background: var(--header-glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-color); padding: 15px 20px; margin-bottom: 30px; }
.header-container { display: flex; align-items: center; justify-content: space-between; max-width: 1100px; margin: auto; gap: 15px; }
.header-left { flex: 1; display: flex; align-items: center; gap: 15px; }
.header-center { flex: 1.5; display: flex; justify-content: center; }
.header-right { flex: 2; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* PENCARIAN & TOMBOL */
.search-wrapper { position: relative; width: 100%; max-width: 350px; }
.search-wrapper .material-symbols-outlined { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 20px; pointer-events: none; }
.search-box { padding: 10px 15px 10px 42px; border-radius: 50px; border: 1px solid var(--border-color); width: 100%; background: var(--card-bg); color: var(--text-color); outline: none; font-family: 'Inter', sans-serif; font-size: 14px; box-shadow: var(--shadow-sm); transition: all 0.2s ease; }
.search-box:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.btn-action { background-color: var(--btn-bg); color: var(--text-color); border: 1px solid var(--border-color); padding: 8px 16px; border-radius: 50px; cursor: pointer; font-size: 14px; font-weight: 500; font-family: 'Inter', sans-serif; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-shadow: var(--shadow-sm); white-space: nowrap; }
.btn-action .material-symbols-outlined { font-size: 18px; }
.btn-action:hover { background-color: var(--btn-hover); border-color: #cbd5e1; }
.btn-primary { background-color: var(--accent-color); color: #ffffff; border: none; }
.btn-primary:hover { background-color: var(--accent-hover); }
.btn-danger { background-color: transparent; color: #ef4444; border-color: #ef4444; }
.btn-danger:hover { background-color: #fef2f2; }
body.dark-mode .btn-danger:hover { background-color: rgba(239, 68, 68, 0.1); }

/* ================== GRID DESKTOP ================== */
.folder-grid { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; margin-bottom: 30px; }
.folder-card { width: 160px; height: 160px; background: var(--card-bg); border-radius: 16px; text-align: center; cursor: pointer; transition: all 0.2s ease; border: 1px solid var(--border-color); position: relative; overflow: hidden; }
.folder-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.folder-cover { width: 100%; height: 100%; object-fit: cover; opacity: 0.3; transition: 0.3s; }
.folder-card:hover .folder-cover { opacity: 0.6; }
.folder-info-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2; pointer-events: none; padding: 10px; }
.folder-icon { font-size: 32px; margin-bottom: 8px; color: var(--heading-color); }
.folder-name { font-weight: 600; color: var(--heading-color); background: var(--card-bg); padding: 4px 12px; border-radius: 20px; font-size: 13px; box-shadow: var(--shadow-sm); width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gallery-grid { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.card { width: 180px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; cursor: pointer; transition: all 0.2s ease; position: relative; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); z-index: 10; }
.card img { width: 100%; height: 140px; object-fit: cover; flex-shrink: 0; }
.card-info { padding: 10px; font-size: 12px; text-align: center; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-color); border-top: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; gap: 4px; background: var(--card-bg); }

.skeleton { width: 100%; height: 140px; background: var(--border-color); animation: pulse 1.5s infinite; position: absolute; top: 0; left: 0; z-index: 1; }
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

#sentinel { height: 60px; width: 100%; display: flex; justify-content: center; align-items: center; color: var(--text-muted); font-size: 13px; font-weight: 500; margin-top: 20px; }

/* ================== MODAL / POPUP ================== */
.modal-box { background: var(--card-bg); padding: 25px; border-radius: 16px; width: 100%; max-width: 360px; border: 1px solid var(--border-color); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); }
.modal-box h3 { margin-top: 0; color: var(--heading-color); font-weight: 600; display: flex; align-items: center; gap: 8px; font-size: 18px; margin-bottom: 5px; }
.modal-box input[type="text"], .modal-box input[type="file"] { width: 100%; margin-bottom: 16px; padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-color); font-family: 'Inter', sans-serif; transition: all 0.2s ease; }
.modal-box input[type="text"]:focus { border-color: var(--accent-color); outline: none; }
.upload-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.toggle-container { margin-bottom: 15px; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; color: var(--text-muted); }

/* ================== LIGHTBOX VIEWER ================== */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: var(--modal-bg); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); flex-direction: column; align-items: center; justify-content: center; }
.image-container { width: 100%; height: 80vh; display: flex; align-items: center; justify-content: center; position: relative; }
.modal-content { max-width: 90%; max-height: 100%; object-fit: contain; cursor: grab; border-radius: 8px; }
.video-content { width: 90%; height: 100%; border: none; display: none; border-radius: 8px; }
.nav-btn { cursor: pointer; position: absolute; top: 50%; transform: translateY(-50%); padding: 12px; color: white; background-color: rgba(255,255,255,0.15); z-index: 1002; user-select: none; border-radius: 50%; display: flex; transition: 0.2s; }
.next { right: 15px; } .prev { left: 15px; }
.nav-btn:hover { background-color: rgba(255,255,255,0.3); }
.close { position: absolute; top: 15px; right: 15px; color: #cbd5e1; font-size: 32px; transition: 0.2s; cursor: pointer; z-index: 1001; background: rgba(0,0,0,0.2); border-radius: 50%; padding: 4px; display: flex; }
.close:hover { color: #fff; background: rgba(0,0,0,0.5); }
.zoom-controls { position: absolute; bottom: 20px; display: flex; gap: 10px; width: 100%; justify-content: center; z-index: 1001; flex-wrap: wrap; padding: 0 10px; }

/* ================== UPLOAD MANAGER ================== */
.upload-manager { position: fixed; bottom: 24px; right: 24px; width: 320px; max-width: 90%; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); z-index: 9999; display: flex; flex-direction: column; transition: transform 0.3s ease; }
.upload-manager.minimized .um-body { display: none; }
.upload-manager.minimized .um-header { border-radius: 12px; }
.upload-manager.minimized #umChevron { transform: rotate(180deg); }
.um-header { background: var(--card-bg); color: var(--heading-color); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; border-bottom: 1px solid var(--border-color); border-radius: 12px 12px 0 0; }
.um-body { padding: 15px; max-height: 250px; overflow-y: auto; background: var(--bg-color); border-radius: 0 0 12px 12px; }
.um-progress-text { font-size: 12px; font-weight: 500; margin-bottom: 8px; color: var(--text-color); display: flex; justify-content: space-between; }
.um-progress-bar { width: 100%; height: 6px; background: var(--border-color); border-radius: 4px; overflow: hidden; margin-bottom: 15px; }
.um-progress-fill { height: 100%; width: 0%; background: var(--accent-color); transition: width 0.3s ease; }
.um-queue-list { display: flex; flex-direction: column; gap: 8px; }
.um-item { display: flex; align-items: center; justify-content: space-between; font-size: 12px; background: var(--card-bg); padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); }
.um-item-left { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.um-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; font-weight: 500; color: var(--text-color); }
.um-item-folder { font-size: 10px; color: var(--text-muted); }
.um-status-icon { font-size: 16px; }
.um-status-uploading { color: var(--accent-color); animation: pulse 1.5s infinite; }
.um-status-done { color: #10b981; }

/* ================== SMARTPHONE OPTIMIZATION ================== */
@media (max-width: 768px) {
  .sticky-header-wrapper { padding: 10px; }
  .header-container { flex-direction: column; gap: 10px; align-items: stretch; }
  .header-left { justify-content: space-between; }
  
  .header-right { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 5px; -webkit-overflow-scrolling: touch; }
  .header-right::-webkit-scrollbar { display: none; }
  .btn-action { padding: 6px 12px; font-size: 13px; }
  .btn-action .material-symbols-outlined { font-size: 16px; }

  .main-wrapper { padding: 15px 10px; }
  
  /* GRID FOLDER - Tetap 2 Kolom agar rapi & hemat ruang */
  .folder-grid { gap: 12px; }
  .folder-card { width: calc(50% - 6px); height: 130px; }
  
  /* GALLERY GRID - 1 KOLOM PENUH ALA FEED SOSIAL MEDIA */
  .gallery-grid { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 20px; 
  }
  .card { 
    width: 100%; 
    max-width: 100%; /* Memenuhi lebar layar */
  }
  .card img { 
    height: 350px; /* Gambar dibuat jauh lebih tinggi */
    width: 100%;
    object-fit: cover; 
  }
  .skeleton {
    height: 350px; /* Menyesuaikan tinggi skeleton saat loading */
  }

  .upload-manager { bottom: 0; right: 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; border-bottom: none; border-left: none; border-right: none; }
  .um-header { border-radius: 16px 16px 0 0; }
  .um-body { border-radius: 0; max-height: 40vh; }
}