/* ── Variables ──────────────────────────────────────────── */
:root {
  --bg:        #0f1117;
  --bg2:       #1a1d2e;
  --bg3:       #252840;
  --border:    #2e3150;
  --text:      #e8eaf6;
  --text2:     #8b92c8;
  --accent:    #6c63ff;
  --accent2:   #a78bfa;
  --green:     #10b981;
  --red:       #ef4444;
  --orange:    #f59e0b;
  --sidebar-w: 220px;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
}

body.dark {
  --bg:    #0f1117;
  --bg2:   #1a1d2e;
  --bg3:   #252840;
  --border:#2e3150;
  --text:  #e8eaf6;
  --text2: #8b92c8;
}

body:not(.dark) {
  --bg:    #f4f5fb;
  --bg2:   #ffffff;
  --bg3:   #eef0fa;
  --border:#d1d5e8;
  --text:  #1a1d2e;
  --text2: #6b7280;
  --shadow:0 4px 24px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: background 0.3s;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

/* ── Iconos (SVG inline) ────────────────────────────────── */
.icon {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.15em;
}

.logo-icon {
  font-size: 1.4rem;
  color: var(--accent);
  display: inline-flex;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.9rem;
  text-align: left;
  width: 100%;
  transition: all 0.2s;
  position: relative;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }

.nav-item.active {
  background: var(--accent);
  color: white;
}

.nav-icon { font-size: 1rem; flex-shrink: 0; display: inline-flex; }

.badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 0.1rem 0.4rem;
  min-width: 18px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-bottom {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.theme-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  cursor: pointer;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--text);
}

.theme-btn:hover { background: var(--accent); }

/* ── Main ───────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  max-width: 1000px;
}

.section { display: none; }
.section.active { display: block; }

.section-header {
  margin-bottom: 2rem;
}

.section-header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.section-header p {
  color: var(--text2);
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  margin-bottom: 1rem;
}

/* ── Compose Grid ───────────────────────────────────────── */
.compose-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ── Upload ─────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  margin-bottom: 0.75rem;
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
  background-color: rgba(108,99,255,0.05);
}

.upload-placeholder {
  text-align: center;
  padding: 1rem;
  pointer-events: none;
}

.upload-icon { font-size: 2rem; margin-bottom: 0.5rem; display: flex; justify-content: center; color: var(--text2); }

.upload-placeholder p {
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 0.25rem;
}

.upload-placeholder span {
  font-size: 0.75rem;
  color: var(--text2);
  opacity: 0.6;
}

#imagePreview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

/* ── Textarea ───────────────────────────────────────────── */
.textarea-wrap {
  position: relative;
  margin-bottom: 1rem;
}

textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.875rem;
  resize: vertical;
  line-height: 1.6;
  transition: border-color 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.char-counter {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text2);
  margin-top: 0.35rem;
}

/* ── Networks ───────────────────────────────────────────── */
.networks-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.network-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  transition: all 0.2s;
  user-select: none;
}

.network-check:has(input:checked) {
  border-color: var(--accent);
  background: rgba(108,99,255,0.1);
}

.network-check input { cursor: pointer; }
.network-icon { font-size: 1.05rem; display: inline-flex; }

/* ── Schedule row ───────────────────────────────────────── */
.schedule-row {
  margin-bottom: 1.25rem;
}

.schedule-row label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 0.4rem;
}

.date-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.65rem 0.875rem;
  transition: border-color 0.2s;
}

.date-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-secondary:hover { background: var(--border); }

.btn-sm { padding: 0.5rem 0.75rem; font-size: 0.8rem; margin-top: 0.5rem; }

/* ── Posts List ─────────────────────────────────────────── */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  position: relative;
  transition: border-color 0.2s;
}

.post-card:hover { border-color: var(--accent); }

.post-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.post-body { flex: 1; min-width: 0; }

.post-text {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
  word-break: break-word;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.post-date { font-size: 0.8rem; color: var(--text2); }

.post-networks { display: flex; gap: 0.4rem; }

.badge-ig {
  background: linear-gradient(135deg,#833ab4,#fd1d1d,#fcb045);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}

.badge-fb {
  background: #1877f2;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}

.post-status { font-size: 0.78rem; color: var(--text2); }
.status-published { color: var(--green); }
.status-failed    { color: var(--red); }

.delete-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s;
  padding: 0.25rem;
  flex-shrink: 0;
}

.delete-btn:hover { opacity: 1; }

/* ── Stats ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.04em;
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text2);
  margin-top: 0.5rem;
  font-weight: 500;
}

/* ── Accounts ───────────────────────────────────────────── */
.accounts-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.btn-connect {
  width: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
}

.info-banner {
  background: rgba(108,99,255,0.08);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.info-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.1rem; display: inline-flex; color: var(--accent); }

.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.account-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color 0.2s;
}

.account-card:hover { border-color: var(--accent); }

.account-card.instagram { border-left: 3px solid #e1306c; }
.account-card.facebook  { border-left: 3px solid #1877f2; }

.account-icon { font-size: 1.75rem; flex-shrink: 0; display: inline-flex; }

.account-info { flex: 1; min-width: 0; }

.account-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-platform {
  font-size: 0.78rem;
  color: var(--text2);
  margin-top: 0.15rem;
}

.account-id {
  font-size: 0.72rem;
  color: var(--text2);
  opacity: 0.6;
  margin-top: 0.1rem;
  font-family: monospace;
}

.account-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text2);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--text2); }

.disconnect-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.3rem;
  border-radius: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.disconnect-btn:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* ── Empty / Loading ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text2);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.loading { text-align: center; padding: 2rem; color: var(--text2); font-size: 0.9rem; }

/* ── Toasts ─────────────────────────────────────────────── */
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.3s;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast.success .icon { color: var(--green); }
.toast.error   .icon { color: var(--red); }
.toast.info    .icon { color: var(--accent); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 720px) {
  :root { --sidebar-w: 60px; }
  .logo-text, .nav-item span:not(.nav-icon):not(.badge) { display: none; }
  .compose-grid { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}

/* ── Post Cards Mejoradas ───────────────────────────────── */
.post-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  display: flex;
  gap: 0;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.post-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(108,99,255,0.15);
}

.post-img {
  width: 110px;
  min-height: 110px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 0;
}

.post-body {
  flex: 1;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.post-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.post-plats {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.plat-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.plat-ig {
  background: linear-gradient(135deg,#833ab4,#fd1d1d,#fcb045);
  color: white;
}

.plat-fb {
  background: #1877f2;
  color: white;
}

.cuenta-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.post-estado {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.7rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.estado-pending { background: rgba(245,158,11,0.15); color: var(--orange); }
.estado-ok      { background: rgba(16,185,129,0.15); color: var(--green); }
.estado-err     { background: rgba(239,68,68,0.15);  color: var(--red); }

.post-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  flex: 1;
}

.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.post-date-badge {
  font-size: 0.78rem;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.post-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-action {
  border: none;
  border-radius: 8px;
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-edit {
  background: rgba(108,99,255,0.12);
  color: var(--accent);
}

.btn-edit:hover { background: var(--accent); color: white; }

.btn-delete {
  background: rgba(239,68,68,0.1);
  color: var(--red);
}

.btn-delete:hover { background: var(--red); color: white; }

.status-badge { display: none; }

/* ── Ajustes PDF ───────────────────────────── */
.settings-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.settings-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.settings-desc {
    font-size: 0.8rem;
    color: var(--text2);
    margin: 0 0 14px 0;
}
.settings-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}
.settings-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
