/* Variables & Color Palette */
:root {
  --bg-color: #0b0f19;
  --card-bg: rgba(17, 25, 40, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #10b981; /* WhatsApp Green styled dynamically */
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.15);
  --secondary: #3b82f6; /* Accent blue */
  --secondary-hover: #2563eb;
  --secondary-glow: rgba(59, 130, 246, 0.15);
  --danger: #ef4444;
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius-lg: 16px;
  --radius-md: 12px;
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Global resets & scrollbar */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  overflow-x: hidden;
}

/* Dynamic Glowing Background Effect */
.glow-bg {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, rgba(59, 130, 246, 0.04) 50%, transparent 100%);
  z-index: -1;
  pointer-events: none;
  filter: blur(40px);
  animation: pulseGlow 10s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
  0% {
    width: 450px;
    height: 450px;
    opacity: 0.8;
  }
  100% {
    width: 550px;
    height: 550px;
    opacity: 1.2;
  }
}

/* App Containers */
.app-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 1;
}

.app-header {
  text-align: center;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
}

.app-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #ffffff 30%, #a5f3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 400;
}

/* Card Components with Glassmorphism */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Dropzone styling */
.dropzone {
  position: relative;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  transition: all 0.25s ease;
  cursor: pointer;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.03);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-icon {
  color: var(--text-muted);
  transition: transform 0.3s ease, color 0.3s ease;
}

.dropzone:hover .upload-icon {
  color: var(--primary);
  transform: translateY(-4px);
}

.dropzone-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.dropzone-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #0b0f19;
  box-shadow: 0 4px 14px 0 var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 20px 0 var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-block {
  width: 100%;
}

.select-btn {
  margin-top: 8px;
}

/* File info card details */
.file-details {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: var(--radius-md);
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.file-icon {
  color: var(--secondary);
}

.file-metadata {
  flex-grow: 1;
  min-width: 0;
}

.file-metadata h4 {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-metadata p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--danger);
}

/* Warnings */
.duration-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

.duration-warning svg {
  flex-shrink: 0;
}

/* Processing card elements */
.processing-card {
  align-items: center;
  text-align: center;
  padding: 40px 24px;
}

.spinner-container {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.spinner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid rgba(16, 185, 129, 0.1);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}

.spinner-inner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.progress-percent {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.status-subtext {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Result Card & Sticker Preview */
.result-card {
  align-items: center;
  text-align: center;
}

.sticker-info {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: -12px;
}

.sticker-preview-container {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 30px;
  border-radius: var(--radius-md);
  margin: 12px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sticker-frame {
  width: 180px;
  height: 180px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.sticker-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0px); }
}

.result-details {
  display: flex;
  gap: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.result-details strong {
  color: var(--text-main);
}

.action-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-buttons .btn {
  width: 100%;
}

/* Footer layout */
.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 8px;
}

/* Trimmer Section Styling */
.trimmer-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(255, 255, 255, 0.01);
  border-radius: var(--radius-md);
  margin-top: 8px;
}

/* Video Preview Wrapper */
.video-preview-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

.video-preview-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none; /* Let drag/resize events pass through to crop container */
  z-index: 15; /* Above crop box */
}

.video-preview-wrapper:hover .video-overlay {
  opacity: 1;
}

.play-overlay-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: var(--text-main);
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
  padding: 0;
  pointer-events: auto; /* Enable click events on the play button itself */
}

.play-overlay-btn svg {
  margin-left: 3px;
  transition: transform 0.2s ease;
}

.play-overlay-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.play-overlay-btn:active {
  transform: scale(0.95);
}

.video-time-bar {
  position: absolute;
  bottom: 10px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-main);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  pointer-events: auto; /* Enable interaction for play button */
  z-index: 16; /* Topmost overlay in wrapper */
  font-weight: 600;
  background: rgba(11, 15, 25, 0.6);
  padding: 4px 8px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bar-play-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.2s ease;
  margin-right: 4px;
}

.bar-play-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--primary);
}

.time-separator {
  color: var(--text-muted);
  font-weight: 400;
}

/* Crop Overlay System */
.crop-container {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  /* Bounds computed dynamically via JavaScript */
}

.crop-shade {
  position: absolute;
  background: rgba(0, 0, 0, 0.65);
  pointer-events: auto;
  transition: background-color 0.2s ease;
}

.crop-box {
  position: absolute;
  border: 1.5px solid var(--primary);
  box-sizing: border-box;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
  cursor: move;
  pointer-events: auto;
  z-index: 11;
}

.crop-grid-h, .crop-grid-v {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  box-sizing: border-box;
}

.crop-grid-h {
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  top: 33.33%;
  height: 33.33%;
}

.crop-grid-v {
  border-left: 1px dashed rgba(255, 255, 255, 0.25);
  border-right: 1px dashed rgba(255, 255, 255, 0.25);
  left: 33.33%;
  width: 33.33%;
}

.crop-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: #ffffff;
  border: 2px solid var(--primary);
  border-radius: 50%;
  z-index: 12;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  box-sizing: border-box;
}

/* Corner Handles */
.handle-tl {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}
.handle-tr {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}
.handle-bl {
  bottom: -5px;
  left: -5px;
  cursor: nesw-resize;
}
.handle-br {
  bottom: -5px;
  right: -5px;
  cursor: nwse-resize;
}

/* Side Handles */
.handle-t {
  top: -5px;
  left: calc(50% - 5px);
  cursor: ns-resize;
}
.handle-b {
  bottom: -5px;
  left: calc(50% - 5px);
  cursor: ns-resize;
}
.handle-l {
  left: -5px;
  top: calc(50% - 5px);
  cursor: ew-resize;
}
.handle-r {
  right: -5px;
  top: calc(50% - 5px);
  cursor: ew-resize;
}

/* Trimmer range scrubber container */
.trimmer-timeline-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.max-badge {
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.range-slider-container {
  position: relative;
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
}

.range-slider {
  position: relative;
  width: 100%;
  height: 6px;
}

.slider-track {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  z-index: 1;
}

.slider-range-fill {
  position: absolute;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  z-index: 2;
}

.slider-thumb {
  position: absolute;
  width: 100%;
  height: 6px;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  z-index: 3;
  outline: none;
  top: 0;
  left: 0;
  margin: 0;
}

.slider-thumb::-webkit-slider-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--text-main);
  border: 2.5px solid var(--primary);
  cursor: pointer;
  pointer-events: auto;
  -webkit-appearance: none;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-thumb::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  background: #ffffff;
}

.slider-thumb::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--text-main);
  border: 2.5px solid var(--primary);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-thumb::-moz-range-thumb:hover {
  transform: scale(1.25);
  background: #ffffff;
}

/* Trimmer inputs layout */
.trimmer-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.trimmer-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trimmer-input-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-with-action {
  display: flex;
  gap: 6px;
  width: 100%;
}

.time-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: monospace;
  font-size: 0.95rem;
  padding: 8px;
  width: 100%;
  outline: none;
  text-align: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  min-width: 0;
}

.time-input:focus {
  border-color: var(--secondary);
  background: rgba(59, 130, 246, 0.02);
}

.time-input.invalid {
  border-color: var(--danger) !important;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.03);
}

.btn-xs {
  font-size: 0.72rem;
  padding: 8px 10px;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Info text & Warnings */
.trimmer-info {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.trimmer-info strong {
  color: var(--primary);
  font-weight: 600;
}

.trim-warning-message {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  justify-content: center;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.trim-warning-message svg {
  flex-shrink: 0;
}

/* Utility classes */
.hidden {
  display: none !important;
}
