/* ========================================
   ImageTools — Split Image Page Styles
   ======================================== */

/* --- Tool Header --- */
.tool-header { text-align: center; padding: 48px 0 32px; position: relative; z-index: 1; }
.tool-header .section-label { margin-left: auto; margin-right: auto; }
.tool-header .section-title { margin-left: auto; margin-right: auto; }
.tool-header .section-subtitle { margin-left: auto; margin-right: auto; margin-bottom: 24px; }

.formats-bar { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.format-badge { padding: 4px 12px; background: var(--color-bg-tertiary); border: 1px solid var(--color-border); border-radius: 100px; font-size: 0.75rem; font-weight: 500; color: var(--color-text-secondary); }

/* --- Upload Zone --- */
.upload-zone { border: 2px dashed var(--color-border); border-radius: var(--radius-xl); padding: 48px 24px; text-align: center; cursor: pointer; transition: all var(--transition-normal); background: var(--color-glass); }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--color-border-accent); background: rgba(var(--glow-rgb), 0.03); }
.upload-zone-icon { width: 48px; height: 48px; margin: 0 auto 16px; color: var(--color-accent); }
.upload-zone-icon i { width: 48px; height: 48px; }
.upload-zone-text { font-size: 1rem; font-weight: 500; color: var(--color-text); margin-bottom: 8px; }
.upload-zone-subtext { font-size: 0.875rem; color: var(--color-text-muted); }
.upload-zone input[type="file"] { display: none; }

/* --- Main Workspace --- */
.workspace { margin-top: 32px; display: none; flex-direction: column; background: var(--color-bg-secondary); border: 1px solid var(--color-border); border-radius: var(--radius-xl); position: relative; overflow: hidden; }
.workspace.active { display: flex; }

/* --- Workspace Controls --- */
.workspace-controls { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--color-border); background: var(--color-bg); flex-wrap: wrap; gap: 16px; z-index: 20; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.controls-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.controls-right { display: flex; align-items: center; gap: 12px; }

/* Options */
.split-options { gap: 16px; }
.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label { font-size: 0.6875rem; color: var(--color-text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.input-field { width: 80px; padding: 6px 8px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text); font-family: var(--font-mono); font-size: 0.875rem; text-align: center; outline: none; transition: border-color var(--transition-fast); }
.input-field:focus { border-color: var(--color-border-accent); }

/* --- Split Stage --- */
/* --- Split Stage --- */
/* Changed from max-height to fixed height to prevent layout shifting when tiles load */
.split-stage { 
  flex: 1; 
  display: grid; 
  grid-template-columns: 1fr 1.5fr; 
  gap: 1px; 
  background: var(--color-border); 
  overflow: hidden; 
  height: 60vh; /* CHANGED: Fixed height */
}
.original-panel, .tiles-panel { 
  display: flex; 
  flex-direction: column; 
  background: var(--color-bg-tertiary); 
  background-image: radial-gradient(rgba(15, 23, 42, 0.07) 1px, transparent 1px); 
  background-size: 24px 24px; 
  overflow: hidden; /* ADDED: Contain the scroll within the panel */
  min-height: 0; /* ADDED: Crucial for flexbox scrolling */
}
.panel-header { 
  padding: 12px 16px; 
  font-size: 0.8125rem; 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: 0.05em; 
  color: var(--color-text-secondary); 
  background: var(--color-bg); 
  border-bottom: 1px solid var(--color-border-subtle); 
  text-align: center; 
}
.panel-body { 
  flex: 1; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  padding: 24px; 
  overflow: auto; /* This now correctly scrolls when tiles exceed the 60vh height */
  position: relative; 
  min-height: 0; /* ADDED: Crucial for flexbox scrolling */
}
.original-panel img { 
  max-width: 100%; 
  max-height: 100%; 
  object-fit: contain; 
  border-radius: var(--radius-sm); 
  box-shadow: var(--shadow-md); 
}

/* Tiles Grid */
.placeholder-text { 
  color: var(--color-text-dim); 
  font-size: 0.875rem; 
  text-align: center; 
  position: absolute; 
}
#tilesGrid { 
  display: grid; 
  gap: 8px; 
  align-content: start; 
  width: 100%; 
  /* height: 100%; <-- REMOVED to allow natural growth for scrolling */
}
.tile-card { position: relative; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; background: var(--color-bg); aspect-ratio: 1; }
.tile-card img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.tile-download-btn { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.6); color: white; border: none; border-radius: 4px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: opacity var(--transition-fast); }
.tile-card:hover .tile-download-btn { opacity: 1; }
.tile-download-btn i { width: 14px; height: 14px; }

/* --- Sticky Bottom Bar --- */
.workspace-bottom-bar { padding: 16px 24px; border-top: 1px solid var(--color-border); background: var(--color-bg); display: flex; align-items: center; justify-content: space-between; gap: 16px; z-index: 20; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.summary-text { font-size: 0.875rem; color: var(--color-text-secondary); display: flex; align-items: center; gap: 8px; }
.bottom-actions { display: flex; align-items: center; gap: 12px; }

.btn-download { min-width: 200px; padding: 14px 32px; font-size: 1rem; font-weight: 600; box-shadow: 0 0 20px rgba(var(--glow-rgb), 0.2); }
.btn-download:disabled { background: var(--color-text-dim); cursor: not-allowed; box-shadow: none; opacity: 0.7; }
.btn-download.loading { pointer-events: none; opacity: 0.8; }

/* --- Social Share Section --- */
.share-section { margin-top: 32px; padding: 32px; background: var(--color-glass); border: 1px solid var(--color-border); border-radius: var(--radius-lg); text-align: center; display: none; }
.share-section.active { display: block; }
.share-title { font-size: 1rem; font-weight: 500; margin-bottom: 6px; }
.share-subtitle { font-size: 0.875rem; color: var(--color-text-muted); margin-bottom: 20px; }
.share-buttons { display: flex; align-items: center; justify-content: center; gap: 12px; }
.share-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--color-border); background: var(--color-bg); color: var(--color-text-secondary); transition: all var(--transition-fast); }
.share-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.share-btn.twitter:hover { background: #000; color: #fff; border-color: #000; }
.share-btn.facebook:hover { background: #1877F2; color: #fff; border-color: #1877F2; }
.share-btn.linkedin:hover { background: #0A66C2; color: #fff; border-color: #0A66C2; }
.share-btn.whatsapp:hover { background: #25D366; color: #fff; border-color: #25D366; }
.share-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .split-stage { grid-template-columns: 1fr; max-height: 80vh; }
  .workspace-bottom-bar { flex-direction: column; text-align: center; }
  .btn-download { width: 100%; }
}