/* Premium Flipkart Label Cropper - styles */

:root {
  --accent-1: #2874F0;
  --accent-2: #60A5FA;
  --ink: #1E1B2E;
  --ink-soft: #6B7280;
  --border: #E5E7EB;
  --bg-soft: #EFF6FF;
  --danger: #DC2626;
  --success: #059669;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(160deg, #EFF6FF 0%, #E0F2FE 45%, #F8FAFC 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app-wrapper { max-width: 1080px; margin: 0 auto; padding: 70px 20px 40px; }

.glass-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(40, 116, 240, 0.12), 0 2px 8px rgba(0,0,0,0.04);
  padding: 28px 24px;
}

.app-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.app-icon svg { width: 28px; height: 28px; }

.app-title { text-align: center; font-size: 26px; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.02em; }
.app-subtitle { text-align: center; color: var(--ink-soft); font-size: 14.5px; margin: 0 0 28px; }

.screen { display: none; }
.screen.active { display: block; }

/* ---------------- Upload ---------------- */
.upload-zone {
  border: 2px dashed #BFDBFE;
  border-radius: 18px;
  background: var(--bg-soft);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent-1); background: #DBEAFE; }
.upload-icon { width: 46px; height: 46px; color: var(--accent-1); margin-bottom: 14px; }
.upload-text { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.upload-subtext { color: var(--ink-soft); font-size: 13px; margin-bottom: 14px; }
.btn-choose {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff; border: none; padding: 11px 26px; border-radius: 30px;
  font-weight: 700; font-size: 14px; cursor: pointer;
}
.upload-meta { margin-top: 16px; font-size: 12px; color: #9CA3AF; }

.upload-progress-card {
  margin-top: 16px; background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}
.upload-progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.spinner { width: 22px; height: 22px; flex: none; animation: spin 0.9s linear infinite; }
.spinner circle { stroke: var(--accent-1); stroke-dasharray: 46; stroke-dashoffset: 14; stroke-linecap: round; }
@keyframes spin { to { transform: rotate(360deg); } }
.upload-progress-text { flex: 1; min-width: 0; text-align: left; }
.upload-progress-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-progress-label { font-size: 12px; color: var(--ink-soft); }
.upload-progress-percent { font-size: 15px; font-weight: 800; color: var(--accent-1); flex: none; }
.upload-progress-track { height: 6px; background: var(--bg-soft); border-radius: 6px; overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); transition: width 0.2s ease; }

/* ---------------- Toolbar ---------------- */
.toolbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.toolbar-file { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.link-btn { background: none; border: none; color: var(--accent-1); font-weight: 700; font-size: 13px; cursor: pointer; padding: 0; }

/* ---------------- Editor layout ---------------- */
.editor-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px;
  margin-bottom: 20px; align-items: start;
}
@media (max-width: 860px) { .editor-layout { grid-template-columns: 1fr; } }
.editor-main { min-width: 0; }

.editor-stage-wrap { display: flex; align-items: center; gap: 10px; justify-content: center; }
.page-nav-btn {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff; color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: background-color .12s ease, color .12s ease;
}
.page-nav-btn svg { width: 18px; height: 18px; }
.page-nav-btn:hover:not(:disabled) { background: var(--accent-1); color: #fff; border-color: var(--accent-1); }
.page-nav-btn:disabled { opacity: 0.35; cursor: default; }

.editor-stage {
  position: relative; max-width: 100%; background: #fff; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(15,23,42,0.12); overflow: hidden;
  touch-action: none; user-select: none; line-height: 0;
}
.page-image {
  display: block; max-width: min(78vw, 480px); max-height: 68vh; width: auto; height: auto;
  user-select: none; -webkit-user-drag: none;
}
.stage-loading { position: absolute; inset: 0; background: rgba(255,255,255,0.7); display: flex; align-items: center; justify-content: center; }

/* Everything below the cut line -- the tax invoice -- dimmed to show
   it will be discarded. Height set in JS as a percentage of the stage. */
.crop-mask-below {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  pointer-events: none;
}

/* The single, full-width, draggable horizontal cut line -- simpler
   than a 4-handle crop box, and a better match for this tool's actual
   job: a Meesho label always spans the full page width, only the
   height varies. */
.cut-line {
  position: absolute;
  left: 0; right: 0;
  height: 0;
  border-top: 2px dashed var(--accent-1);
  cursor: ns-resize;
}
.cut-line-handle {
  position: absolute;
  left: 50%;
  top: -15px;
  transform: translateX(-50%);
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(40,116,240,0.4);
}
.cut-line-handle svg { width: 16px; height: 16px; }
.cut-line-badge {
  position: absolute;
  right: 6px;
  top: -26px;
  background: var(--accent-1);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 20px;
}

.page-counter { text-align: center; font-size: 12.5px; color: var(--ink-soft); font-weight: 700; margin-top: 10px; }

.detect-note {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--bg-soft); border-radius: 10px; padding: 9px 14px;
  margin-top: 12px; font-size: 12px; color: #1E40AF; font-weight: 600;
}
.detect-note svg { width: 16px; height: 16px; flex: none; color: var(--accent-1); }

/* ---------------- Editor panel ---------------- */
.editor-panel { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: 0 2px 10px rgba(15,23,42,0.04); }
.panel-section { margin-bottom: 18px; }
.panel-section:last-child { margin-bottom: 0; }
.panel-label {
  display: block; font-size: 12px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--ink-soft); margin-bottom: 10px;
}

.mode-cards { display: flex; flex-direction: column; gap: 8px; }
.mode-card {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--border); background: #fff; border-radius: 12px;
  padding: 12px 14px; cursor: pointer; text-align: left;
  transition: border-color .12s ease, background-color .12s ease;
}
.mode-card:hover { border-color: var(--accent-2); }
.mode-card.active { border-color: var(--accent-1); background: var(--bg-soft); }
.mode-card svg { width: 26px; height: 26px; flex: none; color: var(--accent-1); }
.mode-card .mode-name { display: block; font-size: 13.5px; font-weight: 800; }
.mode-card .mode-desc { display: block; font-size: 11px; color: var(--ink-soft); }
.mode-card > svg + span { display: flex; flex-direction: column; gap: 2px; }

.crop-readout-card { background: var(--bg-soft); border-radius: 12px; padding: 14px; text-align: center; }
.crop-readout-label { font-size: 11px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.crop-readout-value { font-size: 18px; font-weight: 800; color: var(--accent-1); }

.btn-compress {
  margin-top: 4px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff; border: none; padding: 14px 20px; border-radius: 14px;
  font-weight: 700; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
}
.btn-compress svg { width: 20px; height: 20px; }
.btn-compress:hover { filter: brightness(1.08); }

/* ---------------- Processing ---------------- */
.processing-screen { text-align: center; padding: 30px 0; }
.progress-circle-wrap { position: relative; width: 170px; height: 170px; margin: 0 auto 20px; }
.progress-circle-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-circle-bg { fill: none; stroke: var(--bg-soft); stroke-width: 10; }
.progress-circle-fg { fill: none; stroke: var(--accent-1); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.3s ease; }
.progress-percent { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; }
.progress-bar-track { height: 6px; background: var(--bg-soft); border-radius: 6px; max-width: 340px; margin: 0 auto 16px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); width: 0%; transition: width 0.3s ease; }
.processing-message { font-weight: 700; margin-bottom: 4px; }
.processing-subtext { color: var(--ink-soft); font-size: 13px; }

/* ---------------- Result ---------------- */
.result-screen { text-align: center; padding: 10px 0 0; }
.result-badge { width: 64px; height: 64px; border-radius: 50%; background: #ECFDF5; color: var(--success); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.result-badge svg { width: 30px; height: 30px; }
.result-title { font-size: 20px; font-weight: 800; margin-bottom: 10px; }
.quality-pill { display: inline-flex; align-items: center; gap: 6px; background: #ECFDF5; color: var(--success); padding: 6px 14px; border-radius: 30px; font-size: 12.5px; font-weight: 700; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
@media (max-width: 600px) { .result-stats { grid-template-columns: repeat(2, 1fr); } }
.result-stat { background: var(--bg-soft); border-radius: 12px; padding: 14px 8px; }
.result-stat-label { font-size: 11px; color: var(--ink-soft); margin-bottom: 4px; }
.result-stat-value { font-size: 17px; font-weight: 800; }
.result-stat-value.accent { color: var(--accent-1); }

.download-section { max-width: 380px; margin: 0 auto; }
.download-label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; text-align: left; }
.download-filename-input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.btn-download {
  width: 100%; background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff; border: none; padding: 14px; border-radius: 14px;
  font-weight: 700; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px;
}
.btn-download svg { width: 20px; height: 20px; }
.btn-compress-another { width: 100%; background: none; border: none; color: var(--accent-1); font-weight: 700; font-size: 14px; cursor: pointer; padding: 8px; }

.app-footer { text-align: center; color: var(--ink-soft); font-size: 12px; margin-top: 18px; }

/* ---------------- Toasts ---------------- */
.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100000; display: flex; flex-direction: column; gap: 10px; width: min(420px, 92vw); }
.toast-error { background: #fff; border-left: 4px solid var(--danger); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.toast-icon { width: 22px; height: 22px; color: var(--danger); flex: none; }
.toast-title { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.toast-message { font-size: 13px; color: var(--ink-soft); }
.toast-close { background: none; border: none; cursor: pointer; color: #9CA3AF; margin-left: auto; }

.d-none { display: none !important; }
