/* ============================================================
   TextCraft — styles.css
   Design System: Inter, #0061e0 primary, #fff background
   ============================================================ */

/* ——— Reset & Base ——— */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:        #0061e0;
  --primary-dark:   #0049b0;
  --primary-light:  #e8f0fe;
  --bg:             #ffffff;
  --surface:        #f7f8fc;
  --surface-alt:    #eef1f8;
  --border:         #dde2ef;
  --text:           #1a1e2e;
  --text-muted:     #6b7494;
  --text-light:     #9aa3c4;
  --success:        #10b981;
  --danger:         #ef4444;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-xs:      5px;
  --shadow-sm:      0 1px 4px rgba(0,61,140,.07);
  --shadow:         0 4px 16px rgba(0,61,140,.10);
  --shadow-lg:      0 8px 32px rgba(0,61,140,.13);
  --toolbar-h:      60px;
  --header-h:       56px;
  --transition:     .18s cubic-bezier(.4,0,.2,1);
  --font:           'Inter', system-ui, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ——— Header ——— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
}

.brand-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.4px;
}

.privacy-badge {
  font-size: .78rem;
  color: var(--text-muted);
  background: var(--primary-light);
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 500;
}

/* ——— Toolbar ——— */
.toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.toolbar-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 20px;
  min-width: 0;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.group-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
  padding: 0 6px 0 2px;
  white-space: nowrap;
  user-select: none;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  padding: 5px 10px;
  transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1;
  user-select: none;
}

.btn:active { transform: scale(.95); }

.btn-tool {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-tool:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,97,224,.25);
}

.btn-action {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-action:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-copy {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-copy:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 2px 10px rgba(0,97,224,.3);
}

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

.btn-clear {
  background: #fff0f0;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-clear:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

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

/* ——— Main Layout ——— */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 300px;
  grid-template-rows: auto;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 20px 0;
  align-items: start;
}

/* ——— Panels ——— */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 520px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
}

.panel-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.char-counter {
  font-size: .74rem;
  color: var(--text-light);
  background: var(--surface-alt);
  padding: 3px 9px;
  border-radius: 30px;
  font-weight: 600;
}

.copy-status {
  font-size: .78rem;
  font-weight: 600;
  color: var(--success);
  min-width: 60px;
  text-align: right;
  height: 20px;
  line-height: 20px;
  transition: opacity var(--transition);
}

.output-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-download-panel {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-download-panel:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ——— Textarea ——— */
.text-area {
  flex: 1;
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  padding: 16px;
  font-family: var(--font);
  font-size: .9rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  min-height: 460px;
  caret-color: var(--primary);
}

.text-area::placeholder { color: var(--text-light); }

.panel-output .text-area {
  background: var(--surface);
  color: #1e2a4a;
}

/* ——— Sidebar ——— */
.sidebar {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 20px;
}

/* ——— Stats Card ——— */
.stats-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stats-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  padding: 13px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.stats-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.stats-list {
  list-style: none;
  padding: 6px 0;
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  transition: background var(--transition);
}

.stat-item:hover { background: var(--surface); }

.stat-item--divider {
  border-top: 1px dashed var(--border);
  margin-top: 4px;
  padding-top: 13px;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-label svg {
  width: 13px;
  height: 13px;
  color: var(--text-light);
}

.stat-value {
  display: inline-block;
  font-size: .88rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  transition: color var(--transition);
  transform-origin: center;
}

.stat-value.bump {
  animation: statBump .28s cubic-bezier(.4,0,.2,1);
}

@keyframes statBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.22); color: var(--primary-dark); }
  100% { transform: scale(1); }
}

/* ——— Ad Placeholders ——— */
.ad-placeholder {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
}

.ad-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-light);
  font-weight: 600;
}

.ad-inner {
  font-size: .75rem;
  color: var(--text-light);
  background: var(--surface-alt);
  padding: 6px 14px;
  border-radius: 30px;
}

/* Sidebar Ad */
.ad-sidebar {
  min-height: 250px;
  width: 100%;
}

/* Bottom Ad */
.ad-bottom {
  width: 100%;
  height: 90px;
  flex-direction: row;
  margin-top: 24px;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

/* ——— Footer ——— */
.site-footer {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: .78rem;
  line-height: 1.8;
}

.footer-privacy {
  color: var(--primary);
  font-weight: 600;
}

.shortcuts-hint {
  margin-top: 6px;
  color: var(--text-light);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-size: .72rem;
  font-family: var(--font);
  color: var(--text-muted);
}

/* ——— Scrollbar Styling ——— */
.text-area::-webkit-scrollbar { width: 6px; }
.text-area::-webkit-scrollbar-track { background: transparent; }
.text-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.text-area::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ——— Responsive: Tablet (< 1280px) ——— */
@media (max-width: 1280px) {
  .main-layout {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .sidebar {
    grid-column: 1 / -1;
    grid-row: 2;
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
  }

  .ad-sidebar { display: none; }
}

/* ——— Responsive: Mobile (< 768px) ——— */
@media (max-width: 768px) {
  :root {
    --header-h: 52px;
    --toolbar-h: 52px;
  }

  .privacy-badge { display: none; }

  .main-layout {
    grid-template-columns: 1fr;
    padding: 12px 12px 0;
    gap: 12px;
  }

  .panel { min-height: 280px; }
  .text-area { min-height: 230px; }

  .sidebar {
    grid-column: 1;
    grid-row: auto;
    display: block;
  }

  .stats-card { margin-bottom: 12px; }
  .ad-sidebar { display: none; }

  .toolbar-inner { padding: 0 10px; gap: 2px; }
  .btn { font-size: .72rem; padding: 5px 8px; }
  .group-label { display: none; }
  .toolbar-divider { margin: 0 3px; }

  .header-inner { padding: 0 12px; }
}

@media (max-width: 480px) {
  .brand-name { font-size: 1rem; }
  .main-layout { padding: 10px 10px 0; }
}
