/* ===== IMAGE INSIDE TEXT ===== */

.iit-root {
  --accent: #6557ff;
  --accent2: #aa3fff;
  --bg: #F5F7FF;
  --surface: #ffffff;
  --surface2: #EEF0FB;
  --border: #DDE4F5;
  --border2: #C4CEE8;
  --text: #1B1D2C;
  --muted: #8893AA;
  --hover: #F0F3FF;
  --act: rgba(101,87,255,0.09);
  --shadow-sm: 0 1px 3px rgba(27,29,44,0.07);
  --shadow-md: 0 4px 20px rgba(27,29,44,0.1);

  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: var(--surface);
  max-width: 1200px;
  margin: 0 auto 56px;
  border-radius: 18px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md), 0 1px 0 rgba(255,255,255,0.8) inset;
  position: relative;
}
.iit-root::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  z-index: 10;
}

/* ===== PRESET BAR ===== */
.iit-preset-wrap {
  position: relative;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.iit-preset-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 44px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.iit-preset-bar::-webkit-scrollbar { display: none; }
.iit-preset-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 2; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 50%; cursor: pointer; color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  transition: opacity 0.15s, background 0.13s;
}
.iit-preset-arrow:hover { background: var(--hover); }
.iit-preset-arrow-l { left: 6px; }
.iit-preset-arrow-r { right: 6px; }
.iit-preset-arrow.is-hidden { opacity: 0; pointer-events: none; }

.iit-preset-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px 8px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  min-width: 76px;
}
.iit-preset-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--act);
  transform: translateY(-1px);
}
.iit-preset-btn.iit-preset-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--act);
}
.iit-preset-thumb {
  width: 60px;
  height: 38px;
  border-radius: 7px;
  overflow: hidden;
}
.iit-preset-thumb canvas { width: 100%; height: 100%; display: block; }
.iit-preset-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ===== WORKSPACE ===== */
.iit-workspace {
  display: grid;
  grid-template-columns: 1fr 56px 290px;
  grid-template-rows: 1fr;
  min-height: 580px;
}

/* ===== CANVAS AREA — light checkered background ===== */
.iit-canvas-area {
  display: flex;
  flex-direction: column;
  background: repeating-conic-gradient(#dde1ec 0% 25%, #eef0f8 0% 50%) 0 0 / 20px 20px;
  border-right: 1px solid var(--border);
  /* Prevents the canvas column from stretching to match the tall control panel */
  align-self: start;
  position: sticky;
  top: 80px;
}

/* Download bar — white/light */
.iit-dl-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
.iit-canvas-info {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.iit-dl-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}
.iit-fmt-pills {
  display: flex;
  gap: 4px;
}
.iit-fmt-pill {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.iit-fmt-pill:hover { border-color: var(--border2); color: var(--text); }
.iit-fmt-pill.iit-fmt-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.iit-dl-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}
.iit-dl-btn:hover { background: var(--accent2); transform: translateY(-1px); }
.iit-dl-btn:active { transform: scale(0.97); }

.iit-canvas-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
#iitCanvas {
  display: block;
  max-width: 100%;
  max-height: 460px;
  object-fit: contain;
  border-radius: 6px;
  cursor: grab;
  box-shadow: 0 8px 40px rgba(27,29,44,0.22), 0 2px 8px rgba(27,29,44,0.1);
}
#iitCanvas:active { cursor: grabbing; }
.iit-canvas-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
  white-space: nowrap;
  background: rgba(255,255,255,0.75);
  padding: 3px 10px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* ===== SIDEBAR NAV ===== */
.iit-sidenav {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 4px;
  background: var(--bg);
  border-right: 1px solid var(--border);
}
.iit-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 48px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.13s, color 0.13s;
}
.iit-nav-btn span { font-size: 10px; font-weight: 600; }
.iit-nav-btn:hover { background: var(--hover); color: var(--text); }
.iit-nav-btn.iit-nav-active {
  background: var(--act);
  color: var(--accent);
}

/* ===== PANEL WRAP ===== */
.iit-panel-wrap {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
  background: var(--surface);
}
.iit-panel-wrap::-webkit-scrollbar { width: 4px; }
.iit-panel-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
.iit-panel { padding: 18px 16px 28px; }

/* Section title — replaces old panel-title for inline sections */
.iit-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Divider between sections inside a panel */
.iit-panel-divider {
  border: none;
  border-top: 1.5px solid var(--border);
  margin: 20px -16px 20px;
}

/* ===== FIELDS ===== */
.iit-field { margin-bottom: 14px; }
.iit-field:last-child { margin-bottom: 0; }
.iit-field-row { display: flex; gap: 10px; margin-bottom: 14px; }
.iit-field-half { flex: 1; margin-bottom: 0; }
.iit-two-col-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.iit-two-col-sliders .iit-field { margin-bottom: 0; }

.iit-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  gap: 4px;
}
.iit-val {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}
.iit-select-wrap { position: relative; }
.iit-select-wrap::after {
  content: '';
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-top-color: var(--muted);
  pointer-events: none;
}
.iit-select, .iit-input-num, .iit-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  appearance: none;
  outline: none;
  transition: border-color 0.15s;
}
.iit-select { padding-right: 28px; cursor: pointer; }
.iit-select:focus, .iit-input-num:focus, .iit-textarea:focus { border-color: var(--accent); }
.iit-textarea { resize: vertical; min-height: 56px; }
.iit-range {
  width: 100%;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}
.iit-align-btns { display: flex; gap: 6px; }
.iit-align-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.13s;
}
.iit-align-btn:hover { border-color: var(--border2); color: var(--text); }
.iit-align-btn.iit-align-active {
  border-color: var(--accent);
  background: var(--act);
  color: var(--accent);
}

/* ===== MODE TABS ===== */
.iit-mode-tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 14px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 3px;
}
.iit-mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 6px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.iit-mode-tab:hover { color: var(--text); }
.iit-mode-tab.iit-mode-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ===== SAMPLE IMAGES ===== */
.iit-samples-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.iit-fill-sample {
  flex: 1;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.iit-fill-sample:hover {
  border-color: var(--accent);
  transform: scale(1.04);
  box-shadow: 0 2px 8px rgba(101,87,255,0.2);
}
.iit-fill-sample.iit-sample-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--act);
}

/* ===== PEXELS SEARCH ===== */
.iit-pexels-wrap {
  margin-bottom: 10px;
}
.iit-pexels-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.iit-pexels-input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
.iit-pexels-input:focus { border-color: var(--accent); }
.iit-pexels-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.iit-pexels-btn:hover { background: var(--accent2); }
.iit-pexels-status {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  min-height: 16px;
}
.iit-pexels-status.is-error { color: #e53e3e; }
.iit-pexels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.iit-pexels-grid::-webkit-scrollbar { width: 3px; }
.iit-pexels-grid::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
.iit-pexels-grid button {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface2);
  aspect-ratio: 3/2;
  transition: border-color 0.13s, transform 0.12s;
}
.iit-pexels-grid button:hover { border-color: var(--accent); transform: scale(1.03); }
.iit-pexels-grid button.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--act); }
.iit-pexels-grid button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.iit-pexels-credit {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 8px;
}
.iit-pexels-credit a { color: var(--accent); text-decoration: none; }
.iit-pexels-credit a:hover { text-decoration: underline; }

/* ===== UPLOAD AREA ===== */
.iit-upload-area {
  border: 2px dashed var(--border2);
  border-radius: 10px;
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  margin-bottom: 10px;
}
.iit-upload-area:hover {
  border-color: var(--accent);
  background: var(--hover);
  color: var(--accent);
}
.iit-upload-area span { font-size: 13px; font-weight: 600; }
.iit-upload-area small { font-size: 11px; }
.iit-upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* Fill preview (active image) */
.iit-fill-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.iit-fill-preview img {
  width: 50px;
  height: 36px;
  object-fit: cover;
  border-radius: 5px;
}
.iit-fill-preview-info {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.iit-remove-btn {
  padding: 4px 10px;
  border: 1.5px solid var(--border2);
  border-radius: 6px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  color: #e53e3e;
  cursor: pointer;
  transition: all 0.13s;
  flex-shrink: 0;
}
.iit-remove-btn:hover { background: #fff5f5; border-color: #e53e3e; }

/* ===== COLOR PICKERS ===== */
.iit-color-row { display: flex; align-items: center; gap: 8px; }
.iit-color-input {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 7px;
  padding: 2px;
  cursor: pointer;
  flex-shrink: 0;
  background: transparent;
}
.iit-hex-input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
.iit-hex-input:focus { border-color: var(--accent); }

/* ===== SWATCHES ===== */
.iit-swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.iit-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.iit-swatch:hover { transform: scale(1.2); }
.iit-swatch.active { border-color: var(--accent); }

/* ===== GRADIENT STOPS ===== */
.iit-grad-stops { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.iit-grad-stop { display: flex; align-items: center; gap: 8px; }
.iit-grad-stop input[type="color"] {
  width: 32px; height: 32px;
  border: none; border-radius: 6px; padding: 2px;
  cursor: pointer; flex-shrink: 0; background: transparent;
}
.iit-grad-stop input[type="range"] { flex: 1; height: 4px; accent-color: var(--accent); }
.iit-grad-stop-del {
  width: 22px; height: 22px;
  border: 1.5px solid var(--border);
  border-radius: 50%; background: var(--surface);
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
  transition: all 0.13s; flex-shrink: 0;
}
.iit-grad-stop-del:hover { background: #fff5f5; border-color: #e53e3e; color: #e53e3e; }
.iit-add-stop-btn {
  padding: 6px 12px;
  border: 1.5px dashed var(--border2);
  border-radius: 7px; background: transparent;
  font-size: 12px; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: all 0.13s; width: 100%;
}
.iit-add-stop-btn:hover { border-color: var(--accent); color: var(--accent); }
.iit-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  margin: 14px 0 8px; display: block;
}
.iit-grad-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.iit-grad-preset {
  width: 36px; height: 24px; border-radius: 5px;
  cursor: pointer; border: 1.5px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.iit-grad-preset:hover { transform: scale(1.1); border-color: var(--border2); }
.iit-grad-preset.active { border-color: var(--accent); }

/* ===== EFFECTS ===== */
.iit-effect-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}
.iit-effect-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg);
  cursor: default;
}
.iit-effect-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.iit-effect-body {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.iit-effect-body .iit-field { margin-bottom: 0; }
.iit-effect-hidden { display: none; }

/* ===== TOGGLE ===== */
.iit-toggle { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; flex-shrink: 0; }
.iit-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.iit-toggle-track {
  position: absolute; inset: 0; background: var(--border2); border-radius: 20px; transition: background 0.2s;
}
.iit-toggle-track::after {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.iit-toggle input:checked + .iit-toggle-track { background: var(--accent); }
.iit-toggle input:checked + .iit-toggle-track::after { transform: translateX(16px); }

/* ===== SIZE PRESETS ===== */
.iit-size-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.iit-size-btn {
  padding: 6px 10px;
  border: 1.5px solid var(--border); border-radius: 7px;
  background: var(--surface); font-size: 11px; font-weight: 600;
  color: var(--text); cursor: pointer; transition: all 0.13s;
}
.iit-size-btn:hover { border-color: var(--accent); color: var(--accent); }
.iit-size-btn.iit-size-active { border-color: var(--accent); background: var(--act); color: var(--accent); }
.iit-apply-size-btn {
  margin-top: 10px; width: 100%; padding: 9px 12px;
  border: none; border-radius: 8px; background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; transition: background 0.15s;
}
.iit-apply-size-btn:hover { background: var(--accent2); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .iit-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .iit-canvas-area { order: 1; border-right: none; border-bottom: 1px solid var(--border); }
  #iitCanvas { max-height: 300px; }
  .iit-sidenav {
    order: 2;
    flex-direction: row;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 2px;
    scrollbar-width: none;
  }
  .iit-sidenav::-webkit-scrollbar { display: none; }
  .iit-nav-btn { width: auto; padding: 8px 16px; flex-direction: row; gap: 5px; white-space: nowrap; }
  .iit-nav-btn span { font-size: 12px; }
  .iit-panel-wrap { order: 3; max-height: 420px; }
  .iit-two-col-sliders { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .iit-preset-bar { padding: 12px 36px; }
  .iit-workspace { min-height: unset; }
  .iit-dl-bar { padding: 8px 12px; }
  .iit-fmt-pill { padding: 3px 8px; font-size: 10px; }
  .iit-dl-btn { padding: 6px 12px; font-size: 12px; }
  .iit-canvas-hint { display: none; }
  .iit-panel-wrap { max-height: 460px; }
}
