/* ============================================================
   TEXT CASE CONVERTER — SCOPED CSS
   Prefix  : .cc-*
   File    : case-converter.html  tag
   DO NOT add to text-writing-tools.css
   ============================================================ */

/* ── CSS VARIABLES ───────────────────────────────────────── */
:root {
  --cc-bg             : #f8f9fc;
  --cc-surface        : #ffffff;
  --cc-surface-2      : #f1f3f8;
  --cc-surface-3      : #e8ebf4;
  --cc-border         : #e2e6ef;
  --cc-border-2       : #d0d5e8;
  --cc-text-primary   : #1a1d2e;
  --cc-text-secondary : #5a6282;
  --cc-text-muted     : #9399b2;
  --cc-accent         : #4f6ef7;
  --cc-accent-dark    : #3a56d4;
  --cc-accent-light   : #eef1fe;
  --cc-accent-2       : #7c3aed;
  --cc-success        : #10b981;
  --cc-success-light  : #d1fae5;
  --cc-warning        : #f59e0b;
  --cc-danger         : #ef4444;
  --cc-shadow-sm      : 0 1px 3px rgba(0,0,0,.07);
  --cc-shadow-md      : 0 4px 12px rgba(0,0,0,.08);
  --cc-shadow-lg      : 0 8px 24px rgba(0,0,0,.10);
  --cc-radius-sm      : 8px;
  --cc-radius-md      : 12px;
  --cc-radius-lg      : 16px;
  --cc-font           : 'Inter', system-ui, -apple-system, sans-serif;
  --cc-mono           : 'JetBrains Mono', 'Fira Code', monospace;
  --cc-transition     : 0.2s ease;
  --cc-stat-1         : #4f6ef7;
  --cc-stat-2         : #7c3aed;
  --cc-stat-3         : #10b981;
  --cc-stat-4         : #f59e0b;
}

/* ── DARK MODE ───────────────────────────────────────────── */
[data-theme="dark"] {
  --cc-bg             : #0f1117;
  --cc-surface        : #1a1d2e;
  --cc-surface-2      : #222538;
  --cc-surface-3      : #2a2e48;
  --cc-border         : #2e3150;
  --cc-border-2       : #373c62;
  --cc-text-primary   : #e8eaf6;
  --cc-text-secondary : #9399b2;
  --cc-text-muted     : #6b7280;
  --cc-accent         : #6b84f8;
  --cc-accent-dark    : #5470f0;
  --cc-accent-light   : #1e2244;
  --cc-accent-2       : #9d6bf8;
  --cc-success        : #34d399;
  --cc-success-light  : #064e3b;
  --cc-shadow-sm      : 0 1px 3px rgba(0,0,0,.3);
  --cc-shadow-md      : 0 4px 12px rgba(0,0,0,.4);
}

/* ── GLOBAL FIX ──────────────────────────────────────────── */
/* ── BASE SECTION ────────────────────────────────────────── */
.twt-tool-section[data-tool="text-case-converter"] {
  font-family  : var(--cc-font);
  background   : var(--cc-bg);
  color        : var(--cc-text-primary);
  width        : 100%;
  max-width    : 100%;
  overflow-x   : hidden;
  display      : flex;
  flex-direction: column;
  min-height   : 100vh;
}

/* ══════════════════════════════════════════════════════════
   STATS BAR
   ══════════════════════════════════════════════════════════ */
.cc-stats-bar {
  display              : grid;
  grid-template-columns: repeat(4, 1fr);
  width                : 100%;
  background           : var(--cc-surface);
  border-bottom        : 1px solid var(--cc-border);
  overflow             : hidden;
}

.cc-stat-card {
  display        : flex;
  flex-direction : column;
  align-items    : center;
  justify-content: center;
  padding        : 14px 10px;
  gap            : 4px;
  border-right   : 1px solid var(--cc-border);
  position       : relative;
  overflow       : hidden;
  min-width      : 0;
  transition     : background var(--cc-transition);
  cursor         : default;
}

.cc-stat-card:last-child { border-right: none; }

/* Bottom accent line */
.cc-stat-card::after {
  content   : '';
  position  : absolute;
  bottom    : 0; left: 0; right: 0;
  height    : 3px;
}

.cc-stat-card:nth-child(1)::after { background: var(--cc-stat-1); }
.cc-stat-card:nth-child(2)::after { background: var(--cc-stat-2); }
.cc-stat-card:nth-child(3)::after { background: var(--cc-stat-3); }
.cc-stat-card:nth-child(4)::after { background: var(--cc-stat-4); }

.cc-stat-card:hover { background: var(--cc-surface-2); }

.cc-stat-card__value {
  font-size    : clamp(1.2rem, 3vw, 1.8rem);
  font-weight  : 700;
  line-height  : 1;
  letter-spacing: -0.02em;
  white-space  : nowrap;
}

.cc-stat-card:nth-child(1) .cc-stat-card__value { color: var(--cc-stat-1); }
.cc-stat-card:nth-child(2) .cc-stat-card__value { color: var(--cc-stat-2); }
.cc-stat-card:nth-child(3) .cc-stat-card__value { color: var(--cc-stat-3); }
.cc-stat-card:nth-child(4) .cc-stat-card__value { color: var(--cc-stat-4); }

.cc-stat-card__label {
  font-size    : clamp(0.58rem, 1.2vw, 0.7rem);
  font-weight  : 600;
  color        : var(--cc-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space  : nowrap;
}

/* ══════════════════════════════════════════════════════════
   CASE SELECTOR TABS
   ══════════════════════════════════════════════════════════ */
.cc-case-tabs {
  display         : flex;
  align-items     : center;
  gap             : 6px;
  padding         : 12px 16px;
  background      : var(--cc-surface);
  border-bottom   : 1px solid var(--cc-border);
  overflow-x      : auto;
  overflow-y      : hidden;
  flex-wrap       : nowrap;
  scrollbar-width : none;
  -ms-overflow-style: none;
  width           : 100%;
}

.cc-case-tabs::-webkit-scrollbar { display: none; }

.cc-case-tab {
  display        : flex;
  flex-direction : column;
  align-items    : center;
  gap            : 3px;
  padding        : 8px 14px;
  border         : 1.5px solid var(--cc-border);
  border-radius  : var(--cc-radius-sm);
  background     : var(--cc-surface);
  color          : var(--cc-text-secondary);
  font-family    : var(--cc-font);
  cursor         : pointer;
  transition     : all var(--cc-transition);
  white-space    : nowrap;
  flex-shrink    : 0;
  min-width      : 70px;
  position       : relative;
  overflow       : hidden;
}

.cc-case-tab::before {
  content   : '';
  position  : absolute;
  bottom    : 0; left: 0; right: 0;
  height    : 2px;
  background: transparent;
  transition: background var(--cc-transition);
}

.cc-case-tab:hover {
  border-color: var(--cc-accent);
  background  : var(--cc-accent-light);
  color       : var(--cc-accent);
}

.cc-case-tab--active {
  border-color: var(--cc-accent);
  background  : var(--cc-accent-light);
  color       : var(--cc-accent);
  box-shadow  : var(--cc-shadow-sm);
}

.cc-case-tab--active::before {
  background: var(--cc-accent);
}

.cc-case-tab__icon {
  font-size  : 0.88rem;
  font-weight: 800;
  font-family: var(--cc-mono);
  line-height: 1;
}

.cc-case-tab__label {
  font-size  : 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ══════════════════════════════════════════════════════════
   EDITOR WRAP — INPUT + OUTPUT
   ══════════════════════════════════════════════════════════ */
.cc-editor-wrap {
  display              : grid;
  grid-template-columns: 1fr auto 1fr;
  flex                 : 1;
  width                : 100%;
  overflow             : hidden;
  min-height           : 0;
}

/* ── Panel Shared ────────────────────────────────────────── */
.cc-panel {
  display       : flex;
  flex-direction: column;
  background    : var(--cc-surface);
  min-width     : 0;
  overflow      : hidden;
}

.cc-panel--input  { border-right: 1px solid var(--cc-border); }
.cc-panel--output { border-left:  1px solid var(--cc-border); }

/* Panel Header */
.cc-panel__header {
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  padding        : 10px 14px;
  border-bottom  : 1px solid var(--cc-border);
  background     : var(--cc-surface-2);
  gap            : 10px;
  flex-shrink    : 0;
  min-width      : 0;
}

.cc-panel__title {
  display      : flex;
  align-items  : center;
  gap          : 7px;
  font-size    : 0.8rem;
  font-weight  : 600;
  color        : var(--cc-text-secondary);
  min-width    : 0;
  overflow     : hidden;
  flex-wrap    : wrap;
}

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

/* Panel Body */
.cc-panel__body {
  flex     : 1;
  position : relative;
  min-height: 0;
  overflow : hidden;
  display  : flex;
  flex-direction: column;
}

/* Panel Footer */
.cc-panel__footer {
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  padding        : 8px 14px;
  border-top     : 1px solid var(--cc-border);
  background     : var(--cc-surface-2);
  gap            : 10px;
  flex-shrink    : 0;
  flex-wrap      : wrap;
  min-width      : 0;
}

/* ── Textarea ─────────────────────────────────────────────── */
.cc-textarea {
  flex       : 1;
  width      : 100%;
  padding    : 16px;
  border     : none;
  outline    : none;
  resize     : none;
  background : var(--cc-surface);
  color      : var(--cc-text-primary);
  font-size  : clamp(0.85rem, 1.4vw, 1rem);
  font-family: var(--cc-font);
  line-height: 1.75;
  min-height : 280px;
  caret-color: var(--cc-accent);
  overflow-y : auto;
  overflow-x : hidden;
  word-wrap  : break-word;
  word-break : break-word;
  white-space: pre-wrap;
  max-width  : 100%;
}

.cc-textarea::placeholder {
  color    : var(--cc-text-muted);
  font-size: 0.88rem;
}

/* Output textarea */
.cc-textarea--output {
  color      : var(--cc-text-primary);
  background : var(--cc-surface);
  cursor     : text;
  font-family: var(--cc-mono);
  font-size  : clamp(0.82rem, 1.3vw, 0.95rem);
}

/* ── Empty State ─────────────────────────────────────────── */
.cc-empty-state {
  position      : absolute;
  inset         : 0;
  display       : flex;
  flex-direction: column;
  align-items   : center;
  justify-content: center;
  gap           : 10px;
  padding       : 24px;
  background    : var(--cc-surface);
  z-index       : 2;
  transition    : opacity var(--cc-transition);
  pointer-events: none;
}

.cc-empty-state[aria-hidden="true"] {
  opacity   : 1;
  visibility: visible;
}

.cc-empty-state.cc-hidden {
  opacity   : 0;
  visibility: hidden;
}

.cc-empty-state__icon {
  width    : 48px;
  height   : 48px;
  color    : var(--cc-text-muted);
  opacity  : 0.4;
}

.cc-empty-state__icon svg {
  width        : 100%;
  height       : 100%;
  stroke       : currentColor;
  stroke-width : 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill         : none;
}

.cc-empty-state__title {
  font-size  : 0.95rem;
  font-weight: 600;
  color      : var(--cc-text-muted);
}

.cc-empty-state__sub {
  font-size : 0.78rem;
  color     : var(--cc-text-muted);
  text-align: center;
  max-width : 220px;
  line-height: 1.5;
}

/* ── Swap Button (center divider) ────────────────────────── */
.cc-swap-wrap {
  display        : flex;
  align-items    : center;
  justify-content: center;
  width          : 48px;
  background     : var(--cc-surface-2);
  border-left    : 1px solid var(--cc-border);
  border-right   : 1px solid var(--cc-border);
  flex-shrink    : 0;
}

.cc-swap-btn {
  display        : flex;
  align-items    : center;
  justify-content: center;
  width          : 36px;
  height         : 36px;
  border         : 1.5px solid var(--cc-border);
  border-radius  : 50%;
  background     : var(--cc-surface);
  color          : var(--cc-text-secondary);
  cursor         : pointer;
  transition     : all var(--cc-transition);
  flex-shrink    : 0;
}

.cc-swap-btn:hover {
  background  : var(--cc-accent-light);
  border-color: var(--cc-accent);
  color       : var(--cc-accent);
  transform   : rotate(180deg);
}

/* ── Active Case Badge ───────────────────────────────────── */
.cc-active-badge {
  display      : inline-flex;
  align-items  : center;
  padding      : 2px 8px;
  background   : var(--cc-accent-light);
  color        : var(--cc-accent);
  border       : 1px solid var(--cc-accent);
  border-radius: 99px;
  font-size    : 0.65rem;
  font-weight  : 700;
  letter-spacing: 0.04em;
  white-space  : nowrap;
}

/* ── Icon Buttons ────────────────────────────────────────── */
.cc-icon-btn {
  display        : flex;
  align-items    : center;
  justify-content: center;
  width          : 30px;
  height         : 30px;
  border         : 1px solid var(--cc-border);
  border-radius  : var(--cc-radius-sm);
  background     : var(--cc-surface);
  color          : var(--cc-text-secondary);
  cursor         : pointer;
  transition     : all var(--cc-transition);
  flex-shrink    : 0;
}

.cc-icon-btn:hover {
  background  : var(--cc-accent-light);
  border-color: var(--cc-accent);
  color       : var(--cc-accent);
}

/* ── Buttons ─────────────────────────────────────────────── */
.cc-btn {
  display      : inline-flex;
  align-items  : center;
  gap          : 5px;
  padding      : 7px 14px;
  border-radius: var(--cc-radius-sm);
  font-size    : 0.78rem;
  font-weight  : 600;
  font-family  : var(--cc-font);
  cursor       : pointer;
  transition   : all var(--cc-transition);
  border       : 1px solid transparent;
  white-space  : nowrap;
  flex-shrink  : 0;
}

.cc-btn--sm { padding: 5px 12px; font-size: 0.74rem; }

.cc-btn--ghost {
  background  : transparent;
  border-color: var(--cc-border);
  color       : var(--cc-text-secondary);
}

.cc-btn--ghost:hover {
  background  : var(--cc-surface-2);
  border-color: var(--cc-border-2);
  color       : var(--cc-text-primary);
}

.cc-btn--primary {
  background  : var(--cc-accent);
  color       : #fff;
  border-color: var(--cc-accent);
  box-shadow  : 0 2px 8px rgba(79,110,247,.3);
}

.cc-btn--primary:hover {
  background  : var(--cc-accent-dark);
  border-color: var(--cc-accent-dark);
  transform   : translateY(-1px);
  box-shadow  : 0 4px 14px rgba(79,110,247,.4);
}

/* ── Live Badge ──────────────────────────────────────────── */
.cc-live-badge {
  font-size    : 0.74rem;
  font-weight  : 500;
  color        : var(--cc-text-muted);
  background   : var(--cc-surface);
  padding      : 3px 9px;
  border-radius: var(--cc-radius-sm);
  border       : 1px solid var(--cc-border);
  white-space  : nowrap;
  overflow     : hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════════
   QUICK REFERENCE SECTION
   ══════════════════════════════════════════════════════════ */
.cc-reference {
  padding      : 20px 16px;
  background   : var(--cc-surface);
  border-top   : 1px solid var(--cc-border);
  overflow     : hidden;
}

.cc-reference__title {
  display      : flex;
  align-items  : center;
  gap          : 7px;
  font-size    : 0.78rem;
  font-weight  : 700;
  color        : var(--cc-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.cc-reference__grid {
  display              : grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap                  : 8px;
  width                : 100%;
}

.cc-ref-card {
  display       : flex;
  flex-direction: column;
  gap           : 4px;
  padding       : 10px 12px;
  background    : var(--cc-surface-2);
  border        : 1px solid var(--cc-border);
  border-radius : var(--cc-radius-sm);
  transition    : all var(--cc-transition);
  min-width     : 0;
  overflow      : hidden;
  cursor        : default;
}

.cc-ref-card:hover {
  border-color: var(--cc-accent);
  background  : var(--cc-accent-light);
}

.cc-ref-card__name {
  font-size  : 0.7rem;
  font-weight: 600;
  color      : var(--cc-text-muted);
  white-space: nowrap;
  overflow   : hidden;
  text-overflow: ellipsis;
}

.cc-ref-card__example {
  font-size  : 0.8rem;
  font-weight: 700;
  color      : var(--cc-text-primary);
  font-family: var(--cc-mono);
  white-space: nowrap;
  overflow   : hidden;
  text-overflow: ellipsis;
}

/* ── Icons ───────────────────────────────────────────────── */
.cc-icon {
  width         : 14px;
  height        : 14px;
  stroke        : currentColor;
  stroke-width  : 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill          : none;
  flex-shrink   : 0;
}

.cc-icon--md { width: 16px; height: 16px; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 900px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {

  /* Editor: stack vertically */
  .cc-editor-wrap {
    grid-template-columns: 1fr;
    grid-template-rows   : auto auto auto;
  }

  .cc-panel--input  { border-right: none; border-bottom: 1px solid var(--cc-border); }
  .cc-panel--output { border-left:  none; border-top:    1px solid var(--cc-border); }

  /* Swap button becomes horizontal */
  .cc-swap-wrap {
    width      : 100%;
    height     : 44px;
    border-left: none;
    border-right: none;
    border-top : 1px solid var(--cc-border);
    border-bottom: 1px solid var(--cc-border);
  }

  .cc-swap-btn:hover { transform: rotate(90deg); }

  .cc-textarea { min-height: 200px; }

  /* Reference grid: 3 cols */
  .cc-reference__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 600px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* Stats: 2 cols */
  .cc-stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .cc-stat-card:nth-child(odd)  { border-right: 1px solid var(--cc-border); }
  .cc-stat-card:nth-child(even) { border-right: none; }
  .cc-stat-card:nth-child(n+3)  { border-top: 1px solid var(--cc-border); }

  .cc-stat-card__value { font-size: 1.2rem; }

  /* Tabs scroll on mobile */
  .cc-case-tabs {
    padding: 10px 12px;
    gap    : 5px;
  }

  .cc-case-tab {
    padding  : 7px 10px;
    min-width: 58px;
  }

  .cc-case-tab__icon { font-size: 0.78rem; }
  .cc-case-tab__label { font-size: 0.58rem; }

  /* Panel header */
  .cc-panel__header { padding: 8px 12px; }
  .cc-panel__footer { padding: 7px 12px; }

  .cc-textarea { min-height: 160px; font-size: 0.88rem; }

  /* Reference: 2 cols */
  .cc-reference__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Footer wrap */
  .cc-panel__footer {
    flex-direction: column;
    align-items   : stretch;
  }

  .cc-btn--primary { justify-content: center; }
}

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════ */
@keyframes cc-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0);   }
}

@keyframes cc-pop {
  0%   { transform: scale(1);    }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1);    }
}

.cc-stat-card__value.cc-pop {
  animation: cc-pop 0.25s ease;
}

.cc-panel--output .cc-panel__body {
  animation: cc-fade-in 0.2s ease;
}

/* Scrollbar */
.cc-case-tabs::-webkit-scrollbar { display: none; }
.cc-textarea::-webkit-scrollbar  { width: 3px; }
.cc-textarea::-webkit-scrollbar-track { background: transparent; }
.cc-textarea::-webkit-scrollbar-thumb {
  background   : var(--cc-border-2);
  border-radius: 99px;
}