/* ================================================================
   FRAMOS CABINETS — Panel de Administración
   ================================================================ */

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

:root {
  --navy:      #1a1a2e;
  --navy-mid:  #252545;
  --gold:      #c9a84c;
  --gold-dark: #a8893c;
  --white:     #ffffff;
  --offwhite:  #f8f6f2;
  --text:      #0f0f0f;
  --muted:     #6b7280;
  --border:    #e5e7eb;
  --success:   #2d7a4f;
  --error:     #c0392b;
  --radius:    10px;
  --header-h: 60px;
  --font:      'DM Sans', system-ui, sans-serif;
  --font-h:   'Plus Jakarta Sans', system-ui, sans-serif;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--offwhite);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Login ─────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image: radial-gradient(ellipse at 60% 30%, #252545 0%, #1a1a2e 100%);
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.login-logo {
  height: 36px;
  filter: none;
}

.login-title {
  font-family: var(--font-h);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
}

.login-sub {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
}

#loginForm {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.login-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}
.login-input:focus { border-color: var(--gold); }

.login-error {
  font-size: 0.8125rem;
  color: var(--error);
  min-height: 1rem;
  text-align: center;
}

.login-btn {
  width: 100%;
  padding: 0.875rem;
  background: var(--gold);
  color: var(--navy);
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.login-btn:hover { background: var(--gold-dark); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.login-forgot-link {
  width: 100%;
  background: none;
  border: none;
  font-size: 0.8125rem;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.2s;
  font-family: var(--font);
}
.login-forgot-link:hover { color: var(--navy); }

.login-success {
  font-size: 0.8125rem;
  color: var(--success);
  min-height: 1rem;
  text-align: center;
  font-weight: 600;
}

/* ── Admin App Layout ──────────────────────────────────────────── */
.admin-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────────── */
.admin-header {
  height: var(--header-h);
  background: var(--navy);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.admin-logo {
  height: 28px;
  filter: brightness(10);
}

.admin-brand-label {
  font-family: var(--font-h);
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Tabs */
.admin-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
}

.admin-tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.125rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-family: var(--font-h);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.admin-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.admin-tab:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.85); }
.admin-tab.active {
  background: var(--gold);
  color: var(--navy);
}
.admin-tab.active svg { stroke: var(--navy); }

/* Logout */
.admin-logout-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.875rem;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.admin-logout-btn svg { width: 14px; height: 14px; }
.admin-logout-btn:hover { border-color: rgba(255,255,255,0.45); color: rgba(255,255,255,0.85); }

/* ── Panels ────────────────────────────────────────────────────── */
.admin-panel {
  flex: 1;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.admin-panel.active { display: flex; }

/* ── Tab WEB ───────────────────────────────────────────────────── */
.web-bar {
  height: 40px;
  background: #f3f4f6;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  flex-shrink: 0;
}

.web-bar-url {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.web-open-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  transition: all 0.2s;
}
.web-open-btn svg { width: 13px; height: 13px; }
.web-open-btn:hover { background: var(--navy); color: var(--white); border-color: var(--navy); }

.web-iframe {
  flex: 1;
  border: none;
  width: 100%;
  display: block;
}

/* ── Tab ENTRADAS ──────────────────────────────────────────────── */
.entradas-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}

.entradas-title {
  font-family: var(--font-h);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--navy);
}

.btn-new {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: var(--gold);
  color: var(--navy);
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 0.875rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-new svg { width: 15px; height: 15px; }
.btn-new:hover { background: var(--gold-dark); transform: translateY(-1px); }

.entradas-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.entradas-loading { color: var(--muted); font-size: 0.875rem; padding: 2rem 0; text-align: center; }

.entradas-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.entradas-empty svg { width: 48px; height: 48px; margin-bottom: 1rem; stroke: var(--border); }
.entradas-empty h3 { font-family: var(--font-h); font-size: 1.125rem; color: #374151; margin-bottom: 0.5rem; }
.entradas-empty p { font-size: 0.875rem; }

/* Post rows */
.post-row {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.625rem;
  transition: box-shadow 0.2s;
}
.post-row:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.07); }

.post-row-thumb {
  width: 64px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--offwhite);
  flex-shrink: 0;
}
.post-row-thumb-placeholder {
  width: 64px;
  height: 48px;
  border-radius: 6px;
  background: var(--offwhite);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #d1d5db;
  font-size: 1.25rem;
}

.post-row-info { flex: 1; min-width: 0; }
.post-row-title {
  font-family: var(--font-h);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-row-meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-top: 0.25rem;
}

.cat-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(201,168,76,0.15);
  color: #8a6d0e;
}

.post-date {
  font-size: 0.75rem;
  color: var(--muted);
}

.status-pill {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
}
.status-pill.published { background: rgba(45,122,79,0.12); color: #1a5c37; }
.status-pill.draft     { background: rgba(107,114,128,0.12); color: #4b5563; }

.post-row-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.row-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  background: transparent;
}
.row-btn-edit   { border-color: var(--navy); color: var(--navy); }
.row-btn-edit:hover { background: var(--navy); color: var(--white); }
.row-btn-view   { border-color: #6b7280; color: #6b7280; }
.row-btn-view:hover { background: #6b7280; color: var(--white); }
.row-btn-toggle.published { border-color: #f59e0b; color: #b45309; }
.row-btn-toggle.published:hover { background: #fef3c7; }
.row-btn-toggle.draft { border-color: var(--success); color: var(--success); }
.row-btn-toggle.draft:hover { background: rgba(45,122,79,0.08); }
.row-btn-delete { border-color: var(--error); color: var(--error); }
.row-btn-delete:hover { background: var(--error); color: var(--white); }

/* ── Tab PUBLICAR / EDITOR ─────────────────────────────────────── */
.editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
  gap: 1rem;
}

.editor-topbar-left { display: flex; align-items: center; gap: 1rem; }

.btn-back {
  font-size: 0.8125rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: color 0.2s;
  white-space: nowrap;
}
.btn-back:hover { color: var(--navy); }

.editor-heading {
  font-family: var(--font-h);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--navy);
}

.editor-topbar-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.btn-draft {
  padding: 0.5rem 1.125rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: #374151;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-draft:hover { border-color: var(--navy); color: var(--navy); }

.btn-publish {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: var(--navy);
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-publish:hover { background: var(--gold-dark); transform: translateY(-1px); }
.btn-publish:disabled, .btn-draft:disabled { opacity: 0.5; cursor: default; transform: none; }

/* Editor layout */
.editor-layout {
  flex: 1;
  overflow: hidden;
  display: flex;
  gap: 0;
}

.editor-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.editor-sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--white);
}

/* Fields */
.field-block { display: flex; flex-direction: column; gap: 0.375rem; }

.field-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
}

.field-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
  resize: vertical;
}
.field-input:focus { border-color: var(--gold); }
.field-input--title { font-size: 1.125rem; font-weight: 600; }
.field-input--summary { resize: vertical; }
.field-input--select { cursor: pointer; }

/* Rich text toolbar */
.rich-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem 0.625rem;
  background: #f9fafb;
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.rich-toolbar button {
  padding: 0.3rem 0.625rem;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  color: #374151;
  transition: all 0.15s;
  line-height: 1.4;
}
.rich-toolbar button:hover { background: var(--border); }
.rich-toolbar button.active { background: var(--navy); color: var(--white); }
.toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 0.125rem;
  flex-shrink: 0;
}

.rich-editor {
  min-height: 320px;
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1rem;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
}
.rich-editor:focus { border-color: var(--gold); }
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}
.rich-editor h2 { font-family: var(--font-h); font-size: 1.25rem; font-weight: 700; margin: 1rem 0 0.5rem; color: var(--navy); }
.rich-editor h3 { font-family: var(--font-h); font-size: 1.0625rem; font-weight: 600; margin: 0.875rem 0 0.375rem; color: var(--navy); }
.rich-editor p  { margin-bottom: 0.75rem; }
.rich-editor ul, .rich-editor ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.rich-editor li { margin-bottom: 0.25rem; }
.rich-editor blockquote { border-left: 3px solid var(--gold); padding-left: 1rem; margin: 0.75rem 0; color: #6b7280; font-style: italic; }
.rich-editor a { color: #1d4ed8; text-decoration: underline; }

/* Sidebar cards */
.sidebar-card {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.sidebar-card-title {
  font-family: var(--font-h);
  font-size: 0.8125rem;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-preview-img {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--navy);
  transition: all 0.15s;
  text-align: center;
}
.btn-preview-img:hover { background: var(--navy); color: var(--white); border-color: var(--navy); }

.img-preview img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-top: 0.25rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.375rem 0.75rem;
  border-radius: 100px;
  background: rgba(107,114,128,0.12);
  color: #4b5563;
  width: fit-content;
}
.status-badge.published { background: rgba(45,122,79,0.12); color: #1a5c37; }

.save-msg {
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
}
.save-msg.ok    { color: var(--success); }
.save-msg.error { color: var(--error); }

/* ── Responsive ─────────────────────────────────────────────────── */

/* Login: móvil */
@media (max-width: 480px) {
  .login-screen {
    align-items: flex-start;
    padding: 2rem 1rem;
  }
  .login-card {
    padding: 1.75rem 1.25rem;
    border-radius: 12px;
  }
  .login-title { font-size: 1.125rem; }
}

/* Admin header: tablet y móvil */
@media (max-width: 768px) {
  .admin-brand-label { display: none; }
  .admin-tab { padding: 0.5rem 0.75rem; }
  .admin-logout-btn span { display: none; }
}

@media (max-width: 560px) {
  .admin-header { padding: 0 0.75rem; gap: 0.5rem; }
  .admin-tab { padding: 0.45rem 0.625rem; }
  .tab-text { display: none; }
  .admin-logout-btn { padding: 0.4rem 0.625rem; font-size: 0; }
  .admin-logout-btn svg { width: 18px; height: 18px; }
  .admin-logo { height: 22px; }
}

/* Entradas: post rows en móvil */
@media (max-width: 640px) {
  .entradas-topbar { padding: 1rem; }
  .entradas-body { padding: 0.875rem 1rem; }

  .post-row {
    flex-wrap: wrap;
    gap: 0.625rem;
  }
  .post-row-thumb,
  .post-row-thumb-placeholder { display: none; }
  .post-row-info { width: 100%; min-width: 0; }
  .post-row-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.375rem;
  }
  .row-btn { flex: 1; text-align: center; }
}

/* Editor: apila main + sidebar en móvil */
@media (max-width: 768px) {
  .editor-layout { flex-direction: column; overflow-y: auto; }
  .editor-main { overflow-y: visible; }
  .editor-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .editor-topbar { flex-wrap: wrap; gap: 0.75rem; }
  .editor-topbar-left { flex-wrap: wrap; gap: 0.5rem; }
  .editor-heading { font-size: 0.9375rem; }
  .btn-draft, .btn-publish { padding: 0.45rem 0.875rem; font-size: 0.8125rem; }
}

@media (max-width: 480px) {
  .editor-main { padding: 1rem; }
  .editor-sidebar { padding: 1rem; }
  .rich-toolbar { gap: 0.125rem; }
  .rich-toolbar button { padding: 0.275rem 0.5rem; font-size: 0.75rem; }
}
