/* =========================================================
   Corretor Ortográfico Pro — Frontend Styles v1.3
   All rules scoped under .cop-wrap to avoid clashing with
   the host WordPress theme.
   ========================================================= */

.cop-wrap, .cop-wrap *, .cop-wrap *::before, .cop-wrap *::after {
  box-sizing: border-box;
}

/* Defensive: the host theme may have rules that override the [hidden]
   attribute on elements. Force it to actually hide things inside our widget. */
.cop-wrap [hidden] { display: none !important; }

.cop-wrap {
  /* Light theme tokens (default) */
  --cop-bg:        #ffffff;
  --cop-bg-soft:   #f7f8fa;
  --cop-bg-muted:  #eef0f4;
  --cop-border:    #e3e6ec;
  --cop-border-strong: #cdd2db;
  --cop-text:      #1a1d23;
  --cop-text-soft: #545a66;
  --cop-text-muted:#8a909c;
  --cop-primary:   #4f46e5;
  --cop-primary-hover: #4338ca;
  --cop-primary-soft:  #eef2ff;
  --cop-success:   #10b981;
  --cop-danger:    #ef4444;
  --cop-warning:   #f59e0b;
  --cop-info:      #3b82f6;

  /* Category colors */
  --cop-c-spelling: #ef4444;
  --cop-c-grammar:  #3b82f6;
  --cop-c-style:    #8b5cf6;
  --cop-c-punct:    #f59e0b;

  --cop-shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --cop-shadow:    0 4px 14px rgba(15, 23, 42, .07);
  --cop-shadow-lg: 0 12px 32px rgba(15, 23, 42, .10);
  --cop-radius:    12px;
  --cop-radius-sm: 8px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--cop-text);
  background: var(--cop-bg);
  border: 1px solid var(--cop-border);
  border-radius: var(--cop-radius);
  overflow: hidden;
  box-shadow: var(--cop-shadow);
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.5;
}

/* Dark theme overrides */
.cop-wrap[data-theme="dark"] {
  --cop-bg:        #15181d;
  --cop-bg-soft:   #1c1f25;
  --cop-bg-muted:  #252932;
  --cop-border:    #2a2e37;
  --cop-border-strong: #3a3f4a;
  --cop-text:      #e6e8ec;
  --cop-text-soft: #a8adb8;
  --cop-text-muted:#6e737e;
  --cop-primary:   #818cf8;
  --cop-primary-hover: #a5b4fc;
  --cop-primary-soft:  #1e1f3a;
  --cop-shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --cop-shadow:    0 4px 14px rgba(0, 0, 0, .35);
  --cop-shadow-lg: 0 12px 32px rgba(0, 0, 0, .50);
}

/* Auto theme via system preference */
@media (prefers-color-scheme: dark) {
  .cop-wrap[data-theme="auto"] {
    --cop-bg:        #15181d;
    --cop-bg-soft:   #1c1f25;
    --cop-bg-muted:  #252932;
    --cop-border:    #2a2e37;
    --cop-border-strong: #3a3f4a;
    --cop-text:      #e6e8ec;
    --cop-text-soft: #a8adb8;
    --cop-text-muted:#6e737e;
    --cop-primary:   #818cf8;
    --cop-primary-hover: #a5b4fc;
    --cop-primary-soft:  #1e1f3a;
    --cop-shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --cop-shadow:    0 4px 14px rgba(0, 0, 0, .35);
    --cop-shadow-lg: 0 12px 32px rgba(0, 0, 0, .50);
  }
}

/* ============== Toolbar ============== */
.cop-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--cop-bg-soft);
  border-bottom: 1px solid var(--cop-border);
}
.cop-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.cop-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  box-shadow: 0 4px 10px rgba(99,102,241,.30);
}
.cop-title-block { min-width: 0; }
.cop-title {
  font-size: 17px; font-weight: 700;
  margin: 0; color: var(--cop-text);
  line-height: 1.2;
}
.cop-subtitle {
  font-size: 12px; color: var(--cop-text-muted);
  margin: 2px 0 0 0; line-height: 1.2;
}
.cop-toolbar-right {
  display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.cop-select-wrap { position: relative; }
.cop-label-sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}
.cop-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--cop-bg);
  color: var(--cop-text);
  border: 1px solid var(--cop-border);
  border-radius: var(--cop-radius-sm);
  padding: 8px 30px 8px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23545a66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  line-height: 1.4;
}
.cop-select:hover { border-color: var(--cop-border-strong); }
.cop-select:focus {
  outline: none;
  border-color: var(--cop-primary);
  box-shadow: 0 0 0 3px var(--cop-primary-soft);
}

/* Theme toggle */
.cop-theme-toggle .cop-icon-moon { display: none; }
.cop-wrap[data-theme="dark"] .cop-theme-toggle .cop-icon-sun { display: none; }
.cop-wrap[data-theme="dark"] .cop-theme-toggle .cop-icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  .cop-wrap[data-theme="auto"] .cop-theme-toggle .cop-icon-sun { display: none; }
  .cop-wrap[data-theme="auto"] .cop-theme-toggle .cop-icon-moon { display: block; }
}

/* ============== Buttons ============== */
.cop-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--cop-text-soft);
  width: 34px; height: 34px;
  border-radius: var(--cop-radius-sm);
  display: inline-flex;
  align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  flex: 0 0 auto;
  padding: 0;
}
.cop-icon-btn:hover {
  background: var(--cop-bg-muted);
  color: var(--cop-text);
}
.cop-icon-btn:focus-visible {
  outline: none;
  border-color: var(--cop-primary);
  box-shadow: 0 0 0 3px var(--cop-primary-soft);
}
.cop-icon-btn-danger:hover {
  background: rgba(239, 68, 68, .10);
  color: var(--cop-danger);
}

.cop-divider {
  width: 1px; height: 20px;
  background: var(--cop-border);
  margin: 0 4px;
}

.cop-btn {
  display: inline-flex; align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--cop-radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
  line-height: 1.2;
}
.cop-btn:active { transform: translateY(1px); }
.cop-btn-primary {
  background: var(--cop-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .25);
}
.cop-btn-primary:hover { background: var(--cop-primary-hover); }
.cop-btn-secondary {
  background: var(--cop-bg);
  color: var(--cop-text);
  border-color: var(--cop-border-strong);
}
.cop-btn-secondary:hover { background: var(--cop-bg-muted); }
.cop-btn:disabled {
  opacity: .55; cursor: not-allowed; transform: none !important;
}

/* ============== Main layout ============== */
.cop-main {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 520px;
}
@media (max-width: 900px) {
  .cop-main { grid-template-columns: 1fr; }
}

/* ============== Editor pane ============== */
.cop-editor-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--cop-border);
  background: var(--cop-bg);
  min-width: 0;
}
@media (max-width: 900px) {
  .cop-editor-pane { border-right: 0; border-bottom: 1px solid var(--cop-border); }
}

.cop-editor-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--cop-border);
  background: var(--cop-bg-soft);
}
.cop-editor-actions {
  display: flex; align-items: center;
  gap: 4px; flex-wrap: wrap;
}

/* === Textarea + highlight overlay === */
.cop-editor-body {
  position: relative;
  flex: 1;
  min-height: 320px;
  display: flex;
  background: var(--cop-bg);
}

/* Shared text-rendering rules for textarea & overlay so caret aligns with marks */
.cop-textarea,
.cop-highlights {
  margin: 0;
  padding: 20px;
  font-size: 16px;
  line-height: 1.7;
  font-family: inherit;
  letter-spacing: normal;
  word-spacing: normal;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  tab-size: 4;
  -moz-tab-size: 4;
  border: 0;
  box-sizing: border-box;
}

.cop-textarea {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 320px;
  resize: vertical;
  background: transparent;
  color: var(--cop-text);
  outline: none;
  caret-color: var(--cop-text);
  display: block;
}
.cop-textarea::placeholder {
  color: var(--cop-text-muted);
  opacity: 1;
}

.cop-highlights-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}
.cop-highlights {
  width: 100%;
  height: 100%;
  color: transparent;            /* hide the duplicated text */
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: none;
}
/* Allow scrolling sync without the user seeing the scrollbar twice */
.cop-highlights::-webkit-scrollbar { display: none; }

.cop-highlights mark {
  background: transparent;
  color: transparent;
  border-bottom: 2px solid var(--cop-primary);
  padding: 0;
  border-radius: 0;
  pointer-events: auto;
  cursor: pointer;
}
.cop-highlights mark.cop-mark-spelling    { border-bottom-color: var(--cop-c-spelling); background: rgba(239,68,68,.10); }
.cop-highlights mark.cop-mark-grammar     { border-bottom-color: var(--cop-c-grammar);  background: rgba(59,130,246,.10); }
.cop-highlights mark.cop-mark-style       { border-bottom-color: var(--cop-c-style);    background: rgba(139,92,246,.10); }
.cop-highlights mark.cop-mark-punctuation { border-bottom-color: var(--cop-c-punct);    background: rgba(245,158,11,.10); }
.cop-highlights mark.cop-mark-active {
  outline: 2px solid var(--cop-primary);
  outline-offset: 1px;
}

.cop-editor-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--cop-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--cop-bg-soft);
}
.cop-stats {
  display: flex; align-items: center;
  gap: 18px; flex-wrap: wrap;
  font-size: 12px;
  color: var(--cop-text-muted);
}
.cop-stat strong {
  color: var(--cop-text);
  font-weight: 600;
}

/* ============== Sidebar ============== */
.cop-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--cop-bg-soft);
  min-width: 0;
}
.cop-sidebar-header {
  border-bottom: 1px solid var(--cop-border);
  background: var(--cop-bg);
}
.cop-tabs {
  display: flex;
  padding: 0 12px;
}
.cop-tab {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 14px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cop-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: color .15s, border-color .15s;
}
.cop-tab:hover { color: var(--cop-text); }
.cop-tab-active {
  color: var(--cop-primary);
  border-bottom-color: var(--cop-primary);
}

.cop-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  background: var(--cop-bg-muted);
  color: var(--cop-text-soft);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.cop-tab-active .cop-badge {
  background: var(--cop-primary);
  color: #fff;
}

.cop-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  max-height: 600px;
}
.cop-tab-panel { display: none; }
.cop-tab-panel-active { display: block; }

/* Summary cards */
.cop-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.cop-summary-card {
  background: var(--cop-bg);
  border: 1px solid var(--cop-border);
  border-radius: var(--cop-radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  overflow: hidden;
}
.cop-summary-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.cop-summary-spelling::before { background: var(--cop-c-spelling); }
.cop-summary-grammar::before  { background: var(--cop-c-grammar); }
.cop-summary-style::before    { background: var(--cop-c-style); }
.cop-summary-punct::before    { background: var(--cop-c-punct); }
.cop-summary-num {
  font-size: 22px; font-weight: 700;
  line-height: 1; color: var(--cop-text);
}
.cop-summary-label {
  font-size: 11px;
  color: var(--cop-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Filter row */
.cop-filter-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--cop-border);
}
.cop-filter {
  background: var(--cop-bg);
  border: 1px solid var(--cop-border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--cop-text-soft);
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background .15s, color .15s, border-color .15s;
}
.cop-filter:hover {
  border-color: var(--cop-border-strong);
  color: var(--cop-text);
}
.cop-filter-active {
  background: var(--cop-primary);
  border-color: var(--cop-primary);
  color: #fff;
}
.cop-filter-active .cop-dot { background: #fff !important; }
.cop-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.cop-dot-spelling { background: var(--cop-c-spelling); }
.cop-dot-grammar  { background: var(--cop-c-grammar); }
.cop-dot-style    { background: var(--cop-c-style); }
.cop-dot-punct    { background: var(--cop-c-punct); }

/* Suggestions list */
.cop-suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cop-empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--cop-text-muted);
}
.cop-empty-icon {
  margin: 0 auto 12px;
  width: 64px; height: 64px;
  background: var(--cop-bg-muted);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--cop-text-muted);
}
.cop-empty-title {
  font-weight: 600;
  color: var(--cop-text-soft);
  margin: 0 0 4px 0;
  font-size: 14px;
}
.cop-empty-text {
  font-size: 12px;
  margin: 0;
  line-height: 1.5;
}

.cop-suggestion {
  background: var(--cop-bg);
  border: 1px solid var(--cop-border);
  border-radius: var(--cop-radius-sm);
  padding: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.cop-suggestion:hover {
  border-color: var(--cop-border-strong);
  box-shadow: var(--cop-shadow-sm);
}
.cop-suggestion::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.cop-suggestion-spelling::before { background: var(--cop-c-spelling); }
.cop-suggestion-grammar::before  { background: var(--cop-c-grammar); }
.cop-suggestion-style::before    { background: var(--cop-c-style); }
.cop-suggestion-punctuation::before { background: var(--cop-c-punct); }

.cop-sug-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.cop-sug-cat-spelling { color: var(--cop-c-spelling); }
.cop-sug-cat-grammar  { color: var(--cop-c-grammar); }
.cop-sug-cat-style    { color: var(--cop-c-style); }
.cop-sug-cat-punctuation { color: var(--cop-c-punct); }

.cop-sug-message {
  font-size: 13px;
  color: var(--cop-text);
  margin: 0 0 8px 0;
  line-height: 1.45;
}

.cop-sug-snippet {
  background: var(--cop-bg-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--cop-text-soft);
  margin-bottom: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-word;
}
.cop-sug-snippet .cop-sug-error {
  background: rgba(239, 68, 68, .15);
  color: var(--cop-c-spelling);
  text-decoration: line-through;
  padding: 0 3px;
  border-radius: 3px;
}

.cop-sug-replacements {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 10px;
}
.cop-sug-rep {
  background: var(--cop-primary-soft);
  color: var(--cop-primary);
  border: 1px solid transparent;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.cop-sug-rep:hover {
  background: var(--cop-primary);
  color: #fff;
}
.cop-sug-no-rep {
  font-size: 12px;
  color: var(--cop-text-muted);
  font-style: italic;
  margin-bottom: 10px;
}

.cop-sug-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  border-top: 1px solid var(--cop-border);
  padding-top: 8px;
}
.cop-sug-action {
  background: transparent;
  border: 0;
  color: var(--cop-text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.cop-sug-action:hover {
  background: var(--cop-bg-muted);
  color: var(--cop-text);
}

.cop-fix-all-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--cop-border);
}
.cop-fix-all-wrap .cop-btn {
  width: 100%;
  justify-content: center;
}

/* Stats grid */
.cop-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cop-stat-box {
  background: var(--cop-bg);
  border: 1px solid var(--cop-border);
  border-radius: var(--cop-radius-sm);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.cop-stat-num {
  font-size: 20px; font-weight: 700;
  color: var(--cop-text);
  line-height: 1;
}
.cop-stat-key {
  font-size: 11px;
  color: var(--cop-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Loading overlay — HIDDEN BY DEFAULT (uses class, not [hidden] attr,
   so we don't depend on any host-theme CSS) */
.cop-loading {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
  backdrop-filter: blur(2px);
}
.cop-loading.cop-loading-show { display: flex; }
.cop-wrap[data-theme="dark"] .cop-loading { background: rgba(21, 24, 29, 0.85); }
@media (prefers-color-scheme: dark) {
  .cop-wrap[data-theme="auto"] .cop-loading { background: rgba(21, 24, 29, 0.85); }
}

/* Highlights wrap — also hidden by default via class */
.cop-highlights-wrap[hidden],
.cop-fix-all-wrap[hidden],
.cop-toast[hidden] {
  display: none !important;
}
.cop-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--cop-border);
  border-top-color: var(--cop-primary);
  border-radius: 50%;
  animation: cop-spin .8s linear infinite;
}
@keyframes cop-spin { to { transform: rotate(360deg); } }
.cop-loading-text {
  margin: 0;
  font-size: 13px;
  color: var(--cop-text-soft);
  font-weight: 500;
}

/* Toast */
.cop-toast {
  position: absolute;
  bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--cop-text);
  color: var(--cop-bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--cop-shadow-lg);
  z-index: 20;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}
.cop-toast.cop-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============== Mobile tweaks ============== */
@media (max-width: 600px) {
  .cop-wrap { font-size: 14px; border-radius: 10px; }
  .cop-toolbar { padding: 12px; }
  .cop-toolbar-right { width: 100%; }
  .cop-select { flex: 1; min-width: 0; }
  .cop-title { font-size: 15px; }
  .cop-subtitle { font-size: 11px; }
  .cop-textarea, .cop-highlights { padding: 14px; font-size: 15px; }
  .cop-editor-footer { padding: 10px 12px; }
  .cop-stats { gap: 12px; font-size: 11px; }
  .cop-btn { padding: 9px 14px; font-size: 13px; }
  .cop-sidebar-body { padding: 12px; }
  .cop-summary { grid-template-columns: 1fr 1fr; }
  .cop-stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ============== Print ============== */
@media print {
  .cop-toolbar, .cop-editor-header, .cop-editor-footer, .cop-sidebar { display: none !important; }
  .cop-wrap { border: 0; box-shadow: none; }
}
