/* ============================================================
   AKSTRATO CRM — modules/ajustes/ajustes.css
   Estilos del módulo de Ajustes.
   Utiliza CSS variables para el sistema de temas.
   ============================================================ */

/* ── Variables de tema (valor por defecto: Azul Akstrato) ── */
:root {
  --cp:       #2B2BFF;
  --cp-light: #EEF2FF;
  --cp-dark:  #1F1FCC;
  --cp-rgb:   43, 43, 255;
}

/* ── Layout principal ──────────────────────────────────────── */
#v-ajustes { overflow-y: auto; }

.stg-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.stg-header {
  padding: 22px 28px 0;
  flex-shrink: 0;
}

.stg-header-title {
  font-size: 20px;
  font-weight: 800;
  color: #0D1B2A;
  margin: 0 0 3px;
  letter-spacing: -.3px;
}

.stg-header-sub {
  font-size: 12px;
  color: #9CA3AF;
  margin-bottom: 0;
}

.stg-body {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
  padding: 18px 28px 36px;
}

/* ── Navegación lateral ────────────────────────────────────── */
.stg-nav {
  width: 196px;
  flex-shrink: 0;
  background: #F8FAFF;
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: fit-content;
  position: sticky;
  top: 18px;
  border: 1px solid #E8EDFF;
}

.stg-nav-group {
  font-size: 9px;
  font-weight: 800;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 10px 12px 4px;
}

.stg-nav-group:first-child { padding-top: 4px; }

.stg-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all .12s;
  user-select: none;
  white-space: nowrap;
}

.stg-nav-item:hover { background: var(--cp-light); color: var(--cp); }

.stg-nav-item.active {
  background: var(--cp);
  color: #fff;
  font-weight: 600;
}

.stg-ni-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stg-ni-icon svg { width: 16px; height: 16px; stroke-width: 1.75; }

/* ── Contenido principal ───────────────────────────────────── */
.stg-content {
  flex: 1;
  min-width: 0;
  padding: 0 0 0 22px;
}

.stg-sec-title {
  font-size: 16px;
  font-weight: 700;
  color: #0D1B2A;
  margin: 0 0 3px;
}

.stg-sec-sub {
  font-size: 12px;
  color: #9CA3AF;
  margin-bottom: 20px;
}

/* ── Tarjeta base ──────────────────────────────────────────── */
.stg-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  padding: 20px;
  margin-bottom: 16px;
}

.stg-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #0D1B2A;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #F3F4F6;
}

/* ── Formulario ───────────────────────────────────────────── */
.stg-field { margin-bottom: 14px; }

.stg-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
}

.stg-input {
  width: 100%;
  border: 1.5px solid #E5E7EB;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color .15s;
  color: #0D1B2A;
  background: #fff;
}

.stg-input:focus { border-color: var(--cp); }
.stg-input[readonly] { background: #F9FAFB; color: #9CA3AF; cursor: default; }

.stg-select {
  width: 100%;
  border: 1.5px solid #E5E7EB;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color .15s;
  color: #0D1B2A;
  background: #fff;
  cursor: pointer;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.stg-select:focus { border-color: var(--cp); }

.stg-field-err {
  font-size: 11px;
  color: #DC2626;
  margin-top: 4px;
  display: none;
}

.stg-field-hint {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 4px;
}

/* ── Botones ──────────────────────────────────────────────── */
.stg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}

.stg-btn-primary { background: var(--cp); color: #fff; }
.stg-btn-primary:hover { opacity: .82; }

.stg-btn-secondary {
  background: #F3F4F6;
  color: #374151;
  border: 1.5px solid #E5E7EB;
}

.stg-btn-secondary:hover { background: #E9EAEC; }

.stg-btn-danger {
  background: #FEF2F2;
  color: #DC2626;
  border: 1.5px solid #FCA5A5;
}

.stg-btn-danger:hover { background: #DC2626; color: #fff; border-color: #DC2626; }

.stg-btn-sm { padding: 5px 12px; font-size: 11px; border-radius: 6px; }

.stg-btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ── Tablas ───────────────────────────────────────────────── */
.stg-table { width: 100%; border-collapse: collapse; }
.stg-table thead tr { background: #F9FAFB; }

.stg-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid #E5E7EB;
}

.stg-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #F3F4F6;
  font-size: 13px;
  color: #374151;
  vertical-align: middle;
}

.stg-table tr:last-child td { border-bottom: none; }
.stg-table tbody tr:hover td { background: #FAFBFF; }

/* ── Badges ───────────────────────────────────────────────── */
.stg-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.stg-badge-green  { background: #DCFCE7; color: #16A34A; }
.stg-badge-red    { background: #FEF2F2; color: #DC2626; }
.stg-badge-blue   { background: var(--cp-light); color: var(--cp); }
.stg-badge-gray   { background: #F3F4F6; color: #6B7280; }
.stg-badge-amber  { background: #FEF9C3; color: #92400E; }
.stg-badge-violet { background: #EDE9FE; color: #7C3AED; }

/* ── Toggle ───────────────────────────────────────────────── */
.stg-toggle {
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: #D1D5DB;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
  position: relative;
}

.stg-toggle.on { background: var(--cp); }

.stg-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.stg-toggle.on::after { left: 21px; }

/* ── Matriz de permisos ────────────────────────────────────── */
.stg-perm-tbl { width: 100%; border-collapse: collapse; }

.stg-perm-tbl th,
.stg-perm-tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid #F3F4F6;
}

.stg-perm-tbl thead th {
  font-size: 11px;
  font-weight: 700;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #F9FAFB;
  text-align: center;
}

.stg-perm-tbl thead th:first-child { text-align: left; }
.stg-perm-tbl td { font-size: 13px; text-align: center; vertical-align: middle; }
.stg-perm-tbl td:first-child { text-align: left; font-weight: 500; color: #0D1B2A; }
.stg-perm-tbl tr:last-child td { border-bottom: none; }
.stg-perm-tbl input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--cp); cursor: pointer; }
.stg-perm-na { color: #D1D5DB; font-size: 18px; }

/* ── Tarjetas de módulos ───────────────────────────────────── */
.stg-mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 14px;
}

.stg-mod-card {
  background: #fff;
  border: 1.5px solid #E5E7EB;
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s;
}

.stg-mod-card.active {
  border-color: #C7D2FE;
  box-shadow: 0 0 0 3px rgba(var(--cp-rgb), .06);
}

.stg-mod-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--cp-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stg-mod-icon svg { width: 20px; height: 20px; stroke-width: 1.75; }

.stg-mod-name { font-size: 14px; font-weight: 700; color: #0D1B2A; }
.stg-mod-desc { font-size: 12px; color: #6B7280; line-height: 1.5; }

/* ── Tarjetas de roles ─────────────────────────────────────── */
.stg-roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stg-role-card {
  background: #fff;
  border: 1.5px solid #E5E7EB;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s;
}

.stg-role-card:hover { border-color: #C7D2FE; }
.stg-role-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Sección Logo ──────────────────────────────────────────── */
.stg-logo-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.stg-logo-prev {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  border: 2px solid #E5E7EB;
  background: #F9FAFB;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  overflow: hidden;
  flex-shrink: 0;
}

.stg-logo-prev img { width: 100%; height: 100%; object-fit: contain; }

/* ── Modales ──────────────────────────────────────────────── */
.stg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  overflow-y: auto;
  animation: stgFadeIn .15s ease;
}

.stg-modal {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  width: 520px;
  max-width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  position: relative;
  box-sizing: border-box;
  margin: auto;
}

.stg-modal-wide { width: 620px; }
.stg-modal-sm   { width: 380px; text-align: center; }

.stg-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #9CA3AF;
  padding: 4px 7px;
  line-height: 1;
  border-radius: 6px;
  transition: background .12s;
}

.stg-modal-close:hover { background: #F3F4F6; }

.stg-modal-title { font-size: 17px; font-weight: 800; color: #0D1B2A; margin: 0 0 4px; }
.stg-modal-sub   { font-size: 12px; color: #9CA3AF; margin-bottom: 22px; }
.stg-modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Chips de roles ───────────────────────────────────────── */
.stg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.stg-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid #E5E7EB;
  background: #F9FAFB;
  color: #374151;
  transition: all .12s;
  user-select: none;
}

.stg-chip.selected { background: var(--cp-light); border-color: var(--cp); color: var(--cp); }
.stg-chip:hover:not(.selected) { border-color: #C7D2FE; }

/* ── Acceso denegado ──────────────────────────────────────── */
.stg-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: #9CA3AF;
}

/* ── Mi Perfil: Avatar ────────────────────────────────────── */
.stg-profile-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #F3F4F6;
}

.stg-av-large {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: opacity .15s;
}

.stg-av-large:hover { opacity: .85; }
.stg-av-large img { width: 100%; height: 100%; object-fit: cover; }

.stg-av-large-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  opacity: 0;
  border-radius: 50%;
  transition: opacity .15s;
}

.stg-av-large:hover .stg-av-large-overlay { opacity: 1; }

/* ── Selector de color de avatar ──────────────────────────── */
.stg-color-dots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.stg-color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform .12s, border-color .12s;
  flex-shrink: 0;
}

.stg-color-dot:hover  { transform: scale(1.15); }
.stg-color-dot.active { border-color: #0D1B2A; transform: scale(1.1); }

/* ── Indicador de fuerza de contraseña ────────────────────── */
.stg-pwd-strength {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.stg-pwd-bar {
  height: 3px;
  flex: 1;
  border-radius: 2px;
  background: #E5E7EB;
  transition: background .2s;
}

.stg-pwd-bar.weak   { background: #EF4444; }
.stg-pwd-bar.medium { background: #F59E0B; }
.stg-pwd-bar.strong { background: #10B981; }

.stg-pwd-label {
  font-size: 10px;
  font-weight: 600;
  margin-top: 4px;
}

/* ── Apariencia: Tarjetas de tema ─────────────────────────── */
.stg-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stg-theme-card {
  background: #fff;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.stg-theme-card:hover { border-color: #C7D2FE; box-shadow: 0 2px 8px rgba(0,0,0,.07); }

.stg-theme-card.active {
  border-color: var(--cp);
  box-shadow: 0 0 0 3px rgba(var(--cp-rgb), .12);
}

.stg-theme-swatch {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.stg-theme-swatch-split {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.stg-theme-name {
  font-size: 11px;
  font-weight: 700;
  color: #374151;
}

.stg-theme-active-tick {
  font-size: 11px;
  color: var(--cp);
  font-weight: 700;
  min-height: 16px;
}

/* ── Color picker personalizado ───────────────────────────── */
.stg-custom-color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #F9FAFB;
  border-radius: 10px;
  border: 1.5px solid #E5E7EB;
}

.stg-color-input {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: none;
}

/* ── Divisor ──────────────────────────────────────────────── */
.stg-divider {
  height: 1px;
  background: #F3F4F6;
  margin: 18px 0;
}

/* ── Info box ─────────────────────────────────────────────── */
.stg-info-box {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--cp-light);
  border-radius: 8px;
  border-left: 3px solid var(--cp);
  font-size: 12px;
  color: #374151;
  line-height: 1.5;
  margin-top: 12px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .stg-body { flex-direction: column; padding: 12px 14px 24px; }
  .stg-nav {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    position: static;
    scrollbar-width: none;
  }
  .stg-nav::-webkit-scrollbar { display: none; }
  .stg-nav-group { display: none; }
  .stg-content { padding: 16px 0 0; }
  .stg-mod-grid { grid-template-columns: 1fr; }
  .stg-roles-grid { grid-template-columns: 1fr; }
  .stg-theme-grid { grid-template-columns: repeat(3, 1fr); }
  .stg-modal { width: 100% !important; }
  .stg-profile-hero { flex-direction: column; text-align: center; }
}

@keyframes stgFadeIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Sección Etiquetas ─────────────────────────────────────── */
.stg-tag-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}
.stg-tag-swatch:hover  { transform: scale(1.15); }
.stg-tag-swatch.active { border-color: #0D1B2A; transform: scale(1.1); }

/* Input pequeño para edición inline */
.stg-input-sm {
  height: 32px;
  padding: 0 9px;
  font-size: 13px;
  border: 1.5px solid #E5E7EB;
  border-radius: 7px;
  outline: none;
  transition: border-color .2s;
}
.stg-input-sm:focus { border-color: var(--cp); }

/* Botón peligro (eliminar) */
.stg-btn-danger {
  background: #FEE2E2;
  color: #DC2626;
  border: 1px solid #FECACA;
}
.stg-btn-danger:hover {
  background: #DC2626;
  color: #fff;
  border-color: #DC2626;
}
