/**
 * CR-013: SATE Modern UI
 * Estilos compartidos para login, home y componentes modernizados.
 */
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css");

/* ── Variables ────────────────────────────────────── */
:root {
  --sate-blue: #1a4f8b;
  --sate-blue-light: #2c6fbb;
  --sate-blue-dark: #0d3460;
  --sate-orange: #f8b42f;
  --sate-gray: #f5f6fa;
  --sate-text: #2d3436;
  --sate-text-light: #636e72;
  --sate-border: #dfe6e9;
  --sate-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --sate-radius: 8px;
}

/* ── Login Page ───────────────────────────────────── */
.sate-login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--sate-blue-dark) 0%, var(--sate-blue) 50%, var(--sate-blue-light) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 20px;
  box-sizing: border-box;
}

.sate-login-card {
  background: #fff;
  border-radius: var(--sate-radius);
  box-shadow: var(--sate-shadow);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.sate-login-card img.sate-logo {
  max-width: 220px;
  height: auto;
  margin-bottom: 28px;
}

.sate-login-card h2 {
  font-size: 18px;
  color: var(--sate-text);
  margin: 0 0 24px 0;
  font-weight: 600;
}

.sate-login-error {
  background: #ffeaea;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  text-align: left;
}

.sate-form-group {
  margin-bottom: 16px;
  text-align: left;
}

.sate-form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--sate-text-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sate-form-group input,
.sate-form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--sate-border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--sate-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  font-family: inherit;
  background: #fff;
}

.sate-form-group input:focus,
.sate-form-group select:focus {
  outline: none;
  border-color: var(--sate-blue);
  box-shadow: 0 0 0 3px rgba(26, 79, 139, 0.12);
}

.sate-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
  margin-top: 8px;
}

.sate-btn-primary {
  background: var(--sate-blue);
  color: #fff;
}

.sate-btn-primary:hover {
  background: var(--sate-blue-light);
}

.sate-btn-primary:active {
  transform: scale(0.98);
}

.sate-login-footer {
  margin-top: 28px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}

/* ── Password Strength Banner ─────────────────────── */
.sate-pwd-banner {
  background: linear-gradient(90deg, #fff3cd, #ffeaa7);
  border: 1px solid #f0c36d;
  border-radius: var(--sate-radius);
  padding: 14px 20px;
  margin: 10px auto;
  max-width: 700px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
  font-size: 13px;
  color: #856404;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.sate-pwd-banner .sate-pwd-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.sate-pwd-banner .sate-pwd-text {
  flex: 1;
}

.sate-pwd-banner .sate-pwd-text strong {
  display: block;
  margin-bottom: 2px;
  color: #664d03;
}

.sate-pwd-banner .sate-btn-change {
  background: var(--sate-blue);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
}

.sate-pwd-banner .sate-btn-change:hover {
  background: var(--sate-blue-light);
}

.sate-pwd-banner .sate-btn-dismiss {
  background: none;
  border: none;
  color: #856404;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  flex-shrink: 0;
  opacity: 0.6;
}

.sate-pwd-banner .sate-btn-dismiss:hover {
  opacity: 1;
}

/* ── Password Hint (compact) ──────────────────────── */
.sate-pwd-hint {
  background: #fff3cd;
  color: #856404;
  text-align: center;
  padding: 6px 16px;
  font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
  font-size: 13px;
  border-bottom: 1px solid #f0c36d;
}

.sate-pwd-hint a {
  color: var(--sate-blue);
  font-weight: 600;
  text-decoration: underline;
}

.sate-pwd-hint button {
  background: none;
  border: none;
  color: #856404;
  cursor: pointer;
  font-size: 16px;
  margin-left: 12px;
  opacity: 0.6;
  vertical-align: middle;
}

.sate-pwd-hint button:hover {
  opacity: 1;
}

/* ── Staging Environment Banner ───────────────────── */
.sate-staging-bar {
  background: #e74c3c;
  color: #fff;
  text-align: center;
  padding: 6px 12px;
  font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.sate-staging-bar-spacer {
  height: 30px;
}

/* Login page: full-width bar */
.sate-staging-badge {
  background: #e74c3c;
  color: #fff;
  display: block;
  padding: 8px 12px;
  font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ── Home Layout ─────────────────────────────────── */
.sate-topbar {
  background: linear-gradient(135deg, var(--sate-blue-dark), var(--sate-blue));
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
  position: sticky;
  top: 0;
  z-index: 9999;
}

.sate-topbar-logo {
  height: 36px;
  margin-right: 14px;
}

.sate-topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-right: auto;
}

.sate-topbar-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.sate-topbar-user-info {
  text-align: right;
  line-height: 1.35;
}

.sate-topbar-user-name {
  font-weight: 600;
  font-size: 13px;
}

.sate-topbar-user-role {
  font-size: 11px;
  opacity: 0.75;
}

.sate-topbar-logout,
.sate-topbar-toggle {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.2s;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.sate-topbar-logout:hover,
.sate-topbar-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  text-decoration: none;
}

.sate-home-body {
  background: var(--sate-gray);
  min-height: calc(100vh - 56px);
  font-family: 'Segoe UI', Tahoma, Geneva, sans-serif;
}

.sate-home-layout {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
  align-items: flex-start;
}

.sate-home-main {
  flex: 1;
  min-width: 0;
}

.sate-home-sidebar {
  width: 300px;
  flex-shrink: 0;
  position: sticky;
  top: 76px;
}

.sate-quick-card {
  background: #fff;
  border-radius: var(--sate-radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 16px;
  margin-bottom: 12px;
}

.sate-quick-card h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--sate-blue);
  margin: 0 0 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sate-quick-card input[type="text"],
.sate-quick-card input[type="number"] {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--sate-border);
  border-radius: 5px;
  font-size: 13px;
  box-sizing: border-box;
  margin-bottom: 8px;
  font-family: inherit;
}

.sate-quick-card input[type="text"]:focus,
.sate-quick-card input[type="number"]:focus {
  outline: none;
  border-color: var(--sate-blue);
  box-shadow: 0 0 0 2px rgba(26, 79, 139, 0.1);
}

.sate-quick-card input[type="submit"],
.sate-quick-card button[type="submit"] {
  background: var(--sate-blue);
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: background 0.2s;
}

.sate-quick-card input[type="submit"]:hover,
.sate-quick-card button[type="submit"]:hover {
  background: var(--sate-blue-light);
}

/* Make existing content area cleaner */
.sate-home-main .x-box-tl,
.sate-home-main .x-box-tr,
.sate-home-main .x-box-tc,
.sate-home-main .x-box-bl,
.sate-home-main .x-box-br,
.sate-home-main .x-box-bc {
  display: none;
}

.sate-home-main .x-box-ml,
.sate-home-main .x-box-mr {
  background: none !important;
  padding: 0 !important;
}

.sate-home-main .x-box-mc {
  background: #fff;
  border-radius: var(--sate-radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 20px;
}

/* Responsive: sidebar below on small screens */
@media (max-width: 900px) {
  .sate-home-layout {
    flex-direction: column;
  }
  .sate-home-sidebar {
    width: 100%;
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }
  .sate-quick-card {
    flex: 1;
    min-width: 250px;
  }
}

/* ── Navigation Button Grid ─────────────────────── */
.sate-btn-grid {
  background: #fff;
  border-radius: var(--sate-radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}

/* Flatten table structure inside grid */
.sate-btn-grid table,
.sate-btn-grid tbody,
.sate-btn-grid tr,
.sate-btn-grid td,
.sate-btn-grid > span {
  display: contents !important;
}

/* Hide spacer BR tags leaked from display:contents cells */
.sate-btn-grid td > br {
  display: none;
}

/* Style all links as cards */
.sate-btn-grid a[href] {
  display: inline-flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px 6px;
  background: #fff;
  border: 1.5px solid var(--sate-border);
  border-radius: var(--sate-radius);
  text-decoration: none !important;
  color: var(--sate-text) !important;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
  min-height: 78px;
  width: 120px;
  cursor: pointer;
  flex-shrink: 0;
}

.sate-btn-grid a[href]:hover {
  border-color: var(--sate-blue);
  background: #f0f5ff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(26, 79, 139, 0.12);
  text-decoration: none !important;
  color: var(--sate-text) !important;
}

/* Icon prepended by JS */
.sate-btn-grid a .sate-icon {
  font-size: 22px;
  color: var(--sate-blue);
  flex-shrink: 0;
}

/* Hide old button images */
.sate-btn-grid a img {
  display: none !important;
}

/* Override Bootstrap btn classes inside grid */
.sate-btn-grid a.btn,
.sate-btn-grid a.btn-primary,
.sate-btn-grid a.btn-danger,
.sate-btn-grid a.btn-warning,
.sate-btn-grid a.btn-sm {
  background: #fff !important;
  border: 1.5px solid var(--sate-border) !important;
  color: var(--sate-text) !important;
  font-size: 11px !important;
  padding: 12px 6px !important;
  width: 120px !important;
  min-height: 78px !important;
  display: inline-flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  line-height: 1.3 !important;
}

.sate-btn-grid a.btn:hover,
.sate-btn-grid a.btn-primary:hover,
.sate-btn-grid a.btn-danger:hover,
.sate-btn-grid a.btn-warning:hover {
  border-color: var(--sate-blue) !important;
  background: #f0f5ff !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(26, 79, 139, 0.12);
}

/* Danger-styled button icons */
.sate-btn-grid a.sate-btn-danger .sate-icon { color: #e74c3c; }
.sate-btn-grid a.sate-btn-warning .sate-icon { color: #f39c12; }

@media (max-width: 600px) {
  .sate-btn-grid a[href],
  .sate-btn-grid a.btn {
    width: 100px !important;
    min-height: 70px !important;
    font-size: 10px !important;
  }
}

/* ── Classic Mode (toggle) ───────────────────────── */
.sate-btn-grid.sate-classic {
  display: block;
}

.sate-btn-grid.sate-classic table {
  display: table !important;
  width: 100%;
}

.sate-btn-grid.sate-classic tbody {
  display: table-row-group !important;
}

.sate-btn-grid.sate-classic tr {
  display: table-row !important;
}

.sate-btn-grid.sate-classic td {
  display: table-cell !important;
  text-align: left;
  vertical-align: top;
  padding: 4px;
}

.sate-btn-grid.sate-classic td > br {
  display: block;
}

.sate-btn-grid.sate-classic a[href] {
  display: inline !important;
  flex-direction: unset;
  align-items: unset;
  justify-content: unset;
  gap: unset;
  padding: unset;
  background: transparent !important;
  border: none !important;
  border-radius: unset;
  color: inherit !important;
  font-size: inherit;
  font-weight: inherit;
  text-align: unset;
  line-height: unset;
  min-height: unset;
  width: auto !important;
  transition: none;
}

.sate-btn-grid.sate-classic a[href]:hover {
  transform: none;
  box-shadow: none;
  background: transparent !important;
}

.sate-btn-grid.sate-classic a img {
  display: inline !important;
}

.sate-btn-grid.sate-classic a .sate-icon {
  display: none !important;
}

/* Hide injected text labels in classic mode — only images, like production */
.sate-btn-grid.sate-classic a .sate-btn-label {
  display: none !important;
}

/* Restore Bootstrap btn styles in classic mode */
.sate-btn-grid.sate-classic a.btn {
  display: inline-block !important;
  padding: .25rem .5rem !important;
  width: auto !important;
  min-height: auto !important;
  line-height: 1.5 !important;
  font-size: .875rem !important;
  border-radius: .2rem !important;
}

.sate-btn-grid.sate-classic a.btn-primary {
  background: #007bff !important;
  border: 1px solid #007bff !important;
  color: #fff !important;
}

.sate-btn-grid.sate-classic a.btn-danger {
  background: #dc3545 !important;
  border: 1px solid #dc3545 !important;
  color: #fff !important;
}

.sate-btn-grid.sate-classic a.btn-warning {
  background: #ffc107 !important;
  border: 1px solid #ffc107 !important;
  color: #212529 !important;
}

/* ============================================================
   CR-013: Sectioned home with drag-and-drop (sateHomeSections.js)
   ============================================================ */

.sate-sections {
  max-width: 1400px;
  margin: 12px auto 32px;
  padding: 0 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.sate-section {
  background: #fff;
  border: 1px solid #e4e7eb;
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}

.sate-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  background: #f8fafc;
  border-bottom: 1px solid #e4e7eb;
  transition: background .15s;
}

.sate-section-header:hover {
  background: #f1f5f9;
}

.sate-section-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1e3a5f;
  letter-spacing: .2px;
}

.sate-section-count {
  display: inline-block;
  min-width: 22px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: #e4e7eb;
  border-radius: 10px;
  text-align: center;
}

.sate-section-toggle {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #64748b;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  transition: transform .2s;
}

.sate-section-collapsed .sate-section-toggle {
  transform: rotate(-90deg);
}

.sate-section-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
  padding: 16px;
  transition: max-height .3s, padding .3s, opacity .2s;
}

.sate-section-collapsed .sate-section-body {
  max-height: 0;
  padding: 0 16px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.sate-section-admin .sate-section-header {
  background: #fafaf9;
}

.sate-section-admin .sate-section-header h3 {
  color: #475569;
}

.sate-section-admin .sate-section-header h3::before {
  content: '\f4cb'; /* bi-sliders */
  font-family: 'bootstrap-icons';
  margin-right: 8px;
  font-size: 13px;
  opacity: .7;
}

/* Tile — container that holds the existing <a> */
.sate-tile {
  cursor: grab;
}

.sate-tile:active {
  cursor: grabbing;
}

.sate-tile > a[href] {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px !important;
  min-height: 92px;
  width: 100% !important;
  background: #fff !important;
  border: 1px solid #e4e7eb !important;
  border-radius: 8px !important;
  color: #1e3a5f !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  text-align: center !important;
  text-decoration: none !important;
  line-height: 1.35 !important;
  transition: border-color .15s, box-shadow .15s, transform .1s, background .15s;
  box-sizing: border-box;
}

.sate-tile > a[href]:hover {
  border-color: #94a3b8 !important;
  background: #f8fafc !important;
  box-shadow: 0 2px 6px rgba(30, 58, 95, .08);
  transform: none;
}

.sate-tile > a[href] .sate-icon {
  font-size: 22px;
  color: #1e3a5f;
  margin: 0;
}

.sate-tile > a[href] .sate-btn-label {
  display: block;
  color: #1e3a5f;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.sate-tile > a[href] img {
  display: none !important;
}

.sate-tile > a[href] br {
  display: block;
  content: "";
  margin: 0;
  line-height: 0;
}

.sate-tile > a[href],
.sate-tile > a[href] span,
.sate-tile > a[href] .sate-btn-label {
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  max-width: 100%;
}

/* Neutralize Bootstrap btn colors inside tiles — only 2-color palette */
.sate-tile > a.btn,
.sate-tile > a.btn-primary,
.sate-tile > a.btn-success,
.sate-tile > a.btn-warning,
.sate-tile > a.btn-danger {
  background: #fff !important;
  border: 1px solid #e4e7eb !important;
  color: #1e3a5f !important;
}

/* Drag states */
.sate-tile-ghost {
  opacity: .35;
}

.sate-tile-chosen > a[href] {
  box-shadow: 0 6px 18px rgba(30, 58, 95, .2);
  border-color: #1e3a5f !important;
}

/* View toggle: sections vs legacy grid */
body.sate-has-sections.sate-view-modern .sate-btn-grid {
  display: none !important;
}
body.sate-has-sections.sate-view-classic .sate-sections {
  display: none !important;
}

@media (max-width: 700px) {
  .sate-section-body {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    padding: 12px;
  }
  .sate-tile > a[href] {
    min-height: 78px;
    padding: 10px 6px !important;
    font-size: 11px !important;
  }
}
