/* ==========================================================================
   DocuMorph Studio - Premium Light Theme (AyuCSS + Andalan UI Kit)
   Clean, Modern, High Contrast & Polished In-Browser Studio
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Pristine Light Theme Palette */
  --bg-canvas: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  /* Primary & Accents */
  --primary-rgb: 59, 130, 246;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-subtle: rgba(59, 130, 246, 0.08);
  --danger-rgb: 239, 68, 68;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-subtle: rgba(239, 68, 68, 0.08);
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.1);

  /* Elevation & Radius */
  --card-radius: 16px;
  --element-radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 30px -4px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.03);
}

/* ==========================================================================
   Global & Reset
   ========================================================================== */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Topbar & Brand
   ========================================================================== */
.studio-navbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.brand-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.28);
  transition: transform 0.2s ease;
}

.navbar-brand:hover .brand-icon-wrap {
  transform: rotate(6deg) scale(1.05);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.725rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Live Pulse Privacy Badge */
.privacy-badge {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 9999px;
  padding: 0.4rem 1rem;
  font-size: 0.775rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  display: inline-block;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.6);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   Studio Switcher (Segmented Control)
   ========================================================================== */
.studio-segmented-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.studio-segmented-control {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 5px;
  box-shadow: var(--shadow-sm);
  gap: 6px;
}

.studio-segment-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.6rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  outline: none;
  user-select: none;
}

.studio-segment-btn:hover {
  color: var(--text-main);
}

.studio-segment-btn.active {
  background-color: var(--bg-card);
  box-shadow: var(--shadow-md);
  font-weight: 700;
}

.studio-segment-btn[data-studio="image"].active {
  color: var(--primary);
}

.studio-segment-btn[data-studio="pdf"].active {
  color: var(--danger);
}

.studio-badge-pill {
  font-size: 0.725rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-weight: 700;
  margin-left: 0.5rem;
}

.badge-primary-subtle {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

.badge-danger-subtle {
  background-color: var(--danger-subtle);
  color: var(--danger);
}

.studio-tab-btn {
  border-radius: 9999px !important;
}

/* ==========================================================================
   Main Studio Card & Card Tabs
   ========================================================================== */
.main-studio-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.studio-card-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.6rem 1.25rem 0;
}

.studio-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: -1px;
  list-style: none;
  padding: 0;
}

.studio-tab-link,
.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none !important;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom: 3px solid transparent;
  transition: all 0.18s ease;
  user-select: none;
}

.studio-tab-link:hover,
.tool-chip:hover {
  color: var(--text-main);
  background-color: var(--primary-subtle);
}

.studio-tab-link.active,
.tool-chip.active {
  color: var(--primary) !important;
  border-bottom-color: var(--primary) !important;
  background-color: transparent;
  font-weight: 700;
}

#pdf-tabs-nav .studio-tab-link.active,
#pdf-tabs-nav .tool-chip.active {
  color: var(--danger) !important;
  border-bottom-color: var(--danger) !important;
}

#pdf-tabs-nav .studio-tab-link:hover,
#pdf-tabs-nav .tool-chip:hover {
  background-color: var(--danger-subtle);
}

/* Tool Panel Visibility */
.tool-panel {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.tool-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Tool Header Banner
   ========================================================================== */
.tool-header-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.tool-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-right: 0.85rem;
  flex-shrink: 0;
}

.tool-header-icon.image-mode {
  background: var(--primary-subtle);
  color: var(--primary);
}

.tool-header-icon.pdf-mode {
  background: var(--danger-subtle);
  color: var(--danger);
}

.tool-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.tool-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* ==========================================================================
   Modern Dropzones
   ========================================================================== */
.dropzone {
  border: 2px dashed var(--border-strong);
  background-color: var(--bg-subtle);
  border-radius: var(--card-radius);
  padding: 3.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.dropzone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(59, 130, 246, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background-color: #f0f7ff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.1);
}

.dropzone.pdf-drop:hover,
.dropzone.pdf-drop.dragover {
  border-color: var(--danger);
  background-color: #fef2f2;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.1);
}

.dropzone-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background-color: #ffffff;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.25s ease;
}

.dropzone.pdf-drop .dropzone-icon-wrap {
  color: var(--danger);
}

.dropzone:hover .dropzone-icon-wrap {
  transform: scale(1.1);
}

.dropzone-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.dropzone-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
  max-width: 460px;
  margin: 0 auto 1.15rem;
}

.dropzone-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1.15rem;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: 9999px;
  pointer-events: none;
}

.dropzone-input {
  display: none;
}

/* ==========================================================================
   Image Workspaces (Cropper & Previews)
   ========================================================================== */
.cropper-img-container {
  width: 100%;
  height: 480px;
  background-color: #f8fafc;
  background-image: 
    linear-gradient(45deg, #e9ecef 25%, transparent 25%), 
    linear-gradient(-45deg, #e9ecef 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #e9ecef 75%), 
    linear-gradient(-45deg, transparent 75%, #e9ecef 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--element-radius);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cropper-img-container img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Workspace Toolbar */
.workspace-toolbar {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--element-radius);
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Live Crop Previews */
.cropper-preview-box {
  background-color: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--element-radius);
  padding: 1rem;
}

.cropper-preview-square {
  width: 90px;
  height: 90px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-strong);
  background-color: #ffffff;
  display: inline-block;
}

.cropper-preview-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--primary);
  background-color: #ffffff;
  display: inline-block;
}

/* Preview Container with subtle checkerboard */
.preview-container {
  background-color: #ffffff;
  background-image: 
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%), 
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%), 
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--element-radius);
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
}

.preview-container img {
  max-width: 100%;
  max-height: 52vh;
  object-fit: contain;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  border-radius: 6px;
}

/* ==========================================================================
   Side Controls Card
   ========================================================================== */
.controls-card {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--element-radius);
  padding: 1.25rem;
}

.control-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.45rem;
}

.stats-summary-box {
  background-color: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.825rem;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
}

.stats-row:not(:last-child) {
  border-bottom: 1px solid var(--border-subtle);
}

/* ==========================================================================
   PDF Pages Visual Grid & Cards
   ========================================================================== */
.pdf-pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.pdf-page-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--element-radius);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.pdf-page-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.pdf-page-canvas-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1.414;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), filter 0.25s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.pdf-page-canvas-wrapper canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ==========================================================================
   File Queue Lists
   ========================================================================== */
.file-queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.file-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 0.75rem 1rem;
  border-radius: var(--element-radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease;
}

.file-queue-item:hover {
  border-color: var(--primary);
}

.file-queue-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.file-queue-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.file-queue-pdf-icon {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--danger-subtle);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.file-queue-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.file-queue-meta {
  font-size: 0.775rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Buttons & Controls (Clean Light Styling)
   ========================================================================== */
.btn {
  font-family: inherit;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.18s ease;
}

.btn-primary {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
}

.btn-primary:hover {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  transform: translateY(-1px);
}

.btn-danger {
  background-color: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #ffffff !important;
}

.btn-light {
  background-color: #ffffff !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-main) !important;
}

.btn-light:hover {
  background-color: var(--bg-hover) !important;
  border-color: var(--border-strong) !important;
}

.btn-outline-danger {
  color: var(--danger) !important;
  border-color: var(--danger) !important;
  background: transparent !important;
}

.btn-outline-danger:hover {
  background-color: var(--danger) !important;
  color: #ffffff !important;
}

/* Form Controls */
.form-control,
.form-control-sm,
select.form-control {
  background-color: #ffffff !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-main) !important;
  border-radius: 8px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-control:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-subtle) !important;
}

/* Badges */
.badge {
  font-family: inherit;
  font-weight: 600;
  border-radius: 6px;
}

.badge-light {
  background-color: var(--bg-subtle) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.studio-footer {
  background-color: #ffffff;
  border-top: 1px solid var(--border-subtle);
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}

/* PDF Compress Dedicated Workspace Styles */
.pdf-compress-preview-wrap {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--element-radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
}

.pdf-paper-preview {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  max-width: 100%;
  max-height: 330px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.2s ease;
}

.pdf-paper-preview canvas {
  max-width: 100%;
  max-height: 330px;
  object-fit: contain;
  display: block;
}

.pdf-paper-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  font-size: 0.725rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.pdf-meta-box {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  width: 100%;
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
