/* ============================================================
   SCRIPT PUNCTUATOR — Premium Dark UI
   ============================================================ */

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

:root {
  --bg:          #0d0d1a;
  --bg2:         #12122a;
  --bg3:         #1a1a38;
  --surface:     #1e1e42;
  --surface2:    #252550;
  --accent:      #e94560;
  --accent2:     #ff6b8a;
  --blue:        #0f3460;
  --blue2:       #1a4a8a;
  --cyan:        #00d4ff;
  --purple:      #7c3aed;
  --fg:          #e8e8f0;
  --fg2:         #a0a0c0;
  --fg3:         #606080;
  --border:      rgba(255,255,255,0.07);
  --border2:     rgba(233,69,96,0.35);
  --glow:        rgba(233,69,96,0.15);
  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 20px 60px rgba(0,0,0,0.6);
  --font:        'Inter', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}

/* ---- Animated BG Orbs ---- */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
  animation: floatOrb 20s ease-in-out infinite;
}
.orb-1 { width: 600px; height: 600px; background: var(--accent); top: -200px; left: -150px; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: var(--purple); top: 40%; right: -150px; animation-delay: -7s; }
.orb-3 { width: 400px; height: 400px; background: var(--cyan); bottom: -100px; left: 35%; animation-delay: -14s; }

@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(30px, -40px) scale(1.05); }
  66%       { transform: translate(-20px, 30px) scale(0.95); }
}

/* ---- App Shell ---- */
.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 16px 20px 12px;
  gap: 10px;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-icon {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(233,69,96,0.7));
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(233,69,96,0.6)); }
  50%       { filter: drop-shadow(0 0 22px rgba(233,69,96,1)); }
}
.header-title {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2), #ff9eb5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.header-sub {
  font-size: 0.75rem;
  color: var(--fg3);
  margin-top: 2px;
  font-weight: 400;
}
.header-stats {
  display: flex;
  gap: 8px;
}
.stat-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg2);
  font-family: var(--mono);
  transition: border-color 0.3s, color 0.3s;
}
.stat-badge.active {
  border-color: var(--border2);
  color: var(--accent);
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  color: var(--fg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.tool-btn:hover {
  background: var(--surface2);
  color: var(--fg);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.tool-btn:active { transform: translateY(0); }
.tool-btn.accent {
  background: linear-gradient(135deg, #1a0a10, #2a0d1a);
  border-color: var(--border2);
  color: var(--accent2);
}
.tool-btn.accent:hover {
  background: linear-gradient(135deg, var(--accent), #c81e45);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 20px var(--glow);
}
.tool-btn.danger { color: #ff6060; }
.tool-btn.danger:hover {
  background: rgba(255,60,60,0.15);
  border-color: rgba(255,60,60,0.4);
  color: #ff8080;
}
.tool-btn.summary {
  background: linear-gradient(135deg, #0a1a2e, #112244);
  border-color: rgba(0,180,255,0.3);
  color: #66ccff;
}
.tool-btn.summary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0f3460, #1a4a8a);
  color: white;
  border-color: rgba(0,180,255,0.7);
  box-shadow: 0 4px 18px rgba(0,150,255,0.25);
}
.tool-btn.summary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---- Editor Area ---- */
.editor-area {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

/* ---- Panels ---- */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.panel:focus-within {
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 0 30px rgba(0,0,0,0.4);
}
.panel-input:focus-within {
  border-color: rgba(15,52,96,0.8);
  box-shadow: 0 0 0 1px rgba(15,52,96,0.5), 0 8px 40px rgba(0,0,0,0.5);
}
.panel-output {
  border-color: var(--border2);
  box-shadow: 0 0 30px rgba(233,69,96,0.06);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-icon { font-size: 1rem; }
.panel-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--fg2);
  text-transform: uppercase;
  flex: 1;
}
.panel-output .panel-label { color: var(--accent); }
.panel-wc {
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--fg3);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 10px;
}

.code-area {
  flex: 1;
  width: 100%;
  background: var(--bg2);
  color: var(--fg);
  border: none;
  outline: none;
  resize: none;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.7;
  padding: 16px;
  caret-color: var(--accent);
}
.code-area::placeholder {
  color: var(--fg3);
  font-family: var(--font);
  font-size: 0.83rem;
  line-height: 1.8;
}
.code-area::-webkit-scrollbar { width: 6px; }
.code-area::-webkit-scrollbar-track { background: transparent; }
.code-area::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
.output-area { color: #c8ffc8; caret-color: var(--cyan); }

/* ---- Center Controls ---- */
.center-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 120px;
  flex-shrink: 0;
}

.btn-punctuate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 108px;
  height: 108px;
  background: linear-gradient(135deg, var(--accent), #c81e45);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
  transition: all 0.25s;
  box-shadow: 0 0 30px rgba(233,69,96,0.4), 0 8px 24px rgba(233,69,96,0.3);
  position: relative;
  overflow: hidden;
}
.btn-punctuate::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(var(--accent), transparent, var(--accent));
  animation: spinGlow 3s linear infinite;
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-punctuate:hover::before { opacity: 1; }
.btn-punctuate:hover {
  transform: scale(1.06);
  box-shadow: 0 0 50px rgba(233,69,96,0.7), 0 12px 40px rgba(233,69,96,0.4);
}
.btn-punctuate:active { transform: scale(0.97); }
.btn-punctuate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  animation: none;
}
.btn-arrow { font-size: 1.4rem; }
.btn-label { line-height: 1.4; }

@keyframes spinGlow {
  to { transform: rotate(360deg); }
}

.btn-analyze {
  width: 96px;
  padding: 10px 8px;
  background: var(--blue);
  border: 1px solid rgba(15,52,96,0.8);
  border-radius: var(--radius-sm);
  color: #7bbeff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
  line-height: 1.6;
  transition: all 0.2s;
}
.btn-analyze:hover {
  background: var(--blue2);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15,52,96,0.6);
}

/* Processing animation */
.btn-punctuate.processing .btn-arrow {
  animation: spinArrow 1s linear infinite;
}
@keyframes spinArrow {
  to { transform: rotate(360deg); }
}

/* ---- Status Bar ---- */
.status-bar {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.progress-wrap { padding: 6px 12px 4px; }
.progress-track {
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--cyan));
  border-radius: 2px;
  transition: width 0.3s ease;
}
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 14px 8px;
}
.status-msg {
  font-size: 0.75rem;
  color: var(--fg3);
}
.status-emo {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-backdrop[hidden] { display: none; }

/* Wide variant for summary modal */
.modal-box--wide { width: 700px; }

/* Summary stat cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px 24px 6px;
}
.summary-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.summary-card-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--mono);
  background: linear-gradient(135deg, var(--cyan), #66aaff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}
.summary-card-label {
  font-size: 0.65rem;
  color: var(--fg3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 4px;
  font-weight: 600;
}

/* Summary sections */
.summary-section {
  padding: 12px 24px 6px;
  border-top: 1px solid var(--border);
}
.summary-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.4px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* Punctuation chips */
.punct-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 6px;
}
.punct-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 5px 14px 5px 10px;
}
.punct-chip-symbol {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 28px;
  text-align: center;
}
.punct-chip-info {
  display: flex;
  flex-direction: column;
}
.punct-chip-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fg);
  font-family: var(--mono);
}
.punct-chip-name {
  font-size: 0.62rem;
  color: var(--fg3);
  letter-spacing: 0.3px;
}

/* Sample changes */
.change-samples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 16px;
  max-height: 200px;
  overflow-y: auto;
}
.change-samples::-webkit-scrollbar { width: 4px; }
.change-samples::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 2px; }
.sample-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.73rem;
  font-family: var(--mono);
}
.sample-before {
  background: rgba(255,60,60,0.07);
  border: 1px solid rgba(255,60,60,0.2);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: #ff9999;
  line-height: 1.5;
}
.sample-after {
  background: rgba(50,200,100,0.07);
  border: 1px solid rgba(50,200,100,0.2);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: #88ffbb;
  line-height: 1.5;
}
.sample-label {
  font-size: 0.6rem;
  opacity: 0.6;
  display: block;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 600px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.modal-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  color: var(--fg2);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--accent); color: white; border-color: var(--accent); }
.modal-sub {
  padding: 10px 24px 0;
  font-size: 0.8rem;
  color: var(--fg3);
}

.emotion-bars {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.emo-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.emo-label {
  font-size: 0.78rem;
  font-weight: 600;
  width: 130px;
  flex-shrink: 0;
  color: var(--fg);
}
.emo-bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg3);
  border-radius: 6px;
  overflow: hidden;
}
.emo-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s cubic-bezier(0.34,1.56,0.64,1);
}
.emo-meta {
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--fg3);
  width: 120px;
  flex-shrink: 0;
}

.punctuation-guide {
  padding: 0 24px 24px;
}
.punctuation-guide h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}
.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.guide-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--fg2);
  line-height: 1.5;
}
.guide-item strong {
  color: var(--fg);
  display: block;
  margin-bottom: 2px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 10px 22px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg);
  box-shadow: var(--shadow);
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: rgba(50,205,100,0.5); color: #7dffb3; }
.toast.error   { border-color: rgba(255,70,70,0.5);  color: #ff8888; }

/* ============================================================
   RESPONSIVE DESIGN (Wide, Tablet, Mobile)
   ============================================================ */

/* ---- Widescreen (1600px+) ---- */
@media (min-width: 1600px) {
  .app-shell { 
    max-width: 1600px; 
    margin: 0 auto; 
    width: 100%; 
    padding: 30px 40px; 
  }
  .code-area { font-size: 0.95rem; }
  .header-title { font-size: 2rem; }
  .btn-punctuate { width: 130px; height: 130px; font-size: 0.75rem; }
}

/* ---- Tablet (max-width: 1024px) ---- */
@media (max-width: 1024px) {
  .editor-area {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 1fr) auto minmax(300px, 1fr);
  }
  .center-controls {
    flex-direction: row;
    width: 100%;
    justify-content: center;
    padding: 10px 0;
  }
  .btn-punctuate {
    width: auto;
    height: auto;
    border-radius: 30px;
    padding: 12px 34px;
    flex-direction: row;
    font-size: 0.8rem;
  }
  .btn-punctuate::before { border-radius: 34px; }
  .btn-analyze {
    width: auto;
    height: auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
  }
  .btn-analyze br { display: none; }
  html, body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
}

/* ---- Mobile & Small Screens (max-width: 650px) ---- */
@media (max-width: 650px) {
  .app-shell { padding: 12px; gap: 10px; }
  
  /* Header */
  .app-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-stats { width: 100%; justify-content: flex-start; }
  .header-title { font-size: 1.4rem; }
  
  /* Toolbar */
  .toolbar { justify-content: center; padding: 8px; }
  .tool-btn { 
    font-size: 0.72rem; 
    padding: 6px 8px; 
    flex: 1 1 calc(33% - 8px); 
    justify-content: center; 
    text-align: center; 
  }
  .toolbar-sep { display: none; }
  
  /* Center Controls */
  .center-controls { flex-direction: column; width: 100%; gap: 10px; }
  .btn-punctuate { width: 100%; justify-content: center; }
  .btn-analyze { width: 100%; justify-content: center; }
  .btn-analyze br { display: inline; }
  
  /* Editor Panels */
  .editor-area { grid-template-rows: minmax(220px, 1fr) auto minmax(220px, 1fr); }
  
  /* Modals */
  .modal-box { width: 95vw; max-width: 100%; }
  .modal-box--wide { width: 95vw; }
  .modal-header { padding: 16px 16px 12px; }
  .modal-title { font-size: 1.1rem; }
  
  /* Summary grid */
  .summary-cards { grid-template-columns: 1fr 1fr; padding: 14px 16px 6px; }
  .summary-section { padding: 12px 16px 6px; }
  .change-samples { max-height: 220px; }
  .sample-pair { 
    grid-template-columns: 1fr; 
    gap: 4px; 
    padding-bottom: 12px; 
    border-bottom: 1px dashed var(--border); 
    margin-bottom: 6px; 
  }
  
  /* Analyze grid */
  .guide-grid { grid-template-columns: 1fr; }
  .emotion-bars { padding: 16px; }
  
  /* Emotion rows */
  .emo-row { flex-wrap: wrap; gap: 6px; }
  .emo-label { width: 100px; font-size: 0.72rem; }
  .emo-meta { width: 100%; text-align: left; padding-left: 0; margin-top: 2px; order: 3; }
  .emo-bar-track { flex: 1; min-width: 120px; order: 2; height: 12px; margin-top: 3px; }
  
  /* Status */
  .status-row { flex-direction: column; align-items: flex-start; gap: 6px; padding: 8px 12px 10px; }
}
