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

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

:root {
  –primary: #667eea;
  –primary-dark: #5568d3;
  –primary-bright: #818cf8;
  –secondary: #764ba2;
  –secondary-bright: #a78bfa;
  –success: #10b981;
  –error: #ef4444;
  –warning: #f59e0b;
  –gray-50: #f9fafb;
  –gray-100: #f3f4f6;
  –gray-200: #e5e7eb;
  –gray-300: #d1d5db;
  –gray-400: #9ca3af;
  –gray-500: #6b7280;
  –gray-600: #4b5563;
  –gray-700: #374151;
  –gray-800: #1f2937;
  –gray-900: #111827;
  –shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  –shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  –shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  –shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  –shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0, #764ba2 100%);
  min-height: 100vh;
  padding: 2rem 1rem;
  color: var(–gray-900);
  line-height: 1.6;
  overflow-x: hidden;
  max-width: 100vw;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.card {
  background: #fff;
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(–shadow-lg);
}

.card-heading {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(–gray-900);
  margin: 0;
}

.card-heading:not(:last-child) {
  margin-bottom: 1rem;
}

.header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.logo {
  flex-shrink: 0;
}

.drop-zone h3,
.header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(–gray-900);
  margin-bottom: 0.25rem;
}

.drop-zone p,
.header p {
  color: var(–gray-600);
  font-size: 0.875rem;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.drop-zone {
  border: 3px dashed var(–gray-300);
  border-radius: 0.75rem;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(–gray-50);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.drop-zone::before {
  content: ‘’;
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(–primary), var(–secondary));
  opacity: 0;
  transition: opacity 0.3s;
}

.drop-zone:hover::before {
  opacity: 0.05;
}

.drop-zone.dragover,
.drop-zone:hover {
  border-color: var(–primary);
  will-change: transform;
}

.drop-zone:hover {
  transform: translateY(-2px);
}

.drop-zone.dragover {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1),
    rgba(118, 75, 162, 0.1)
  );
  transform: scale(1.01);
}

.drop-zone.dragover::before {
  opacity: 0.1;
}

.upload-icon {
  color: var(–primary);
  margin-bottom: 0.75rem;
  width: 48px;
  height: 48px;
}

.drop-zone h3 {
  font-size: 1rem;
  font-weight: 600;
}

.drop-zone p {
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
}

.drop-zone > div:last-child {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.format-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#previewSection {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card-header {
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.btn-clear,
.card-header,
.preview-wrapper {
  display: flex;
  align-items: center;
}

.btn-clear {
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(–gray-100);
  border: 0;
  border-radius: 0.5rem;
  color: var(–gray-700);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear:hover {
  background: var(–gray-200);
  color: var(–gray-900);
}

.preview-wrapper {
  justify-content: center;
  min-height: 400px;
  background: repeating-conic-gradient(var(–gray-100) 0% 25%, white 0% 50%) 50%/20px
    20px;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

#preview,
#previewCanvas {
  max-width: 100%;
  max-height: 600px;
  width: auto;
  height: auto;
  border-radius: 0.5rem;
  box-shadow: var(–shadow-md);
  object-fit: contain;
  display: block;
}

#previewCanvas {
  background: transparent;
}

.image-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(–gray-50);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(–gray-600);
}

.image-info > div {
  word-break: break-all;
}

.crop-options {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.crop-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  transition: background-color 0.2s;
  user-select: none;
  border: 2px solid transparent;
}

.crop-option:hover {
  background: var(–gray-100);
}

.crop-option input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.compression-option span,
.crop-option span {
  font-size: 0.875rem;
  color: var(–gray-700);
  font-weight: 500;
}

.crop-option input[type="radio"]:checked + span {
  color: var(–gray-900);
  font-weight: 600;
}

.crop-option:has(input[type="radio"]:checked) {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1),
    rgba(118, 75, 162, 0.1)
  );
  border-color: var(–primary);
}

.crop-option:has(input[type="radio"]:checked):hover {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.15),
    rgba(118, 75, 162, 0.15)
  );
}

#customCropInputs {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(–gray-200);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
}

#customCropInputs label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

#customCropInputs label span {
  font-size: 0.875rem;
  color: var(–gray-700);
  font-weight: 500;
  min-width: 60px;
}

#customCropInputs input[type="number"] {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(–gray-300);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(–gray-900);
  transition: border-color 0.2s;
}

#customCropInputs input[type="number"]:focus,
.compression-option select:focus {
  outline: 0;
  border-color: var(–primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.crop-position-selector {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(–gray-200);
}

.crop-position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0.3rem;
  max-width: 140px;
  margin: 0;
}

.crop-position-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.4rem 0.3rem;
  border: 2px solid var(–gray-300);
  border-radius: 0.5rem;
  background: var(–gray-50);
  color: var(–gray-700);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  min-height: 42px;
}

.crop-position-btn:hover {
  background: var(–gray-100);
  border-color: var(–gray-400);
  transform: translateY(-1px);
}

.crop-position-btn:active {
  transform: translateY(0);
}

.crop-position-btn.active {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1),
    rgba(118, 75, 162, 0.1)
  );
  border-color: var(–primary);
  color: var(–gray-900);
  font-weight: 600;
}

.crop-position-btn.active:hover {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.15),
    rgba(118, 75, 162, 0.15)
  );
}

.crop-position-btn svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.crop-position-btn span {
  font-size: 0.65rem;
  line-height: 1;
}

/* Grid positioning for compass layout */
.crop-position-btn[data-position="top"] {
  grid-column: 2;
  grid-row: 1;
}

.crop-position-btn[data-position="left"] {
  grid-column: 1;
  grid-row: 2;
}

.crop-position-btn[data-position="center"] {
  grid-column: 2;
  grid-row: 2;
}

.crop-position-btn[data-position="right"] {
  grid-column: 3;
  grid-row: 2;
}

.crop-position-btn[data-position="bottom"] {
  grid-column: 2;
  grid-row: 3;
}

.card p {
  color: var(–gray-600);
  font-size: 0.875rem;
}

.compression-option {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(–gray-50);
  border-radius: 0.5rem;
  padding: 0.75rem;
  user-select: none;
}

.compression-option select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(–gray-300);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(–gray-900);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
}

.compression-help {
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  padding: 0.75rem 1rem;
  background: var(–gray-50);
  border-radius: 0.5rem;
  border-left: 3px solid var(–primary);
}

.compression-help p {
  margin: 0;
  color: var(–gray-700);
}

.compression-help strong {
  color: var(–gray-900);
  font-weight: 600;
}

.settings-card {
  width: 100%;
}

.settings-group {
  margin-bottom: 1.5rem;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(–gray-700);
  margin-bottom: 0.75rem;
}

.preview-card {
  width: 100%;
  flex: 1;
}

.tab-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  transition: background-color 0.2s;
  user-select: none;
  border: 2px solid transparent;
  background: transparent;
  color: var(–gray-700);
  font-size: 0.875rem;
  font-weight: 500;
}

.tab-btn:hover {
  background: var(–gray-100);
  color: var(–gray-900);
}

.tab-btn.active {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1),
    rgba(118, 75, 162, 0.1)
  );
  border-color: var(–primary);
  color: var(–gray-900);
  font-weight: 600;
}

.tab-btn.active:hover {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.15),
    rgba(118, 75, 162, 0.15)
  );
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

#previewSection .card:last-child {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.btn-convert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #9399ff 0, #b990ff 100%);
  border: 0;
  border-radius: 0.75rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(147, 153, 255, 0.4);
  margin-top: auto;
}

.btn-convert:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(147, 153, 255, 0.6);
  background: linear-gradient(135deg, #a5abff 0, #c9a3ff 100%);
  will-change: transform;
}

.btn-convert:active {
  transform: translateY(0);
}

.btn-convert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.notification {
  position: fixed;
  top: 2rem;
  right: 2rem;
  background: #fff;
  border-radius: 0.75rem;
  padding: 1rem 1.5rem;
  box-shadow: var(–shadow-xl);
  transform: translateY(-120%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  box-sizing: border-box;
  max-width: calc(100vw - 4rem);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notification.visible {
  transform: translateY(0);
}

.notification-icon {
  flex-shrink: 0;
}

.notification.success .notification-icon {
  color: var(–success);
}

.notification.error .notification-icon {
  color: var(–error);
}

.notification.info .notification-icon {
  color: var(–primary);
}

#notificationText {
  font-size: 0.875rem;
  color: var(–gray-900);
  font-weight: 500;
}

@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .card,
  .header {
    padding: 1.5rem;
  }

  .header {
    text-align: center;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .header {
    flex-direction: column;
  }

  #previewSection {
    flex-direction: column;
  }

  #previewSection .card {
    width: 100% !important;
  }

  .tab-bar {
    flex-wrap: wrap;
  }

  .tab-btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }

  .notification {
    right: 1rem;
    left: 1rem;
    top: 1rem;
    max-width: none;
    transform: translateY(-120%);
  }

  .notification.visible {
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .card {
    padding: 1rem;
  }

  .drop-zone {
    padding: 1.25rem 0.75rem;
  }

  .upload-icon {
    width: 40px;
    height: 40px;
  }

  .preview-wrapper {
    min-height: 300px;
    padding: 1rem;
  }

  #preview {
    max-height: 500px;
  }

  .crop-options {
    flex-direction: column;
    gap: 0.75rem;
  }

  .crop-option {
    width: 100%;
    justify-content: flex-start;
  }

  .crop-position-grid {
    max-width: 130px;
    gap: 0.25rem;
  }

  .crop-position-btn {
    min-height: 40px;
    padding: 0.35rem 0.25rem;
    font-size: 0.6rem;
  }

  .crop-position-btn svg {
    width: 12px;
    height: 12px;
  }
}

.btn-convert:disabled svg {
  animation: spin 1s linear infinite;
}

/* Buy Me a Coffee Button Styling */
/* Using !important is necessary here because the third-party script injects
   dynamic HTML and inline styles that would otherwise override our styles */
.bmc-button-container {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
  margin: 2rem auto 0 !important;
  padding-bottom: 2rem !important;
}

#bmc-wbtn,
.bmc-btn,
[data-name="bmc-button"] {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  margin: 0 auto !important;
  transform: scale(0.65) !important;
  transform-origin: center !important;
}

/* Container for the button */
#bmc-wbtn-container,
.bmc-btn-container {
  display: flex !important;
  justify-content: center !important;
  width: 100% !important;
}

/* Iframe styling if the button is in an iframe */
#bmc-wbtn iframe,
.bmc-btn iframe {
  transform: scale(0.75) !important;
  transform-origin: center !important;
}

/* Footer */
.footer {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #fff;
  border-radius: 0.75rem;
  color: var(--gray-700);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.footer-link:hover {
  color: var(--gray-900);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.footer-link svg {
  flex-shrink: 0;
  color: var(--primary);
}

.footer-link:hover svg {
  color: var(--primary-dark);
}

@media (max-width: 768px) {
  .footer-link {
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
  }
}
