/* ==========================================================================
   Social Media Image Resizer & Post/Story Maker - Stylesheet
   Usetra Tools Design System
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-light: #e2e8f0;
  --border-focus: #3b82f6;
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px -3px rgba(15, 23, 42, 0.1);
  --accent-ig: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  --accent-wa: #25d366;
  --accent-fb: #1877f2;
}

/* Base resets & layout */
.sm-app-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1rem 3rem 1rem;
}

/* Breadcrumbs */
.sm-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.sm-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.sm-breadcrumb a:hover {
  color: var(--primary);
}
.sm-breadcrumb .separator {
  color: #cbd5e1;
}

/* Hero Header */
.sm-hero {
  text-align: center;
  margin-bottom: 2rem;
}
.sm-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.sm-hero h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 0 0 0.75rem 0;
}
.sm-hero p {
  max-width: 680px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Upload Dropzone */
.sm-upload-card {
  background: var(--bg-surface);
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  margin-bottom: 2.5rem;
}
.sm-upload-card:hover,
.sm-upload-card.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.sm-upload-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 1.25rem;
  background: #e0e7ff;
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.sm-upload-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}
.sm-upload-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 1.25rem;
}
.sm-btn-browse {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9375rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.sm-btn-browse:hover {
  background: var(--primary-hover);
}
.sm-privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  color: #15803d;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 0.3rem 0.85rem;
  border-radius: 9999px;
  font-weight: 500;
}

/* Editor Workspace (Grid on Desktop) */
.sm-editor-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(340px, 0.9fr);
  gap: 2rem;
  align-items: start;
}
@media (max-width: 960px) {
  .sm-editor-workspace {
    grid-template-columns: 1fr;
  }
}

/* Preview Canvas Container */
.sm-preview-col {
  position: sticky;
  top: 1.5rem;
}
.sm-preview-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.sm-preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.sm-preview-meta {
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sm-preview-meta .dim-tag {
  background: var(--bg-subtle);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.sm-btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.sm-btn-text:hover {
  background: var(--primary-light);
}

/* Canvas Viewport */
.sm-canvas-wrapper {
  background: #0f172a;
  background-image: 
    linear-gradient(45deg, #1e293b 25%, transparent 25%), 
    linear-gradient(-45deg, #1e293b 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #1e293b 75%), 
    linear-gradient(-45deg, transparent 75%, #1e293b 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  border-radius: var(--radius-md);
  padding: 1rem;
  min-height: 440px;
  max-height: 580px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  user-select: none;
}
.sm-canvas-wrapper canvas {
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  max-width: 100%;
  max-height: 520px;
  border-radius: 4px;
  cursor: grab;
  touch-action: none;
}
.sm-canvas-wrapper canvas.dragging {
  cursor: grabbing;
}
.sm-drag-tooltip {
  position: absolute;
  bottom: 1.25rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  pointer-events: none;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Quick Zoom & Reset Controls under Preview */
.sm-preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}
.sm-zoom-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}
.sm-zoom-group label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.sm-zoom-group input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Controls Panel */
.sm-controls-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.sm-card-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.sm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.sm-section-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sm-section-title .step-num {
  width: 22px;
  height: 22px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
}

/* Platform Filter Chips */
.sm-platform-tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  scrollbar-width: thin;
}
.sm-platform-tab {
  padding: 0.4rem 0.8rem;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.sm-platform-tab:hover {
  background: #e2e8f0;
  color: var(--text-main);
}
.sm-platform-tab.active {
  background: var(--text-main);
  color: #ffffff;
}

/* Presets Grid */
.sm-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.sm-preset-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.5rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  position: relative;
}
.sm-preset-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.sm-preset-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}
.sm-preset-btn .p-platform {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.sm-preset-btn .p-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0.15rem 0;
  line-height: 1.2;
}
.sm-preset-btn .p-dim {
  font-size: 0.6875rem;
  color: var(--primary);
  font-weight: 600;
}
.sm-preset-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.625rem;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  padding: 0.1rem 0.35rem;
  border-radius: 9999px;
  font-weight: 700;
}

/* Custom Size Inputs */
.sm-custom-size-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}
.sm-input-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
}
.sm-input-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.sm-input-group input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}

/* Mode Switch: Fit vs Fill */
.sm-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  background: var(--bg-subtle);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
.sm-mode-btn {
  padding: 0.5rem;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.sm-mode-btn:hover {
  color: var(--text-main);
}
.sm-mode-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Background Options (Fit Mode) */
.sm-bg-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.sm-bg-tab {
  flex: 1;
  padding: 0.4rem 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.sm-bg-tab.active {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* Blur Controls */
.sm-blur-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Color Swatches */
.sm-colors-grid {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.sm-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--border-light);
  cursor: pointer;
  transition: transform 0.15s;
}
.sm-color-swatch:hover,
.sm-color-swatch.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--primary);
}
.sm-color-picker-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px dashed var(--border-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  background: #ffffff;
  position: relative;
  overflow: hidden;
}
.sm-color-picker-btn input[type="color"] {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 50px;
  height: 50px;
  opacity: 0;
  cursor: pointer;
}

/* Gradient Chips */
.sm-gradients-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.sm-gradient-chip {
  height: 36px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.sm-gradient-chip:hover,
.sm-gradient-chip.active {
  transform: scale(1.04);
  border-color: var(--text-main);
}

/* Fine-Tuning Controls (Sliders & Buttons) */
.sm-control-row {
  margin-bottom: 0.85rem;
}
.sm-control-row:last-child {
  margin-bottom: 0;
}
.sm-control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}
.sm-control-label span.val {
  color: var(--primary);
  font-weight: 700;
}
.sm-slider {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Transform Button Bar */
.sm-btn-bar {
  display: flex;
  gap: 0.5rem;
}
.sm-icon-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
}
.sm-icon-btn:hover {
  background: #e2e8f0;
}

/* Export Card */
.sm-export-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.sm-export-options {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.sm-export-select-group {
  flex: 1;
}
.sm-export-select-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.sm-export-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-size: 0.8125rem;
  font-weight: 600;
}
.sm-btn-download-main {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.95rem;
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
  transition: all 0.15s;
}
.sm-btn-download-main:hover {
  background: #15803d;
  transform: translateY(-1px);
}
.sm-btn-download-main:active {
  transform: translateY(0);
}
.sm-sub-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.sm-btn-sub {
  flex: 1;
  padding: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
}
.sm-btn-sub:hover {
  background: #f8fafc;
}

/* Toast Notification */
.sm-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 99999;
}
.sm-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* SEO Educational Content */
.sm-seo-section {
  max-width: 960px;
  margin: 4rem auto 0;
  border-top: 1px solid var(--border-light);
  padding-top: 3rem;
}
.sm-seo-section h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}
.sm-seo-section h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 1.75rem 0 0.75rem;
}
.sm-seo-section p, .sm-seo-section li {
  color: #475569;
  font-size: 1rem;
  line-height: 1.7;
}

/* Size Reference Table */
.sm-size-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}
.sm-size-table th,
.sm-size-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9375rem;
}
.sm-size-table th {
  background: var(--bg-subtle);
  font-weight: 700;
  color: var(--text-main);
}
.sm-size-table tr:last-child td {
  border-bottom: none;
}
.sm-size-table .badge-ratio {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.8125rem;
}

/* FAQ Accordion */
.sm-faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.sm-faq-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}
.sm-faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  text-align: left;
  background: none;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sm-faq-question .arrow {
  transition: transform 0.2s;
}
.sm-faq-item.open .sm-faq-question .arrow {
  transform: rotate(180deg);
}
.sm-faq-answer {
  padding: 0 1.25rem 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
  display: none;
}
.sm-faq-item.open .sm-faq-answer {
  display: block;
}

/* Related Tools Grid */
.sm-related-tools {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border-light);
}
.sm-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.sm-tool-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.15s;
}
.sm-tool-pill:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.sm-tool-pill .icon {
  font-size: 1.5rem;
}
.sm-tool-pill .name {
  font-weight: 700;
  font-size: 0.875rem;
}
.sm-tool-pill .desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}
