/* Kifly 6.0 · navegación y dashboards móviles */

@media (max-width: 800px) {
  html { scroll-padding-top: 132px; }
  body { overflow-x: hidden; }

  /* Header público: siempre separado y por encima del panel administrativo. */
  .site-header {
    position: sticky !important;
    z-index: 200 !important;
    top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .1) !important;
    background: rgba(17, 20, 42, .98) !important;
    box-shadow: 0 8px 24px rgba(10, 14, 34, .16);
    backdrop-filter: blur(18px);
  }
  .site-header .header-inner {
    position: relative;
    min-height: 70px;
    padding: 10px 0;
    align-items: center;
  }
  .site-header .brand { min-width: 0; gap: 9px; }
  .site-header .brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 13px;
    background: #0d1128;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
  }
  .site-header .brand-copy { display: grid !important; min-width: 0; }
  .site-header .brand-copy strong { color: #fff !important; font-size: 1.05rem; }
  .site-header .brand-copy small { display: none !important; }

  .site-header .menu-toggle {
    display: block;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 13px;
    background: rgba(255, 255, 255, .09);
    box-shadow: none;
    cursor: pointer;
  }
  .site-header .menu-toggle span {
    height: 2px;
    margin: 5px 0;
    border-radius: 999px;
    background: #fff;
    transition: transform .2s ease, opacity .2s ease;
  }
  .site-header .menu-toggle.is-active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .site-header .menu-toggle.is-active span:nth-child(2) { opacity: 0; }
  .site-header .menu-toggle.is-active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .site-header .main-nav {
    position: absolute;
    z-index: 220;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    display: none;
    max-height: calc(100vh - 92px);
    padding: 10px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 17px;
    background: linear-gradient(145deg, #171b38, #10142c) !important;
    box-shadow: 0 24px 60px rgba(7, 10, 27, .42);
  }
  .site-header .main-nav.is-open {
    display: grid;
    gap: 5px;
    animation: kifly-mobile-menu-in .18s ease both;
  }
  .site-header .main-nav > a,
  .site-header .main-nav .nav-button {
    display: flex !important;
    align-items: center;
    width: 100%;
    min-height: 47px;
    padding: 0 14px !important;
    border: 1px solid transparent;
    border-radius: 11px;
    color: #eef0ff !important;
    background: transparent;
    text-align: left;
    font-size: .9rem;
    font-weight: 750;
  }
  .site-header .main-nav > a::after { display: none !important; }
  .site-header .main-nav > a:hover,
  .site-header .main-nav .nav-button:hover {
    border-color: rgba(160, 146, 255, .2);
    color: #fff !important;
    background: rgba(139, 92, 246, .14);
  }
  .site-header .main-nav .launcher-nav-button {
    justify-content: center;
    border-color: rgba(174, 161, 255, .28) !important;
    color: #fff !important;
    background: linear-gradient(135deg, #7659f6, #596dff) !important;
  }
  .site-header .main-nav .admin-nav-link {
    border-color: rgba(45, 212, 191, .18) !important;
    color: #7cebd8 !important;
    background: rgba(20, 184, 166, .09) !important;
  }
  .site-header .main-nav .inline-form { display: block; width: 100%; }

  /* Header del Superpanel: identidad y color propios. */
  .kf-admin-shell { display: block !important; min-height: 0; }
  .kf-admin-sidebar {
    position: sticky !important;
    z-index: 120 !important;
    top: 70px !important;
    height: auto !important;
    padding: 9px 12px !important;
    overflow: visible !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, .15) !important;
    background: linear-gradient(105deg, #5036c8, #33256f) !important;
    box-shadow: 0 10px 26px rgba(45, 30, 112, .22) !important;
  }
  .kf-admin-sidebar__head { min-height: 50px; align-items: center !important; }
  .kf-admin-logo { min-width: 0; padding: 0 !important; gap: 10px; }
  .kf-admin-logo img {
    width: 38px !important;
    height: 38px !important;
    flex: 0 0 38px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 11px;
    background: rgba(11, 15, 37, .35);
  }
  .kf-admin-logo span { min-width: 0; line-height: 1.12; }
  .kf-admin-logo strong { color: #fff; font-size: .92rem; }
  .kf-admin-logo small {
    margin-top: 4px;
    overflow: hidden;
    color: #ddd8ff;
    font-size: .69rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .kf-admin-menu-toggle {
    display: block !important;
    width: 42px;
    height: 42px;
    flex: 0 0 42px !important;
    padding: 9px;
    border-color: rgba(255, 255, 255, .22) !important;
    border-radius: 12px;
    background: rgba(10, 12, 34, .2) !important;
  }
  .kf-admin-sidebar > nav,
  .kf-admin-sidebar > .kf-admin-user { display: none !important; }
  .kf-admin-sidebar.is-open > nav {
    position: absolute;
    z-index: 125;
    top: calc(100% + 8px);
    right: 8px;
    left: 8px;
    display: grid !important;
    max-height: calc(100vh - 154px);
    margin: 0 !important;
    padding: 10px !important;
    overflow-y: auto;
    border: 1px solid rgba(151, 139, 255, .22) !important;
    border-radius: 16px;
    background: linear-gradient(150deg, #171a38, #101329) !important;
    box-shadow: 0 26px 64px rgba(8, 10, 28, .46) !important;
    animation: kifly-mobile-menu-in .18s ease both;
  }
  .kf-admin-sidebar.is-open > nav > span {
    margin: 12px 9px 5px;
    color: #888fba;
    font-size: .58rem;
    font-weight: 850;
    letter-spacing: .09em;
  }
  .kf-admin-sidebar.is-open > nav > a {
    min-height: 44px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: #d8dcf2;
    font-size: .84rem;
  }
  .kf-admin-sidebar.is-open > nav > a:hover {
    transform: none;
    border-color: rgba(139, 92, 246, .24);
    color: #fff;
    background: rgba(139, 92, 246, .15);
  }
  .kf-admin-sidebar.is-open > nav b {
    border-radius: 8px;
    color: #c9c1ff;
    background: rgba(139, 92, 246, .14);
  }
  .kf-admin-sidebar.is-open > .kf-admin-user { display: none !important; }

  /* Dashboard compacto, legible y sin desbordes. */
  .kf-admin-main {
    width: 100%;
    min-width: 0;
    padding: 18px 10px 48px !important;
    overflow: hidden;
  }
  .kf-admin-top {
    display: grid !important;
    gap: 14px;
    margin-bottom: 14px !important;
    padding: 18px;
    border: 1px solid #e2e6ef;
    border-radius: 17px;
    background: linear-gradient(145deg, #fff, #faf9ff);
    box-shadow: 0 8px 24px rgba(31, 38, 58, .05);
  }
  .kf-admin-top h1 {
    margin: 0;
    font-size: clamp(1.72rem, 7.2vw, 2.3rem) !important;
    line-height: 1.08;
    overflow-wrap: anywhere;
  }
  .kf-admin-top p { margin: 8px 0 0 !important; font-size: .86rem; line-height: 1.55; }
  .kf-admin-top__actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    width: 100%;
  }
  .kf-admin-top__actions .kf-button { width: 100%; min-height: 44px; padding: 10px 12px; }

  .kf-metrics,
  .kf-metrics--five,
  .kf-metrics--six {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
  }
  .kf-metrics--five article:last-child { grid-column: auto !important; }
  .kf-metrics article {
    min-height: 116px !important;
    padding: 15px !important;
    border-radius: 15px !important;
  }
  .kf-metrics strong { margin: 7px 0 !important; font-size: clamp(1.35rem, 6vw, 1.75rem) !important; overflow-wrap: anywhere; }
  .kf-metrics span { font-size: .76rem; }
  .kf-metrics small { font-size: .7rem; line-height: 1.35; }

  .kf-card { max-width: 100%; padding: 16px !important; border-radius: 16px !important; }
  .kf-card__head { gap: 10px; margin-bottom: 14px; }
  .kf-card__head h2 { font-size: 1.2rem; }
  .kf-card__head > a { align-self: flex-start; }
  .kf-command__grid { grid-template-columns: 1fr !important; }
  .kf-command__grid > a { min-height: 72px; padding: 13px; }
  .kf-admin-grid,
  .kf-program-workspace { grid-template-columns: minmax(0, 1fr) !important; gap: 12px !important; }
  .kf-table-wrap,
  .responsive-table { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .kf-form,
  .kf-form fieldset,
  .kf-filter { max-width: 100%; }

  /* Compatibilidad con las pantallas administrativas del diseño anterior. */
  .admin-hero { padding: 24px 0 !important; }
  .admin-hero-inner { gap: 14px; }
  .admin-hero h1 { font-size: clamp(1.8rem, 8vw, 2.4rem); }
  .admin-identity { padding: 12px; border-radius: 14px; }
  .admin-toolbar {
    position: sticky;
    z-index: 110;
    top: 70px !important;
    border-bottom: 1px solid #dedaff;
    background: #f5f3ff;
    box-shadow: 0 8px 20px rgba(61, 48, 135, .08);
  }
  .admin-toolbar-inner {
    display: flex;
    gap: 7px;
    padding: 9px 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .admin-toolbar-inner::-webkit-scrollbar { display: none; }
  .admin-toolbar-inner a {
    flex: 0 0 auto;
    min-height: 39px;
    padding: 9px 12px;
    border: 1px solid #dedaff;
    border-radius: 10px;
    background: #fff;
    white-space: nowrap;
  }
  .admin-toolbar-inner a.active { color: #fff; background: #665cff; }
  .admin-section { padding-top: 20px !important; }
}

@media (max-width: 430px) {
  .site-header .header-inner { min-height: 66px; }
  .site-header .brand-mark { width: 39px; height: 39px; flex-basis: 39px; }
  .site-header .menu-toggle { width: 41px; height: 41px; flex-basis: 41px; }
  .kf-admin-sidebar { top: 66px !important; padding-inline: 9px !important; }
  .admin-toolbar { top: 66px !important; }
  .kf-admin-main { padding-inline: 7px !important; }
  .kf-admin-top { padding: 16px 14px; }
  .kf-admin-top__actions { grid-template-columns: 1fr !important; }
  .kf-metrics,
  .kf-metrics--five,
  .kf-metrics--six { gap: 7px !important; }
  .kf-metrics article { min-height: 108px !important; padding: 13px !important; }
}

@media (max-width: 360px) {
  .kf-metrics,
  .kf-metrics--five,
  .kf-metrics--six { grid-template-columns: 1fr !important; }
}

@keyframes kifly-mobile-menu-in {
  from { opacity: 0; transform: translateY(-7px) scale(.985); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .site-header .main-nav.is-open,
  .kf-admin-sidebar.is-open > nav { animation: none; }
}
