/**
 * style.css
 * Premium dark theme para o App Artigo Pilar
 * Design system com glassmorphism, gradients e micro-animações
 */

/* ============================================================
   RESET & VARIABLES
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #00d4aa;
  --primary-dark: #00b894;
  --primary-glow: rgba(0, 212, 170, 0.15);
  --accent: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.15);
  --danger: #ff4757;
  --warning: #ffa502;
  --success: #2ed573;

  --bg-deep: #0a0a1a;
  --bg-base: #0f0f23;
  --bg-card: #161630;
  --bg-card-hover: #1a1a3e;
  --bg-input: #1c1c40;
  --bg-input-focus: #22224a;

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-active: rgba(0, 212, 170, 0.3);

  --text-primary: #f0f0f0;
  --text-secondary: #a0a0b8;
  --text-muted: #666680;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px rgba(0, 212, 170, 0.08);

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  scroll-behavior: smooth;
}

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

/* Background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(0, 212, 170, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse 60% 30% at 80% 100%, rgba(108, 99, 255, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   HEADER
   ============================================================ */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 35, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.header-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(0, 212, 170, 0.3));
}

.logo-text {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.logo-accent {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
#app-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  animation: cardSlideIn 0.4s ease;
}

@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.01);
}

.card-header-compact {
  padding: 16px 28px;
}

.card-header h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.card-sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 2px 0 0 0;
}

.card-body {
  padding: 24px 28px;
}

.step-badge {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: var(--bg-deep);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 212, 170, 0.2);
}

.step-badge-success {
  background: linear-gradient(135deg, var(--success), #00b894);
  font-size: 18px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.form-group-small {
  max-width: 160px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"] {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
  width: 100%;
}

input:focus {
  border-color: var(--primary);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder {
  color: var(--text-muted);
}

.btn-toggle-pw {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  transition: var(--transition);
}

.btn-toggle-pw:hover {
  opacity: 1;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg-deep);
  box-shadow: 0 4px 14px rgba(0, 212, 170, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(0, 212, 170, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #e84141);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 71, 87, 0.25);
}

.btn-danger:hover {
  box-shadow: 0 6px 20px rgba(255, 71, 87, 0.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 14px;
}

.btn-ghost:hover {
  color: var(--primary);
  background: var(--primary-glow);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ============================================================
   CHECKBOXES
   ============================================================ */
.blocks-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
  color: var(--text-secondary);
}

.checkbox-item:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.checkbox-item input[type="checkbox"] {
  display: none;
}

.check-mark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-hover);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  font-size: 12px;
  color: transparent;
}

.checkbox-item input[type="checkbox"]:checked ~ .check-mark {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--bg-deep);
}

.checkbox-item input[type="checkbox"]:checked ~ .check-mark::after {
  content: '✓';
}

.checkbox-item input[type="checkbox"]:checked ~ span:last-child {
  color: var(--text-primary);
}

.options-row {
  margin-bottom: 16px;
}

/* ============================================================
   COLOR CONFIG
   ============================================================ */
.color-config {
  margin-top: 8px;
}

.color-inputs {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.color-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="color"] {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  padding: 2px;
}

/* ============================================================
   POST INFO
   ============================================================ */
.post-info-box {
  background: rgba(0, 212, 170, 0.04);
  border: 1px solid rgba(0, 212, 170, 0.12);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.post-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-publish {
  background: rgba(46, 213, 115, 0.15);
  color: var(--success);
}

.badge-draft {
  background: rgba(255, 165, 2, 0.15);
  color: var(--warning);
}

.post-headings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.heading-tag {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.heading-tag-h2 {
  border-color: rgba(108, 99, 255, 0.3);
  color: var(--accent);
}

.heading-tag-h3 {
  border-color: rgba(0, 212, 170, 0.2);
  color: var(--primary);
  font-size: 10px;
}

.post-blocks-warning {
  margin-top: 12px;
}

.warning-box {
  background: rgba(255, 165, 2, 0.08);
  border: 1px solid rgba(255, 165, 2, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--warning);
}

.subsection {
  margin-bottom: 20px;
}

.subsection h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.subsection h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 10px 0;
  color: var(--text-secondary);
}

/* ============================================================
   CONNECTION STATUS
   ============================================================ */
.connection-status {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conn-success {
  color: var(--success);
}

.conn-error {
  color: var(--danger);
}

/* ============================================================
   PREVIEW & DIFF
   ============================================================ */
.preview-count {
  margin-left: auto;
  background: var(--primary-glow);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
}

.insertions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.insertion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.insertion-item:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.insertion-key {
  background: var(--accent);
  color: #fff;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  min-width: 44px;
  text-align: center;
}

.insertion-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.diff-container {
  margin-bottom: 20px;
}

.diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.diff-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.diff-stats {
  font-size: 12px;
  color: var(--text-muted);
}

.diff-view {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.diff-line-added {
  background: rgba(46, 213, 115, 0.08);
  border-left: 3px solid var(--success);
  padding: 4px 12px;
  margin: 2px 0;
  border-radius: 0 4px 4px 0;
  color: var(--success);
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-line-removed {
  background: rgba(255, 71, 87, 0.08);
  border-left: 3px solid var(--danger);
  padding: 4px 12px;
  margin: 2px 0;
  border-radius: 0 4px 4px 0;
  color: var(--danger);
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-line-context {
  color: var(--text-muted);
  padding: 4px 12px;
  margin: 2px 0;
  font-style: italic;
}

/* ============================================================
   RESULT
   ============================================================ */
.result-box {
  background: rgba(46, 213, 115, 0.06);
  border: 1px solid rgba(46, 213, 115, 0.2);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
}

.result-box p {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 4px 0;
}

.result-box .result-highlight {
  color: var(--success);
  font-weight: 700;
}

/* ============================================================
   LOGS
   ============================================================ */
.logs-container {
  padding: 16px 20px;
  max-height: 250px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.8;
}

.log-empty {
  color: var(--text-muted);
  font-style: italic;
}

.log-entry {
  padding: 2px 0;
  animation: logFadeIn 0.3s ease;
}

@keyframes logFadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.log-info { color: var(--text-secondary); }
.log-success { color: var(--success); }
.log-warning { color: var(--warning); }
.log-error { color: var(--danger); }
.log-step { color: var(--primary); font-weight: 600; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalOverlayIn 0.2s ease;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  max-height: 60vh;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.loading-spinner p {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}

/* ============================================================
   PRESET ITEMS
   ============================================================ */
.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: var(--transition);
}

.preset-item:hover {
  border-color: var(--primary);
}

.preset-name {
  font-weight: 700;
  font-size: 14px;
}

.preset-date {
  font-size: 11px;
  color: var(--text-muted);
}

.preset-actions {
  display: flex;
  gap: 6px;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .blocks-selector {
    grid-template-columns: 1fr;
  }

  .card-body {
    padding: 18px 18px;
  }

  .card-header {
    padding: 18px 18px;
  }

  .header-content {
    padding: 0 8px;
  }

  .color-inputs {
    flex-direction: column;
    gap: 12px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }
}
