/* === FONT & THEME VARIABLES === */
:root {
  --bg-dark-blue: #0b0f19;       
  --bg-light-blue: #0f172a;
  --blob-1: rgba(139, 92, 246, 0.35);  
  --blob-2: rgba(56, 189, 248, 0.28); 
  --blob-3: rgba(99, 102, 241, 0.22); 
  
  --primary: #8b5cf6;       
  --secondary: #3b82f6;     
  --accent: #38bdf8;        
  
  --success: #10b981;       
  --text-dark: #f8fafc;
  --text-light: #94a3b8;
  --bg-card: rgba(30, 41, 59, 0.75);
  --bg-subtle: rgba(15, 23, 42, 0.65);
  --border: rgba(255, 255, 255, 0.1);
  --shadow-color: 0, 0, 0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #0f172a;
  color: var(--text-dark);
  overflow-x: hidden;
  padding: 30px 20px;
  align-items: center;
}

/* === TOP BRAND BAR === */
.brand-top-bar {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto 20px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

.brand-back-btn {
  background: rgba(30, 41, 59, 0.65);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 12px;
  text-decoration: none;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
}

.brand-back-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(56, 189, 248, 0.4);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.brand-badge img {
  height: 22px;
  width: auto;
}

/* === ANIMATED BACKGROUND === */
.background-wrapper {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: -1; overflow: hidden; pointer-events: none;
}
.blob-container { width: 100%; height: 100%; position: relative; filter: blur(80px); }
.blob { position: absolute; border-radius: 50%; animation: moveBlobs 10s ease-in-out infinite alternate; }
.blob:nth-child(1) { top: 5%; left: 5%; width: 450px; height: 450px; background: var(--blob-1); animation-delay: 0s; }
.blob:nth-child(2) { bottom: 5%; right: 5%; width: 500px; height: 500px; background: var(--blob-2); animation-delay: -5s; }
.blob:nth-child(3) { top: 40%; left: 35%; width: 380px; height: 380px; background: var(--blob-3); animation-delay: -2.5s; }

@keyframes moveBlobs {
  0% { transform: translate(0px, 0px) scale(1); }
  100% { transform: translate(35px, 50px) scale(1.1); }
}

/* === MAIN GLASSMORPHISM CARD === */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55);
  margin: auto; 
  width: 100%;
  z-index: 1;

  display: grid;
  grid-template-columns: 1fr 0fr; 
  gap: 0;
  max-width: 480px; 
  transition: max-width 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
              grid-template-columns 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
              gap 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.card.expanded {
  max-width: 1300px; 
  grid-template-columns: 350px 1fr; 
  gap: 40px;
}

.card-left {
  min-width: 0; 
  display: flex; flex-direction: column;
}

.header-section { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; }
.pdf-logo-icon { font-size: 38px; color: var(--primary); filter: drop-shadow(0 4px 10px rgba(139, 92, 246, 0.4)); }
.header-section h2 { 
  margin: 0; 
  font-size: 28px; 
  background: linear-gradient(135deg, #c084fc 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800; 
  letter-spacing: -0.5px; 
  line-height: 1.1; 
}
p.subtitle { font-size: 14px; color: var(--text-light); line-height: 1.6; margin-bottom: 30px; }

/* Right Panel wrapper */
.card-right {
  min-width: 0; opacity: 0; overflow: hidden; 
  padding-left: 0; border-left: 2px dashed rgba(255, 255, 255, 0);
  transition: opacity 0.3s ease, padding-left 0.8s, border-color 0.8s;
}

.card-right-content {
  min-width: 360px; display: flex; flex-direction: column; height: 100%;
}

.card.expanded .card-right {
  opacity: 1; padding-left: 40px; border-left-color: rgba(255, 255, 255, 0.12);
  transition: opacity 0.6s ease 0.4s, padding-left 0.8s, border-color 0.8s;
}

/* === UPLOAD AREA === */
.upload-area {
  border: 2px dashed rgba(148, 163, 184, 0.35); border-radius: 18px;
  padding: 30px 20px; background-color: rgba(15, 23, 42, 0.35);
  transition: all 0.3s ease; cursor: pointer; position: relative; text-align: center;
}
.upload-area:hover { border-color: var(--accent); background-color: rgba(56, 189, 248, 0.08); transform: scale(1.01); }
.upload-area input[type="file"] { display: none; }
.upload-label { font-weight: 700; color: var(--accent); font-size: 16px; display: block;}
.file-name { display: block; margin-top: 10px; font-size: 13px; color: var(--text-light); font-weight: 500; }

/* === BUTTONS & ACTIONS === */
.action-row { display: flex; gap: 10px; margin-top: 10px; }
.action-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  background-size: 200% 200%;
  color: white; border: none; padding: 13px 20px; font-size: 14px; border-radius: 12px;
  cursor: pointer; transition: all 0.3s ease; width: 100%;
  font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 8px 20px -3px rgba(59, 130, 246, 0.35); margin-bottom: 10px; flex: 1;
}
.action-btn:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 10px 25px -3px rgba(59, 130, 246, 0.5); 
}

.clear-btn { background: var(--bg-subtle); color: #cbd5e1; box-shadow: none; border: 1px solid var(--border); }
.clear-btn:hover { background: rgba(51, 65, 85, 0.8); color: white; border-color: rgba(56, 189, 248, 0.4); }

.btn-group { display: flex; gap: 10px; }
.outline-btn { background: transparent; color: var(--accent); border: 1px solid var(--accent); box-shadow: none; }
.outline-btn:hover { background: rgba(56, 189, 248, 0.12); color: white; }
.small-btn { padding: 10px; border-radius: 8px; }

/* === PAGES GRID === */
.grid-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.grid-header h3 { font-size: 20px; color: var(--text-dark); margin: 0; }
.pages-count { background: var(--bg-subtle); padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--accent); border: 1px solid var(--border); }

.pages-grid-container { max-height: calc(100vh - 200px); overflow-y: auto; padding-right: 15px; padding-bottom: 20px; }
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }

/* Scrollbar */
.pages-grid-container::-webkit-scrollbar { width: 6px; }
.pages-grid-container::-webkit-scrollbar-track { background: transparent; }
.pages-grid-container::-webkit-scrollbar-thumb { background-color: var(--border); border-radius: 10px; }

/* === PAGE THUMBNAILS === */
.page-thumb { 
  background-color: rgba(15, 23, 42, 0.7); 
  border: 1px solid var(--border); 
  border-radius: 14px; 
  box-shadow: 0 4px 15px rgba(0,0,0,0.3); 
  display: flex; 
  flex-direction: column; 
  position: relative; 
  transition: all 0.2s; 
  cursor: grab; 
  user-select: none; 
  overflow: hidden;
}
.page-thumb:hover { 
  transform: translateY(-3px); 
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 8px 25px rgba(0,0,0,0.4); 
}
.page-thumb:active { cursor: grabbing; }
.thumb-header { position: relative; border-bottom: 1px solid var(--border); }
.page-thumb img { width: 100%; height: auto; aspect-ratio: 3/4; object-fit: contain; background-color: var(--bg-subtle); }
.page-num { position: absolute; top: 8px; left: 8px; background: var(--primary); color: white; height: 26px; width: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; border: 2px solid #0f172a; box-shadow: 0 2px 5px rgba(0,0,0,0.3);}
.crop-indicator { position: absolute; top: 8px; right: 8px; background-color: var(--bg-subtle); color: var(--accent); border: 1px solid var(--border); height: 26px; width: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.2);}

.thumb-body { padding: 12px; }
.thumb-actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.thumb-btn { background: rgba(30, 41, 59, 0.8); color: var(--text-light); border: 1px solid var(--border); border-radius: 6px; padding: 8px 0; font-size: 14px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center;}
.thumb-btn:hover { background-color: var(--primary); color: white; border-color: var(--primary); }

.size-controls { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: none; animation: fadeIn 0.3s; }
.size-controls.visible { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.size-inputs { display: flex; gap: 10px; }
.size-input-group { flex: 1; }
.size-input-group label { font-size: 11px; font-weight: 600; display: block; margin-bottom: 4px; color: var(--text-light); }
.size-input-group input { width: 100%; padding: 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; background: var(--bg-subtle); color: var(--text-dark); }
.size-input-group input:focus { border-color: var(--accent); }
.aspect-ratio-control { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-light); }

/* === MODALS === */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 1200; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 30px; max-width: 400px; width: 90%; box-shadow: 0 25px 50px rgba(0,0,0,0.6); animation: modalSlide 0.3s ease-out; text-align: center; }
@keyframes modalSlide { from { transform: translateY(-20px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal h3 { margin-bottom: 10px; font-size: 20px; color: var(--text-dark); }
.modal p { margin-bottom: 20px; color: var(--text-light); font-size: 14px;}
.modal input { width: 100%; padding: 12px; font-size: 15px; margin-bottom: 10px; border-radius: 8px; border: 1px solid var(--border); outline: none; background: var(--bg-subtle); color: var(--text-dark); }
.modal input:focus { border-color: var(--accent); }
.modal #password-error, .modal #move-error, .modal #blank-error { color: var(--accent); margin-bottom: 15px; font-size: 13px; display: none; }
.modal-actions { display: flex; gap: 15px; justify-content: center; margin-top: 20px; }
.btn-cancel { background: var(--bg-subtle); color: #cbd5e1; padding: 12px 20px; border-radius: 8px; font-weight: 600; border: 1px solid var(--border); cursor: pointer;}
.btn-cancel:hover { background: rgba(51, 65, 85, 0.8); color: white; }
.btn-export { background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); color: white; padding: 12px 20px; border-radius: 8px; font-weight: 600; border: none; cursor: pointer; display: flex; gap: 8px; align-items: center;}

/* Crop Modal */
.crop-modal-container { background: #1e293b; width: 90vw; height: 90vh; max-width: 1400px; border-radius: 20px; border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 25px 50px rgba(0,0,0,0.6); }
.crop-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 25px; border-bottom: 1px solid var(--border); background: rgba(15, 23, 42, 0.8);}
.crop-image-container { flex-grow: 1; background: #0f172a; padding: 20px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cropper-view-box { outline: 3px solid var(--accent); }
.cropper-point { background-color: var(--accent); }

/* Loader */
#loader-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.loader-content { background: var(--bg-card); border: 1px solid var(--border); padding: 30px 40px; border-radius: 18px; text-align: center; }
.loader-content i { font-size: 40px; color: var(--accent); margin-bottom: 15px; }
.loader-content p { font-size: 16px; font-weight: 600; }

/* Notification Element */
.notification {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(150%);
  background-color: #1e293b; color: white; border: 1px solid var(--border); padding: 12px 24px; border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5); z-index: 3000; font-weight: 500; font-size: 14px;
  opacity: 0; visibility: hidden; transition: all 0.4s ease;
}
.notification.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.notification.error { background-color: var(--danger); }

/* Drag Overlay */
body.drag-over-active::after {
  content: 'Drop Files to Upload'; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(12px); z-index: 4000;
  display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 800;
  color: white; border: 4px dashed var(--accent);
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .card { grid-template-columns: 1fr; grid-template-rows: auto 0fr; max-width: 500px; padding: 30px 20px; transition: grid-template-rows 0.8s cubic-bezier(0.16, 1, 0.3, 1), gap 0.8s; }
  .card.expanded { max-width: 600px; grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 25px; }
  .card-right { border-left: none; padding-left: 0; border-top: 2px dashed rgba(255, 255, 255, 0); }
  .card.expanded .card-right { padding-left: 0; padding-top: 25px; border-left: none; border-top-color: var(--border); }
  .pages-grid-container { max-height: 50vh; }
  .header-section { justify-content: center; }
  .card-left { text-align: center; }
}
@media (max-width: 480px) {
  .action-row { flex-direction: column; gap: 10px; margin-bottom: 0px; }
  .pages-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .thumb-actions { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .thumb-btn { font-size: 12px; padding: 6px 0; }
  body { padding: 20px 10px; }
  .card { padding: 20px 15px; border-radius: 16px; }
}