/**
 * smallai.tools - Global Animated File Uploader Component
 * Inspired by Dribbble 3D animated file upload interaction.
 * 100% Parent Width Responsive, Theme-Aware (Light & Dark), Zero Dependencies.
 */

/* ==========================================================================
   1. UNIVERSAL UPLOADER CONTAINER & DROPZONE
   ========================================================================== */
.smallai-uploader-zone,
.upload-dropzone,
.ic-dropzone,
.resizer-dropzone,
.editor-dropzone,
#comp-dropzone,
#p2i-dropzone,
#i2p-dropzone,
#merge-dropzone,
#split-dropzone,
#org-dropzone,
#wm-dropzone,
#prot-dropzone,
#prot-drop-zone,
#unlock-dropzone,
#unlock-drop-zone,
#sp-dropzone,
#spDropZone,
#pdf-drop-zone,
#pdf-dropzone,
#pc-drop-zone,
#pdf-maker-dropzone,
#pdf-maker-drop-zone,
#pe-drop-zone,
#scanner-dropzone,
#vc-drop-zone,
#vconv-drop-zone,
#vg-drop-zone,
#vw-drop-zone,
#vs-drop-zone,
#ea-drop-zone,
#mv-drop-zone,
#exif-dropzone,
#exif-drop-zone,
#conv-drop-zone,
#editor-drop-zone,
#resizer-drop-zone,
#fav-drop-zone,
#flip-dropzone,
#rot-dropzone,
#wip-dropzone,
#flipkart-dropzone,
#meesho-dropzone,
#pdf-crop-dropzone,
#image-dropzone,
#pan-photo-dropzone,
#pan-sign-dropzone,
#psr-photo-dropzone,
#psr-sign-dropzone,
.psr-upload-zone,
.ai-dropzone,
#aiDropZone,
.uconv-dropzone,
#uconv-dropzone,
[data-uploader] {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  position: relative !important;
  background: var(--solidbw, #ffffff);
  border: 2px dashed rgba(61, 70, 240, 0.28) !important;
  border-radius: var(--radius-lg, 20px) !important;
  padding: 2.25rem 1.5rem !important;
  text-align: center !important;
  cursor: pointer !important;
  overflow: hidden !important;
  transition: border-color 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.2s ease !important;
  box-shadow: 0 4px 24px -2px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}

/* Allow tools to hide dropzone cleanly when file selected */
.smallai-uploader-zone[style*="display: none"],
.smallai-uploader-zone.is-hidden,
.upload-dropzone[style*="display: none"],
.upload-dropzone.is-hidden,
.ic-dropzone[style*="display: none"],
.ic-dropzone.is-hidden,
.resizer-dropzone[style*="display: none"],
.resizer-dropzone.is-hidden,
.editor-dropzone[style*="display: none"],
.editor-dropzone.is-hidden,
#comp-dropzone[style*="display: none"],
#comp-dropzone.is-hidden,
#p2i-dropzone[style*="display: none"],
#p2i-dropzone.is-hidden,
#i2p-dropzone[style*="display: none"],
#i2p-dropzone.is-hidden,
#vc-drop-zone[style*="display: none"],
#vc-drop-zone.is-hidden,
.psr-upload-zone[style*="display: none"],
.psr-upload-zone.is-hidden,
.ai-dropzone[style*="display: none"],
.ai-dropzone.is-hidden,
.uconv-dropzone[style*="display: none"],
.uconv-dropzone.is-hidden,
#uconv-dropzone[style*="display: none"],
#uconv-dropzone.is-hidden {
  display: none !important;
}

/* Subtle background aura */
.smallai-uploader-zone::before,
.upload-dropzone::before,
.ic-dropzone::before,
.resizer-dropzone::before,
.editor-dropzone::before,
#comp-dropzone::before,
#p2i-dropzone::before,
#i2p-dropzone::before,
.ai-dropzone::before {
  content: "";
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 240px;
  background: radial-gradient(circle, rgba(61, 70, 240, 0.07) 0%, rgba(61, 70, 240, 0) 70%);
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

html[data-theme="dark"] .smallai-uploader-zone,
html[data-theme="dark"] .upload-dropzone,
html[data-theme="dark"] .ic-dropzone,
html[data-theme="dark"] .resizer-dropzone,
html[data-theme="dark"] .editor-dropzone,
html[data-theme="dark"] #comp-dropzone,
html[data-theme="dark"] #p2i-dropzone,
html[data-theme="dark"] #i2p-dropzone,
html[data-theme="dark"] .psr-upload-zone,
html[data-theme="dark"] .ai-dropzone {
  background: var(--solidbw, #161c28) !important;
  border-color: rgba(99, 102, 241, 0.3) !important;
  box-shadow: 0 6px 28px -4px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .smallai-uploader-zone::before,
html[data-theme="dark"] .upload-dropzone::before,
html[data-theme="dark"] .ic-dropzone::before,
html[data-theme="dark"] .resizer-dropzone::before,
html[data-theme="dark"] .editor-dropzone::before,
html[data-theme="dark"] #comp-dropzone::before,
html[data-theme="dark"] #p2i-dropzone::before,
html[data-theme="dark"] #i2p-dropzone::before,
html[data-theme="dark"] .ai-dropzone::before {
  background: radial-gradient(circle, rgba(99, 102, 241, 0.16) 0%, transparent 70%);
}

/* ==========================================================================
   2. HOVER & DRAG-OVER ACTIVE STATES
   ========================================================================== */
.smallai-uploader-zone:hover,
.upload-dropzone:hover,
.ic-dropzone:hover,
.resizer-dropzone:hover,
.editor-dropzone:hover,
#comp-dropzone:hover,
#p2i-dropzone:hover,
#i2p-dropzone:hover,
.ai-dropzone:hover {
  border-color: var(--indigo, #3D46F0) !important;
  box-shadow: 0 10px 32px -4px rgba(61, 70, 240, 0.14) !important;
}

.smallai-uploader-zone.is-dragover,
.upload-dropzone.is-dragover,
.upload-dropzone.dragover,
.ic-dropzone.is-dragover,
.ic-dropzone.dragover,
.resizer-dropzone.dragover,
.editor-dropzone.dragover,
#comp-dropzone.is-dragover,
#p2i-dropzone.is-dragover,
#i2p-dropzone.is-dragover,
.psr-upload-zone.dragover,
.ai-dropzone.dragover {
  border-color: var(--indigo, #3D46F0) !important;
  background: var(--indigo-tint, rgba(61, 70, 240, 0.06)) !important;
  box-shadow: 0 0 0 4px rgba(61, 70, 240, 0.18), 0 16px 40px -6px rgba(61, 70, 240, 0.22) !important;
  transform: scale(1.008);
}

.smallai-uploader-zone.is-dragover .uploader-art-card,
.upload-dropzone.is-dragover .uploader-art-card,
.ic-dropzone.is-dragover .uploader-art-card {
  transform: translateY(-8px) scale(1.08) !important;
}

.smallai-uploader-zone.is-dragover .uploader-badge,
.upload-dropzone.is-dragover .uploader-badge,
.ic-dropzone.is-dragover .uploader-badge {
  transform: scale(1.15) !important;
  background: var(--indigo, #3D46F0) !important;
  color: #ffffff !important;
  box-shadow: 0 0 20px rgba(61, 70, 240, 0.6) !important;
}

/* ==========================================================================
   3. 3D-STYLE FLOATING ILLUSTRATION (DRIBBLE REFERENCE REPLICA)
   ========================================================================== */
.uploader-art-wrap {
  position: relative;
  width: 170px;
  height: 120px;
  margin: 0 auto 1.15rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

/* Organic Floating Movement */
.uploader-art-card {
  position: relative;
  width: 82px;
  height: 104px;
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
  border: 1.5px solid rgba(203, 213, 225, 0.85);
  border-radius: 12px;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: uploaderFloat 5s ease-in-out infinite;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2;
}

html[data-theme="dark"] .uploader-art-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-color: rgba(71, 85, 105, 0.8);
  box-shadow: 0 14px 34px -4px rgba(0, 0, 0, 0.45);
}

/* Folded Corner */
.uploader-art-card::after {
  content: "";
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, transparent 50%, rgba(203, 213, 225, 0.9) 50%);
  border-bottom-left-radius: 6px;
  box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] .uploader-art-card::after {
  background: linear-gradient(135deg, transparent 50%, rgba(51, 65, 85, 0.9) 50%);
}

/* Interior Document Lines */
.uploader-card-line {
  position: absolute;
  top: 18px;
  left: 14px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
}
.uploader-card-line-1 { width: 32px; }
.uploader-card-line-2 { top: 26px; width: 20px; }

html[data-theme="dark"] .uploader-card-line {
  background: #334155;
}

/* Centerpiece Glowing Circular Action Badge */
.uploader-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--indigo, #3D46F0);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 6px 18px rgba(61, 70, 240, 0.4);
  position: relative;
  z-index: 3;
  margin-top: 14px;
  animation: uploaderBadgePulse 3.5s ease-in-out infinite;
  transition: transform 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

/* Left & Right Soft Floating Clouds */
.uploader-cloud {
  position: absolute;
  fill: #f1f5f9;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.05));
  z-index: 1;
  transition: transform 0.3s ease;
}

html[data-theme="dark"] .uploader-cloud {
  fill: #1e293b;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
}

.uploader-cloud-left {
  left: 6px;
  bottom: 8px;
  width: 62px;
  height: 44px;
  animation: uploaderCloudLeft 6s ease-in-out infinite;
}

.uploader-cloud-right {
  right: 6px;
  bottom: 14px;
  width: 72px;
  height: 50px;
  z-index: 3;
  animation: uploaderCloudRight 5.5s ease-in-out infinite 0.6s;
}

/* Ambient Micro-Sparkles */
.uploader-sparkle {
  position: absolute;
  color: #f59e0b;
  font-size: 14px;
  opacity: 0.85;
  animation: uploaderSparkle 3s ease-in-out infinite;
}
.uploader-sparkle-1 { top: 6px; left: 16px; animation-delay: 0.2s; }
.uploader-sparkle-2 { bottom: 12px; right: 20px; color: #10b981; animation-delay: 1.4s; }

/* ==========================================================================
   4. KEYFRAME ANIMATIONS
   ========================================================================== */
@keyframes uploaderFloat {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-9px) rotate(1deg);
  }
}

@keyframes uploaderBadgePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(61, 70, 240, 0.38);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(61, 70, 240, 0.58);
  }
}

@keyframes uploaderCloudLeft {
  0%, 100% {
    transform: translateX(0px) scale(1);
  }
  50% {
    transform: translateX(-5px) scale(1.04);
  }
}

@keyframes uploaderCloudRight {
  0%, 100% {
    transform: translateX(0px) scale(1);
  }
  50% {
    transform: translateX(6px) scale(1.03);
  }
}

@keyframes uploaderSparkle {
  0%, 100% {
    transform: scale(0.8) rotate(0deg);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.2) rotate(180deg);
    opacity: 1;
  }
}

@keyframes uploaderSpin {
  to { transform: rotate(360deg); }
}

@keyframes uploaderShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Reduced Motion Fallback */
@media (prefers-reduced-motion: reduce) {
  .uploader-art-card,
  .uploader-badge,
  .uploader-cloud-left,
  .uploader-cloud-right,
  .uploader-sparkle {
    animation: none !important;
    transform: none !important;
  }
}

/* ==========================================================================
   5. TYPOGRAPHY, BUTTONS & ACTIONS
   ========================================================================== */
.uploader-title,
.ic-dropzone-title,
.ai-dropzone-title {
  font-family: var(--font-heading, "Space Grotesk", sans-serif) !important;
  font-size: 1.3rem !important;
  font-weight: 700 !important;
  color: var(--ink, #0f172a) !important;
  margin: 0 0 6px 0 !important;
  line-height: 1.3 !important;
  position: relative;
  z-index: 2;
}

.uploader-subtitle,
.ic-dropzone-desc,
.ai-dropzone-desc {
  font-size: 0.92rem !important;
  color: var(--ink-soft, #475569) !important;
  max-width: 540px !important;
  margin: 0 auto 1rem auto !important;
  line-height: 1.55 !important;
  position: relative;
  z-index: 2;
}

.uploader-browse-link {
  color: var(--indigo, #3D46F0);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.15s ease;
}
.uploader-browse-link:hover {
  color: var(--indigo-deep, #2b32b2);
}

.uploader-actions,
.ic-dropzone-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 2;
}

/* Reusable Global Browse / Select Button */
.uploader-browse-btn,
.ic-btn-select {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 10px 24px !important;
  font-size: 14.5px !important;
  font-weight: 600 !important;
  border-radius: var(--radius-sm, 8px) !important;
  background: var(--indigo, #3D46F0) !important;
  color: #ffffff !important;
  border: none !important;
  cursor: pointer !important;
  box-shadow: 0 4px 14px rgba(61, 70, 240, 0.28) !important;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease !important;
}

.uploader-browse-btn:hover,
.ic-btn-select:hover {
  background: var(--indigo-deep, #2e34bd) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(61, 70, 240, 0.38) !important;
}

.uploader-browse-btn i,
.ic-btn-select i {
  font-size: 16px;
  line-height: 1;
}

/* ==========================================================================
   6. METADATA CHIPS & BADGES
   ========================================================================== */
.uploader-meta-row,
.ic-dropzone-badges {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
  position: relative;
  z-index: 2;
  margin-top: 4px;
}

.uploader-meta-chip,
.ic-feat-badge {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  color: var(--ink-soft, #475569) !important;
  background: var(--paper-alt, #f8fafc) !important;
  border: 1px solid var(--line, #e2e8f0) !important;
  border-radius: 999px !important;
  padding: 4px 12px !important;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

html[data-theme="dark"] .uploader-meta-chip,
html[data-theme="dark"] .ic-feat-badge {
  background: rgba(30, 41, 59, 0.7) !important;
  border-color: rgba(71, 85, 105, 0.6) !important;
  color: var(--ink-soft, #94a3b8) !important;
}

.uploader-meta-chip i,
.ic-feat-badge svg,
.ic-feat-badge i {
  font-size: 13px !important;
}

/* ==========================================================================
   7. ICON CLEANUP & STATIC DUPLICATE SUPPRESSION
   ========================================================================== */
.smallai-uploader-zone .pdf-dropzone-icon,
.smallai-uploader-zone .uconv-dropzone-icon,
.smallai-uploader-zone .crop-dropzone-icon,
.smallai-uploader-zone .dropzone-animated-icon,
.smallai-uploader-zone .ic-dropzone-icon,
.smallai-uploader-zone .resizer-drop-icon,
.smallai-uploader-zone .editor-drop-icon,
.smallai-uploader-zone .ai-dropzone-icon,
.smallai-uploader-zone .sp-upload-icon,
.smallai-uploader-zone [class*="-dropzone-icon"],
.smallai-uploader-zone [class*="-upload-icon"],
.uploader-art-wrap ~ [class*="-dropzone-icon"],
.uploader-art-wrap ~ [class*="-upload-icon"],
.pdf-dropzone-icon,
.uconv-dropzone-icon,
.crop-dropzone-icon,
.dropzone-animated-icon,
.ic-dropzone-icon {
  display: none !important;
}
  color: var(--indigo, #3D46F0) !important;
  flex-shrink: 0;
}

/* ==========================================================================
   7. PROGRESS, PROCESSING & ERROR STATES
   ========================================================================== */
.uploader-status-wrap {
  width: 100%;
  max-width: 440px;
  margin: 1rem auto 0 auto;
  position: relative;
  z-index: 3;
}

.uploader-progress-card {
  background: var(--paper-alt, #f8fafc);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: var(--radius-md, 12px);
  padding: 12px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

html[data-theme="dark"] .uploader-progress-card {
  background: #1e293b;
  border-color: #334155;
}

.uploader-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #0f172a);
}

.uploader-progress-filename {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}

.uploader-progress-track {
  width: 100%;
  height: 6px;
  background: var(--line, #e2e8f0);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

html[data-theme="dark"] .uploader-progress-track {
  background: #334155;
}

.uploader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--indigo, #3D46F0) 0%, #6366f1 100%);
  border-radius: 999px;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.uploader-progress-bar.indeterminate {
  width: 40% !important;
  animation: uploaderIndeterminate 1.4s infinite ease-in-out;
}

@keyframes uploaderIndeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* Error Banner */
.uploader-error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #dc2626;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  margin-top: 12px;
  animation: uploaderShake 0.4s ease;
}

html[data-theme="dark"] .uploader-error-banner {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* ==========================================================================
   8. BOOTSTRAP ICONS & GLOBAL BUTTON ICON ALIGNMENT
   ========================================================================== */
.btn i.bi,
.btn .bi,
.uploader-browse-btn i,
button i.bi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.125em;
  font-size: 1.1em;
  line-height: 1;
}

.btn i.bi:first-child:not(:last-child),
.btn .bi:first-child:not(:last-child),
button i.bi:first-child:not(:last-child) {
  margin-right: 0.45rem;
}

html[dir="rtl"] .btn i.bi:first-child:not(:last-child),
html[dir="rtl"] .btn .bi:first-child:not(:last-child),
html[dir="rtl"] button i.bi:first-child:not(:last-child) {
  margin-right: 0;
  margin-left: 0.45rem;
}

/* ==========================================================================
   9. RESPONSIVE ADAPTATIONS
   ========================================================================== */
@media (max-width: 600px) {
  .smallai-uploader-zone,
  .upload-dropzone,
  .ic-dropzone,
  .resizer-dropzone,
  .editor-dropzone,
  #comp-dropzone,
  #p2i-dropzone,
  #i2p-dropzone,
  .ai-dropzone {
    padding: 2rem 1rem !important;
    border-radius: 14px !important;
  }
  .uploader-art-wrap {
    width: 140px;
    height: 100px;
    margin-bottom: 1rem;
  }
  .uploader-art-card {
    width: 68px;
    height: 88px;
  }
  .uploader-badge {
    width: 38px;
    height: 38px;
    font-size: 17px;
    margin-top: 10px;
  }
  .uploader-title,
  .ic-dropzone-title,
  .ai-dropzone-title {
    font-size: 1.15rem !important;
  }
  .uploader-subtitle,
  .ic-dropzone-desc,
  .ai-dropzone-desc {
    font-size: 0.85rem !important;
    margin-bottom: 1rem !important;
  }
  .uploader-browse-btn,
  .ic-btn-select {
    width: 100%;
    padding: 11px 18px !important;
  }
  .uploader-meta-chip,
  .ic-feat-badge {
    font-size: 11.5px !important;
    padding: 3px 9px !important;
  }
}
