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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --text-dark: #1f2937;
  --text-light: #6b7280;
  --bg-light: #f9fafb;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-container {
  width: 100%;
  max-width: 1200px;
  background: white;
  border-radius: 24px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: slideUp 0.5s ease;
}

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

.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title h1 {
  font-size: 24px;
  font-weight: 700;
}

.app-title .logo {
  font-size: 32px;
  animation: float 3s ease-in-out infinite;
}

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

.header-actions {
  display: flex;
  gap: 12px;
}

.header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.settings-btn-icon {
  transition: transform 0.3s;
}

.header-btn:hover .settings-btn-icon {
  transform: rotate(90deg);
}

.app-body {
  padding: 32px;
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 24px;
}

/* Upload Section */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.upload-zone {
  border: 3px dashed var(--primary);
  border-radius: 20px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #f3f4ff 0%, #faf5ff 100%);
  position: relative;
  overflow: hidden;
  min-height: 350px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-zone::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.3; }
}

.upload-zone:hover {
  border-color: var(--secondary);
  background: linear-gradient(135deg, #eef0ff 0%, #f5edff 100%);
  transform: scale(1.02);
}

.upload-zone.dragover {
  background: linear-gradient(135deg, #e0e2ff 0%, #ede0ff 100%);
  border-color: var(--secondary);
  transform: scale(1.05);
}

.upload-icon {
  font-size: 72px;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
  position: relative;
  z-index: 1;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.upload-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.upload-hint {
  font-size: 14px;
  color: var(--text-light);
  position: relative;
  z-index: 1;
}

.file-input {
  display: none;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: var(--bg-light);
  color: var(--text-dark);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn:disabled {
  background: #d1d5db;
  color: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
}

/* Preview Section */
.preview-section {
  background: var(--bg-light);
  border-radius: 20px;
  padding: 24px;
  min-height: 350px;
  display: flex;
  flex-direction: column;
}

.preview-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

.preview-content {
  flex: 1;
  display: none;
}

.preview-image-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow-md);
}

.preview-image {
  width: 100%;
  height: 250px;
  object-fit: contain;
  background: white;
}

.preview-remove {
  position: absolute;
  top: 12px;
  right: 12px;
  background: white;
  border: none;
  color: var(--error);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.3s;
  font-size: 18px;
}

.preview-remove:hover {
  background: var(--error);
  color: white;
  transform: scale(1.1);
}

.preview-details {
  margin-top: 16px;
  padding: 16px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.preview-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.preview-detail-row:last-child {
  border-bottom: none;
}

.preview-detail-label {
  font-size: 13px;
  color: var(--text-light);
}

.preview-detail-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 1.5s infinite;
}

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

.progress-text {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  text-align: center;
}

/* Result Section */
.result-section {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 2px solid var(--success);
  border-radius: 16px;
  padding: 20px;
  margin-top: 24px;
  display: none;
  animation: slideUp 0.5s ease;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.link-input {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: monospace;
  background: white;
}

.link-input:focus {
  outline: none;
  border-color: var(--primary);
}

.copy-btn {
  padding: 12px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.copy-btn.copied {
  background: var(--success);
}

/* Status Message */
.status-message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 24px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: none;
  animation: slideInRight 0.3s ease;
  z-index: 2000;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.status-message.success {
  background: var(--success);
  color: white;
}

.status-message.error {
  background: var(--error);
  color: white;
}

.status-message.warning {
  background: var(--warning);
  color: white;
}

/* Settings Panel */
.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.settings-overlay.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow-xl);
  z-index: 1001;
  display: none;
  overflow: hidden;
  animation: scaleIn 0.3s ease;
}

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

@keyframes scaleIn {
  from { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.settings-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.close-settings {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 20px;
}

.close-settings:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.settings-content {
  padding: 24px;
  max-height: calc(90vh - 80px);
  overflow-y: auto;
}

.settings-group {
  margin-bottom: 24px;
}

.settings-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.settings-field {
  margin-bottom: 16px;
}

.settings-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.settings-input-wrapper {
  position: relative;
}

.settings-input {
  width: 100%;
  padding: 10px 14px;
  padding-right: 44px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.3s;
}

.settings-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.toggle-visibility {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 18px;
  transition: color 0.3s;
  padding: 4px;
}

.toggle-visibility:hover {
  color: var(--primary);
}

.settings-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.settings-btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.settings-save {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
}

.settings-save:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.settings-reset {
  background: var(--bg-light);
  color: var(--text-dark);
  border: 2px solid var(--border);
}

.settings-reset:hover {
  background: var(--border);
}

/* Uploaded Image Preview */
.uploaded-image-preview {
  margin-top: 24px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: none;
  animation: fadeIn 0.5s ease;
}

.uploaded-image-preview img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  background: var(--bg-light);
}

/* Responsive Design */
@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    padding: 20px;
  }

  .app-title h1 {
    font-size: 20px;
  }

  .header-btn span {
    display: none;
  }

  .settings-panel {
    width: 95%;
    max-height: 95vh;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}