/* ============================================================
   FENIX · Sistema de diseño
   Tokens y reglas extraídas del Brandbook (opción 3 principal)
   ============================================================ */

:root {
  /* Paleta corporativa */
  --fenix-blue:   #0063BE;
  --fenix-blue-d: #004f99;
  --fenix-blue-l: #e6f0fb;
  --fenix-black:  #111111;
  --fenix-white:  #FFFFFF;
  --fenix-gray:   #F4F7FA;
  --fenix-gray-2: #E5EAF1;
  --fenix-gray-3: #9CA6B4;
  --fenix-night:  #0B1220;
  --fenix-danger: #c1372f;
  --fenix-ok:     #1f7a4d;

  /* Tipografía */
  --font-display: 'Montserrat', 'Segoe UI', system-ui, sans-serif;
  --font-ui:      'Inter', 'Segoe UI', system-ui, sans-serif;

  /* Radios y sombras */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(11,18,32,0.06);
  --shadow:    0 4px 14px rgba(11,18,32,0.08);
  --shadow-lg: 0 12px 32px rgba(11,18,32,0.12);

  /* Layout */
  --container: 1200px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  color: var(--fenix-black);
  background: var(--fenix-gray);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--fenix-black);
  margin: 0;
}

a { color: var(--fenix-blue); text-decoration: none; }
a:hover { color: var(--fenix-blue-d); }

button {
  font-family: var(--font-ui);
  cursor: pointer;
}

/* ===== Cabecera ===== */

.fx-header {
  background: var(--fenix-white);
  border-bottom: 1px solid var(--fenix-gray-2);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.fx-header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.fx-header .fx-brand { display: flex; align-items: center; gap: 12px; }
.fx-header .fx-brand img,
.fx-header .fx-brand svg { height: 44px; width: auto; display: block; }

.fx-header nav { display: flex; gap: 8px; align-items: center; }

.fx-header nav a {
  font-size: 14px;
  color: var(--fenix-black);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: background .15s ease;
}
.fx-header nav a:hover { background: var(--fenix-gray); }
.fx-header nav a.active {
  background: var(--fenix-blue-l);
  color: var(--fenix-blue);
  font-weight: 500;
}

/* ===== Layout general ===== */

.fx-container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.fx-page-title {
  font-size: 32px;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.fx-page-subtitle {
  color: var(--fenix-gray-3);
  font-size: 15px;
  margin-bottom: 36px;
}

/* ===== Botones ===== */

.fx-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s ease;
  background: var(--fenix-white);
  color: var(--fenix-black);
  border-color: var(--fenix-gray-2);
}
.fx-btn:hover { border-color: var(--fenix-gray-3); }

.fx-btn-primary {
  background: var(--fenix-blue);
  color: var(--fenix-white);
  border-color: var(--fenix-blue);
}
.fx-btn-primary:hover {
  background: var(--fenix-blue-d);
  border-color: var(--fenix-blue-d);
}

.fx-btn-ghost { background: transparent; border-color: transparent; }
.fx-btn-ghost:hover { background: var(--fenix-gray); }

.fx-btn-danger {
  background: var(--fenix-white);
  color: var(--fenix-danger);
  border-color: var(--fenix-gray-2);
}
.fx-btn-danger:hover { border-color: var(--fenix-danger); }

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

/* ===== Home: grid de aplicaciones ===== */

.fx-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

.fx-app-card {
  background: var(--fenix-white);
  border: 1px solid var(--fenix-gray-2);
  border-radius: var(--radius);
  padding: 28px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  text-decoration: none;
  color: inherit;
  min-height: 240px;
}

.fx-app-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--fenix-blue);
}

.fx-app-icon {
  width: 88px;
  height: 88px;
  border-radius: var(--radius);
  background: var(--fenix-blue-l);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--fenix-blue);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 38px;
  flex-shrink: 0;
}

.fx-app-icon img,
.fx-app-icon svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Cuando la imagen del icono YA es una pastilla redondeada (los PNG
   de las apps vienen así), no hace falta el fondo azul claro de detrás. */
.fx-app-icon.has-image {
  background: transparent;
}

.fx-app-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--fenix-black);
  margin: 0;
}

.fx-app-desc {
  font-size: 13px;
  color: var(--fenix-gray-3);
  margin: 0;
  line-height: 1.5;
  flex-grow: 1;
}

.fx-app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--fenix-blue);
  font-weight: 500;
}

.fx-app-footer svg {
  width: 14px;
  height: 14px;
  transition: transform .15s ease;
}

.fx-app-card:hover .fx-app-footer svg {
  transform: translateX(4px);
}

/* Tarjeta vacía para invitar a añadir desde backoffice */
.fx-empty {
  background: var(--fenix-white);
  border: 1px dashed var(--fenix-gray-2);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  color: var(--fenix-gray-3);
}
.fx-empty h3 { color: var(--fenix-black); margin-bottom: 8px; font-size: 18px; }
.fx-empty p { margin: 0 0 20px; font-size: 14px; }

/* ===== Backoffice: tabla y formulario ===== */

.fx-bo-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .fx-bo-layout { grid-template-columns: 1fr; }
}

.fx-card {
  background: var(--fenix-white);
  border: 1px solid var(--fenix-gray-2);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.fx-card h2 {
  font-size: 16px;
  margin-bottom: 4px;
}

.fx-card .fx-hint {
  font-size: 13px;
  color: var(--fenix-gray-3);
  margin: 0 0 20px;
}

.fx-form-group { margin-bottom: 16px; }

.fx-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--fenix-black);
  margin-bottom: 6px;
}

.fx-input,
.fx-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--fenix-gray-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--fenix-black);
  background: var(--fenix-white);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.fx-input:focus,
.fx-textarea:focus {
  outline: none;
  border-color: var(--fenix-blue);
  box-shadow: 0 0 0 3px rgba(0,99,190,0.15);
}
.fx-textarea { resize: vertical; min-height: 70px; }

.fx-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fx-file-preview {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--fenix-blue-l);
  border: 1px solid var(--fenix-gray-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--fenix-blue);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  flex-shrink: 0;
}
.fx-file-preview img,
.fx-file-preview svg {
  width: 100%; height: 100%; object-fit: contain;
}
.fx-file-preview.has-image {
  background: transparent;
  border-color: var(--fenix-gray-2);
}

.fx-file-input {
  position: relative;
  flex-grow: 1;
}
.fx-file-input input[type="file"] {
  position: absolute; opacity: 0; inset: 0; cursor: pointer;
}
.fx-file-input .fx-btn { width: 100%; justify-content: center; }

.fx-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--fenix-gray-2);
}
.fx-form-actions .fx-btn { flex: 1; justify-content: center; }

.fx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.fx-table th {
  text-align: left;
  font-weight: 500;
  color: var(--fenix-gray-3);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--fenix-gray-2);
}
.fx-table td {
  padding: 14px;
  border-bottom: 1px solid var(--fenix-gray-2);
  vertical-align: middle;
}
.fx-table tr:last-child td { border-bottom: none; }

.fx-table tbody tr { transition: background .12s ease; }
.fx-table tbody tr:hover { background: var(--fenix-gray); }

.fx-cell-app {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fx-cell-app .fx-file-preview { width: 40px; height: 40px; font-size: 16px; }
.fx-cell-app strong { font-weight: 500; }

.fx-cell-url a {
  color: var(--fenix-gray-3);
  font-size: 13px;
  word-break: break-all;
}
.fx-cell-url a:hover { color: var(--fenix-blue); }

.fx-cell-actions { text-align: right; white-space: nowrap; }
.fx-cell-actions .fx-btn { margin-left: 6px; }

/* Estado de fila editándose */
.fx-table tr.is-editing { background: var(--fenix-blue-l); }

/* Mensajes */

.fx-flash {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}
.fx-flash.is-visible { display: block; }
.fx-flash.is-ok { background: #e9f5ee; color: var(--fenix-ok); border: 1px solid #c5e3d3; }
.fx-flash.is-err { background: #fbeae9; color: var(--fenix-danger); border: 1px solid #f3c8c4; }

/* Footer suave */
.fx-footer {
  max-width: var(--container);
  margin: 0 auto;
  padding: 24px;
  font-size: 12px;
  color: var(--fenix-gray-3);
  text-align: center;
}
