/* ══════════════════════════════════════════
   CERAMI CASA — Admin Panel Styles
   Dark sidebar + clean content area
══════════════════════════════════════════ */

:root {
  --accent:    #C4875E;
  --accent-dk: #a86b44;
  --accent-lt: #f0e0d4;
  --white:     #ffffff;
  --sb-bg:     #111111;
  --sb-border: rgba(255,255,255,.07);
  --sb-text:   rgba(255,255,255,.55);
  --sb-active: rgba(255,255,255,.95);
  --bg:        #f4f4f6;
  --card:      #ffffff;
  --text:      #1d1d1f;
  --muted:     #6e6e73;
  --border:    #e5e5ea;
  --danger:    #ff3b30;
  --success:   #34c759;
  --font:      'Poppins', -apple-system, sans-serif;
  --sb-w:      252px;
  --radius:    10px;
  --radius-lg: 16px;
  --t:         .22s cubic-bezier(.4,0,.2,1);
}

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

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
a { text-decoration: none; color: inherit; }
input, select, textarea { font-family: var(--font); }

.hidden { display: none !important; }

/* ══════════════════════════════════════════
   LOGIN
══════════════════════════════════════════ */
#login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2520 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 48px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 32px 80px rgba(0,0,0,.4);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.login-logo-img {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.login-logo-text {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text);
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 36px;
  padding-left: 2px;
}

.field-group { margin-bottom: 18px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.field-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196,135,94,.15);
}

.login-error {
  min-height: 18px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 14px;
  font-weight: 500;
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--white);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  transition: background var(--t), transform var(--t);
}

.login-btn:hover { background: var(--accent-dk); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }

/* ══════════════════════════════════════════
   ADMIN LAYOUT
══════════════════════════════════════════ */
#admin-app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sb-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  border-right: 1px solid var(--sb-border);
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 26px 22px 24px;
  border-bottom: 1px solid var(--sb-border);
}

.sb-logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.sb-brand { display: flex; flex-direction: column; }

.sb-brand-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sb-active);
  letter-spacing: -.01em;
  line-height: 1.2;
}

.sb-badge {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 2px;
}

.sb-nav {
  flex: 1;
  padding: 20px 12px;
  overflow-y: auto;
}

.sb-nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 0 10px;
  margin-bottom: 6px;
  margin-top: 4px;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--sb-text);
  transition: background var(--t), color var(--t);
  position: relative;
  text-align: left;
}

.sb-link:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.8); }

.sb-link.is-active {
  background: rgba(196,135,94,.15);
  color: var(--accent);
}

.sb-link.is-active svg { opacity: 1; }

.sb-link svg { flex-shrink: 0; opacity: .6; }

.sb-count {
  margin-left: auto;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.4);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 24px;
  text-align: center;
}

.sb-link.is-active .sb-count {
  background: rgba(196,135,94,.25);
  color: var(--accent);
}

.sb-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-footer-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--sb-text);
  transition: background var(--t), color var(--t);
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.sb-footer-link:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.8); }

/* ─── Main ─────────────────────────────── */
.admin-main {
  margin-left: var(--sb-w);
  flex: 1;
  min-height: 100vh;
  padding: 40px;
  background: var(--bg);
}

/* ─── Section ──────────────────────────── */
.a-section { display: none; }
.a-section.is-active { display: block; }

.a-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.a-h1 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -.025em;
  color: var(--text);
  line-height: 1.2;
}

.a-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  background: var(--accent);
  color: var(--white);
  border-radius: 40px;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--t), transform var(--t), box-shadow var(--t);
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(196,135,94,.3);
}

.add-btn:hover {
  background: var(--accent-dk);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(196,135,94,.4);
}

/* ── Table ──────────────────────────────── */
.table-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-scroll { overflow-x: auto; }

.a-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.a-table thead th {
  padding: 13px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.a-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}

.a-table tbody tr:last-child { border-bottom: none; }
.a-table tbody tr:hover { background: #fafafa; }

.a-table td {
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}

.td-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: contain;
  background: #f5f5f7;
  padding: 4px;
  border: 1px solid var(--border);
}

.td-thumb-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: #f5f5f7;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c7c7cc;
  font-size: 10px;
  text-align: center;
}

.td-name { font-weight: 500; }

.td-price { font-weight: 600; color: var(--text); }

.td-badge {
  display: inline-block;
  padding: 3px 10px;
  background: var(--accent-lt);
  color: var(--accent-dk);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.td-actions { display: flex; gap: 8px; align-items: center; }

.btn-edit, .btn-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}

.btn-edit { background: #f0f0f5; color: var(--muted); }
.btn-edit:hover { background: #e8e8ef; color: var(--text); }

.btn-del { background: #fff0ee; color: #ff6b5b; }
.btn-del:hover { background: #ffe0dd; color: var(--danger); }

/* ── Category Admin Cards ───────────────── */
.cats-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.cat-admin-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow var(--t);
}

.cat-admin-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.07); }

.cat-admin-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #f5f5f7;
}

.cat-admin-img-ph {
  width: 100%;
  height: 140px;
  background: #f5f5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c7c7cc;
  font-size: 13px;
}

.cat-admin-body { padding: 18px 20px; }

.cat-admin-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.cat-admin-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.cat-admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cat-admin-sub-count {
  font-size: 12px;
  color: var(--muted);
}

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

/* ══════════════════════════════════════════
   FORM MODAL
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10,8,6,.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t);
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.modal-panel {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,.2);
  transform: translateY(20px) scale(.98);
  transition: transform .3s cubic-bezier(0,.55,.45,1);
  scrollbar-width: thin;
}

.modal-overlay.is-open .modal-panel { transform: translateY(0) scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f5f5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t), transform var(--t);
  color: var(--muted);
}

.modal-close:hover { background: #ebebef; transform: rotate(90deg); }

.modal-body { padding: 24px 28px 32px; }

/* ── Form Styles ────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid .full-col { grid-column: 1 / -1; }

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

.form-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196,135,94,.12);
}

.form-textarea { resize: vertical; min-height: 72px; line-height: 1.5; }

/* Image section in form */
.form-img-section {
  grid-column: 1 / -1;
  background: #fafafa;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.form-img-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  display: block;
}

.form-img-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.form-img-preview {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  background: #efefef;
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c7c7cc;
  font-size: 11px;
}

.form-img-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.form-img-inputs { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.form-img-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* Cloudinary / Firebase note */
.cloud-note {
  display: inline-block;
  font-size: 10px;
  background: #fff8f4;
  color: var(--accent);
  border: 1px solid var(--accent-lt);
  border-radius: 6px;
  padding: 4px 10px;
  margin-top: 4px;
  font-weight: 500;
}

.form-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn-cancel {
  padding: 10px 22px;
  background: #f5f5f7;
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--t);
}

.btn-cancel:hover { background: #ebebef; }

.btn-save {
  padding: 10px 28px;
  background: var(--accent);
  color: var(--white);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--t), transform var(--t);
}

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

/* ══════════════════════════════════════════
   CONFIRM DIALOG
══════════════════════════════════════════ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(10,8,6,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t);
}

.confirm-overlay.is-open { opacity: 1; pointer-events: all; }

.confirm-box {
  background: var(--white);
  border-radius: 18px;
  padding: 36px 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.2);
}

.confirm-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff0ee;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.confirm-msg {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.confirm-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.confirm-actions { display: flex; gap: 12px; }

.btn-delete {
  flex: 1;
  padding: 12px;
  background: var(--danger);
  color: var(--white);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: background var(--t);
}

.btn-delete:hover { background: #e0352a; }

.btn-cancel {
  flex: 1;
  padding: 12px;
  background: #f5f5f7;
  color: var(--muted);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--t);
}

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 9999;
  background: #1d1d1f;
  color: #fff;
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  max-width: 320px;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.toast-ok  { border-left: 3px solid var(--success); }
.toast.toast-err { border-left: 3px solid var(--danger); }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--t); }
  .sidebar.is-open { transform: translateX(0); }
  .admin-main { margin-left: 0; padding: 24px 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-col { grid-column: 1; }
}

@media (max-width: 600px) {
  .a-header { flex-direction: column; align-items: flex-start; }
  .add-btn { width: 100%; justify-content: center; }
  .login-card { padding: 36px 28px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d1d6; border-radius: 3px; }

/* Focus */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ══════════════════════════════════════════
   SIDEBAR — user email
══════════════════════════════════════════ */
.sb-user-email {
  font-size: 11px;
  color: rgba(255,255,255,.35);
  padding: 0 22px 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════════
   SETTINGS SECTION
══════════════════════════════════════════ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 820px;
}

.settings-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 28px 32px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,.05);
}

.settings-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 22px;
}

.settings-card-title svg {
  color: var(--accent);
  flex-shrink: 0;
}

.btn-save {
  margin-top: 18px;
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t), transform var(--t);
}

.btn-save:hover  { background: var(--accent-dk); }
.btn-save:active { transform: scale(.97); }

@media (max-width: 680px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════
   HERO SLOTS — Portada
══════════════════════════════════════════ */
.hero-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  max-width: 900px;
}

.hero-slot {
  position: relative;
  aspect-ratio: 16/9;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
}

.hero-slot--filled {
  background: var(--gray-100);
}

.hero-slot-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-slot-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px;
  transition: opacity .2s;
}

.hero-slot--filled:hover .hero-slot-overlay { opacity: 1; }

.hero-slot-num {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}

.hero-slot-del {
  background: rgba(220,50,50,.85);
  border: none;
  border-radius: 8px;
  color: #fff;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s;
}

.hero-slot-del:hover { background: #cc2222; }

.hero-slot--empty {
  border: 2px dashed var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}

.hero-slot--empty:hover {
  border-color: var(--accent);
  background: rgba(196,135,94,.05);
  color: var(--accent);
}

.hero-slot--empty.is-uploading {
  pointer-events: none;
  opacity: .6;
}

.hero-slot-count {
  font-size: 11px;
  opacity: .5;
}

.hero-slots-empty {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-2);
}
