/* =========================================================
   Panel administrativo FDO ORGANIC
   CSS propio (sin framework ni CDN) con los tokens de la marca.
   ========================================================= */

:root {
  --brand-900: #3a1c01;
  --brand-800: #4a2201;
  --brand-700: #5c2b02;
  --brand-600: #74380a;
  --brand-500: #8c4713;
  --brand-100: #f1e4d7;
  --brand-50: #faf4ee;
  --naranja: #e77103;
  --cream: #fbf6ef;
  --cream-dark: #f0e6d8;
  --ink: #3a2a1c;
  --ink-soft: #6b5947;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warn: #8a6100;
  --warn-bg: #fff6e0;
  --radius: 14px;
  --shadow: 0 2px 10px rgb(60 32 8 / 0.07), 0 12px 28px -14px rgb(60 32 8 / 0.18);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--brand-700); }

h1, h2, h3 { color: var(--brand-800); margin: 0; line-height: 1.25; }

/* ---------------- Estructura ---------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: var(--brand-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .marca {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
}
.sidebar .marca b { font-size: 20px; letter-spacing: .02em; display: block; }
.sidebar .marca span {
  font-size: 10px; letter-spacing: .42em; color: var(--naranja);
  text-transform: uppercase;
}

.sidebar nav { padding: 14px 12px; flex: 1; overflow-y: auto; }

.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 3px;
  border-radius: 10px;
  color: rgb(255 255 255 / 0.8);
  text-decoration: none;
  font-size: 14.5px;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgb(255 255 255 / 0.09); color: #fff; }
.sidebar nav a.activo { background: var(--naranja); color: #fff; font-weight: 600; }
.sidebar nav a .pastilla {
  margin-left: auto; background: #fff; color: var(--brand-800);
  border-radius: 999px; padding: 1px 8px; font-size: 11.5px; font-weight: 700;
}

.sidebar .pie { padding: 14px; border-top: 1px solid rgb(255 255 255 / 0.1); font-size: 12.5px; }
.sidebar .pie a { color: rgb(255 255 255 / 0.75); text-decoration: none; }
.sidebar .pie form { margin: 8px 0 0; }

.contenido { flex: 1; min-width: 0; }

.barra {
  background: #fff;
  border-bottom: 1px solid var(--cream-dark);
  padding: 16px 26px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
.barra h1 { font-size: 21px; }
.barra .derecha { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.principal { padding: 26px; max-width: 1240px; }

/* ---------------- Componentes ---------------- */

.tarjeta {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.tarjeta + .tarjeta { margin-top: 20px; }
.tarjeta > h2 { font-size: 17px; margin-bottom: 14px; }

.rejilla { display: grid; gap: 18px; }
.rejilla.k4 { grid-template-columns: repeat(4, 1fr); }
.rejilla.k3 { grid-template-columns: repeat(3, 1fr); }
.rejilla.k2 { grid-template-columns: repeat(2, 1fr); }

.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.kpi .etiqueta { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--naranja); font-weight: 700; }
.kpi .valor { font-size: 32px; font-weight: 700; color: var(--brand-700); margin-top: 6px; line-height: 1.1; }
.kpi .nota { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 9px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primario { background: var(--naranja); color: #fff; }
.btn-primario:hover { background: #c85f02; }
.btn-suave { background: #fff; color: var(--brand-800); border-color: var(--cream-dark); }
.btn-suave:hover { border-color: var(--brand-500); }
.btn-peligro { background: var(--danger-bg); color: var(--danger); }
.btn-peligro:hover { background: #f9d8d5; }
.btn-mini { padding: 5px 12px; font-size: 13px; }

/* Formularios */
.campo { margin-bottom: 16px; }
.campo label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.campo .ayuda { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--cream-dark); border-radius: 10px;
  font: inherit; color: inherit; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
textarea { resize: vertical; min-height: 110px; }

.check { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; font-size: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--brand-600); }

/* Tablas — con scroll horizontal para que no se recorten en móvil (L.30) */
.tabla-envoltura { overflow-x: auto; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
table.tabla { width: 100%; border-collapse: collapse; min-width: 720px; }
table.tabla th {
  text-align: left; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--naranja); padding: 14px 16px; border-bottom: 1px solid var(--cream-dark); white-space: nowrap;
}
table.tabla td { padding: 14px 16px; border-bottom: 1px solid var(--cream); vertical-align: top; }
table.tabla tr:last-child td { border-bottom: 0; }
table.tabla tbody tr:hover { background: var(--brand-50); }
table.tabla a.titulo { font-weight: 600; text-decoration: none; }
table.tabla a.titulo:hover { text-decoration: underline; }

/* Etiquetas de estado */
.estado { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.estado.nueva { background: var(--brand-100); color: var(--brand-800); }
.estado.en_proceso { background: var(--warn-bg); color: var(--warn); }
.estado.respondida { background: #e5eefb; color: #14508f; }
.estado.cerrada { background: var(--cream-dark); color: var(--ink-soft); }

/* Avisos */
.aviso { padding: 13px 17px; border-radius: 12px; margin-bottom: 20px; font-size: 14.5px; }
.aviso.ok { background: var(--brand-50); color: var(--brand-800); border: 1px solid var(--brand-100); }
.aviso.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f5c6c2; }

.vacio { text-align: center; padding: 46px 20px; color: var(--ink-soft); }

/* Filtros */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filtros input[type=search] { max-width: 300px; }
.filtros select { max-width: 190px; }

/* Paginación */
.paginacion { margin-top: 18px; display: flex; gap: 6px; flex-wrap: wrap; }
.paginacion a, .paginacion span {
  padding: 7px 13px; border-radius: 9px; text-decoration: none;
  background: #fff; border: 1px solid var(--cream-dark); font-size: 14px;
}
.paginacion .actual { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }

/* Editor de producto: columna principal + barra lateral (estilo WooCommerce) */
.editor { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.editor .lateral { position: sticky; top: 92px; }

/* Biblioteca de medios */
.medios-rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.medio { background: #fff; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.medio img { width: 100%; height: 118px; object-fit: cover; display: block; background: var(--cream); }
.medio .info { padding: 9px 11px; font-size: 12px; color: var(--ink-soft); }
.medio .info b { display: block; color: var(--ink); font-size: 12.5px; word-break: break-all; font-weight: 600; }

/* Vista previa de imagen del producto */
.previa {
  width: 100%; aspect-ratio: 5/3; border-radius: 12px; object-fit: cover;
  background: var(--cream); border: 1px dashed var(--cream-dark); display: block;
}

/* Login */
.login-pantalla {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
}
.login-caja { background: #fff; border-radius: 20px; padding: 36px 32px; width: 100%; max-width: 400px; box-shadow: 0 30px 60px -24px rgb(0 0 0 / .45); }
.login-caja .marca { text-align: center; margin-bottom: 26px; }
.login-caja .marca b { font-size: 27px; color: var(--brand-800); display: block; letter-spacing: .02em; }
.login-caja .marca span { font-size: 10.5px; letter-spacing: .42em; color: var(--naranja); text-transform: uppercase; }
.login-caja .credito { text-align: center; margin-top: 22px; font-size: 12.5px; color: var(--ink-soft); }

/* Gráfico de barras.
   La barra va posicionada en absoluto dentro de una pista de alto fijo: así su
   altura es exactamente la del dato y flexbox no la estira. */
.gr-barras { display: flex; gap: 6px; }
.gr-barras .col { flex: 1; min-width: 0; }
.gr-barras .pista {
  position: relative;
  height: 130px;
  background: linear-gradient(var(--cream), var(--cream)) bottom / 100% 1px no-repeat;
}
.gr-barras .barra {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--naranja); border-radius: 5px 5px 0 0;
  transition: background .15s;
}
.gr-barras .col:hover .barra { background: #c85f02; }
.gr-barras .fecha {
  font-size: 10.5px; color: var(--ink-soft); white-space: nowrap;
  text-align: center; margin-top: 6px;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 1080px) {
  .rejilla.k4 { grid-template-columns: repeat(2, 1fr); }
  .editor { grid-template-columns: 1fr; }
  .editor .lateral { position: static; }
}

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .sidebar nav a { flex: 1 1 auto; justify-content: center; margin: 0; }
  .sidebar .pie { display: flex; justify-content: space-between; align-items: center; }
  .principal { padding: 18px; }
  .barra { padding: 14px 18px; position: static; }
  .rejilla.k4, .rejilla.k3, .rejilla.k2 { grid-template-columns: 1fr; }
}
