/* ============================================================================
   OFICINA RUBIKU · estilo consolidado y celular (28-oct-2026)
   Pedido del fundador: «todo se pueda gestionar desde el celular», rápido y profesional, con la vista
   despejada; y consolidar el estilo Rubiku en oscuro (sin colores ni piezas genéricas).
   Va DESPUÉS de superadmin.css. La hoja compartida con Go (/go/css/RubikuOS/main.css) NO se toca:
   todo se ajusta aquí con body.sa-rubiku / html.rk-phone (lo pone /go/js/core/device_profile.js).
   La parte de JS (tablas → tarjetas, volver en vistas divididas) está en js/os/oficina_movil.js.
   ============================================================================ */

/* ---------------------------------------------------------------- ventana: cabecera y botones
   Antes: semáforo genérico (amarillo, verde, rojo) y la X oscura sobre oscuro (la regla del botón de
   cerrar de los modales le ganaba). Ahora: cabecera violeta de Rubiku y tres botones de vidrio iguales;
   solo al pasar o tocar se tiñen (violeta; la X, rojo de Rubiku). */
body.sa-rubiku .window-header {
    background: linear-gradient(135deg, #3b1a78 0%, #1a1033 70%);
    border-bottom: 0;
}

body.sa-rubiku .os-window::before {
    background: radial-gradient(circle at top left, rgba(255, 255, 255, .07), transparent 35%);
}

body.sa-rubiku .window-title { color: #fff; letter-spacing: .01em; }

body.sa-rubiku .window-controls { gap: 8px; align-items: center; }

body.sa-rubiku .win-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    padding: 0;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .16);
    color: #ebe6ff;
    transition: background .15s, border-color .15s, color .15s;
}

body.sa-rubiku .win-btn i,
body.sa-rubiku .window-controls:hover .win-btn i {
    font-size: 13px;
    opacity: 1;
    color: inherit;
}

body.sa-rubiku .win-btn:hover,
body.sa-rubiku .win-btn:focus-visible {
    background: rgba(157, 123, 255, .35);
    border-color: rgba(180, 140, 255, .7);
    color: #fff;
}

body.sa-rubiku .win-btn.btn-close:hover,
body.sa-rubiku .win-btn.btn-close:focus-visible,
body.sa-rubiku .win-btn.btn-close:active {
    background: #ff4d6a;
    border-color: #ff4d6a;
    color: #fff;
}

/* ---------------------------------------------------------------- menú de apps
   El alfiler de las apps ancladas y la lupa venían en amarillo (main.css, compartido con Go): en la oficina, violeta */
body.sa-rubiku .hub-btn-pin.pinned { color: #e2d9ff; background: rgba(157, 123, 255, .32); border-color: rgba(180, 140, 255, .6); }
body.sa-rubiku .hub-search-box i { color: #b48cff; }

/* ---------------------------------------------------------------- volver (vistas divididas) */
.sa-split-back {
    display: none;
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 10px;
    border: 1px solid var(--sa-border-strong);
    background: var(--sa-panel-2);
    color: var(--sa-text);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
}

/* ============================================================================
   📱 CELULAR (html.rk-phone)
   La ventana del celular va con zoom .8 (main.css): las medidas de aquí ya cuentan con eso.
   ============================================================================ */

/* Barra inferior más baja: la ventana gana alto (el logo vivo lo pone rubiku_logo.js) */
html.rk-phone body.sa-rubiku .os-taskbar {
    min-height: 60px !important;
    padding-top: 6px !important;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Con una ventana abierta, main.css (.compressed) le da 200 px a cada lado: en un celular de 390 px no quedaba
   espacio para las apps del medio. Y su ancho mínimo (400 px) la sacaba de la pantalla. */
html.rk-phone body.sa-rubiku .os-taskbar { min-width: 0 !important; }
html.rk-phone body.sa-rubiku .os-taskbar :is(.taskbar-left, .taskbar-right) { width: auto !important; }
html.rk-phone body.sa-rubiku .taskbar-center { margin: 0 4px !important; }

html.rk-phone body.sa-rubiku .dock-item { width: 46px !important; height: 46px !important; }
html.rk-phone body.sa-rubiku .os-dock { gap: 6px !important; }

html.rk-phone body.sa-rubiku .os-window {
    height: calc((100vh - 60px - env(safe-area-inset-bottom, 0px)) * 1.25) !important;
    height: calc((100dvh - 60px - env(safe-area-inset-bottom, 0px)) * 1.25) !important;
}

html.rk-phone body.sa-rubiku .os-hub {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    height: calc(100dvh - 60px - env(safe-area-inset-bottom, 0px)) !important;
}

/* Cabecera: maximizar no aplica (en el celular la app ya ocupa todo); quedan minimizar y cerrar, grandes */
html.rk-phone body.sa-rubiku .window-header { min-height: 58px !important; }
html.rk-phone body.sa-rubiku .win-btn.btn-max { display: none !important; }
html.rk-phone body.sa-rubiku .win-btn { width: 38px !important; height: 38px !important; }
html.rk-phone body.sa-rubiku .win-btn i { font-size: 16px !important; }
html.rk-phone body.sa-rubiku .window-title { font-size: 1rem !important; }

/* Pestañas: más compactas y deslizables */
html.rk-phone .sa-tabs-bar { padding: 6px 8px 0 !important; gap: 2px !important; }
html.rk-phone .sa-tab { padding: 10px 12px 12px !important; font-size: .9rem !important; }

/* Encabezados de cada app: el título ya está en la ventana. Sin el ícono grande y con la explicación
   en una sola línea (se lee completa en la guía de la app) */
html.rk-phone .window-body :is(h2, h3) + p,
html.rk-phone .window-body .lc-head p,
html.rk-phone .window-body .rkin-head p {
    display: -webkit-box !important;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden !important;
}

html.rk-phone .window-body [style*="width:42px"][style*="height:42px"],
html.rk-phone .window-body [style*="width: 42px"][style*="height: 42px"] { display: none !important; }

html.rk-phone .window-body [style*="padding:20px 24px"],
html.rk-phone .window-body [style*="padding: 20px 24px"] { padding: 12px !important; gap: 12px !important; }

html.rk-phone .window-body [style*="padding:16px 24px"],
html.rk-phone .window-body [style*="padding: 16px 24px"] { padding: 10px 12px !important; gap: 8px !important; }

/* Cifras: en vez de una cuadrícula que llena la pantalla, una franja que se desliza de lado.
   Cada cifra: número arriba, nombre abajo (la explicación larga se queda en computador). */
html.rk-phone :is(.sa-kpis, .lc-kpis, .rkin-kpis, .rkc-kpis, .rks-kpis, .rki-grid, .rki-kpis) {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 8px !important;
    margin-bottom: 0 !important;
    padding-bottom: 2px;
    flex: none !important; /* dentro de columnas flex con scroll se encogía hasta casi desaparecer */
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

html.rk-phone :is(.sa-kpis, .lc-kpis, .rkin-kpis, .rkc-kpis, .rks-kpis, .rki-grid, .rki-kpis)::-webkit-scrollbar { display: none; }

html.rk-phone :is(.sa-kpis, .lc-kpis, .rkin-kpis, .rkc-kpis, .rks-kpis, .rki-grid, .rki-kpis) > * {
    flex: 0 0 auto !important;
    min-width: 108px !important;
    max-width: 62vw !important;
    padding: 9px 13px !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    margin: 0 !important;
    gap: 1px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    scroll-snap-align: start;
    text-align: left !important;
}

/* número */
html.rk-phone :is(.lc-kpi, .rkin-kpi, .rkc-kpi, .rks-kpi, .rki-card) b,
html.rk-phone .sa-kpis > * > div:nth-child(2) {
    order: -1;
    font-size: 1.3rem !important;
    line-height: 1.15 !important;
    margin: 0 !important;
    white-space: nowrap;
}

/* nombre */
html.rk-phone :is(.lc-kpi, .rkin-kpi, .rkc-kpi, .rks-kpi) span,
html.rk-phone .rki-card .t,
html.rk-phone .sa-kpis > * > div:first-child {
    font-size: .8rem !important;
    white-space: nowrap;
    margin: 0 !important;
}

/* explicación e ícono decorativo: fuera en el celular */
html.rk-phone :is(.rkin-kpi, .rki-card) small,
html.rk-phone .sa-kpis > * > div:nth-child(3),
html.rk-phone .sa-kpis > * > div:first-child > i { display: none !important; }

html.rk-phone .rki-card .t i { font-size: .95rem !important; }html.rk-phone .rki-card.zero { opacity: .6; }

/* Tablas → tarjetas (oficina_movil.js pone en cada celda el nombre de su columna) */
html.rk-phone .window-body :is(.table-container, [style*="overflow-x"]):has(> table.sa-cardtable) { overflow: visible !important; }

html.rk-phone table.sa-cardtable,
html.rk-phone table.sa-cardtable tbody {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
}

html.rk-phone table.sa-cardtable thead { display: none !important; }

html.rk-phone table.sa-cardtable tr {
    display: block !important;
    padding: 10px 14px !important;
    border-bottom: 1px solid var(--sa-border) !important;
}

html.rk-phone table.sa-cardtable tr:last-child { border-bottom: 0 !important; }

html.rk-phone table.sa-cardtable td {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex-wrap: wrap !important;
    gap: 6px 10px !important;
    padding: 3px 0 !important;
    min-height: 30px;
    border: 0 !important;
    width: auto !important;
    max-width: none !important;
    text-align: right !important;
    white-space: normal !important;
    background: transparent !important;
}

html.rk-phone table.sa-cardtable td::before {
    content: attr(data-label);
    flex: none;
    max-width: 45%;
    margin-right: auto;
    text-align: left;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--sa-text-3);
}

html.rk-phone table.sa-cardtable td > * { min-width: 0; }

html.rk-phone table.sa-cardtable td:first-child,
html.rk-phone table.sa-cardtable td[colspan] {
    display: block !important;
    text-align: left !important;
    padding-bottom: 6px !important;
    font-size: 1rem;
}

html.rk-phone table.sa-cardtable td[colspan] { text-align: center !important; }

html.rk-phone table.sa-cardtable :is(td:first-child, td[colspan], td[data-label=""])::before { display: none; }
html.rk-phone table.sa-cardtable td[data-label=""] { justify-content: flex-end !important; }

/* Vistas divididas (lista + detalle, p. ej. Soporte → Casos): una a la vez, con «volver» */
html.rk-phone .sa-split > .sa-split-list {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    border-right: 0 !important;
}

html.rk-phone .sa-split > .sa-split-detail { display: none !important; }
html.rk-phone .sa-split.is-detail > .sa-split-list { display: none !important; }
html.rk-phone .sa-split.is-detail > .sa-split-detail { display: flex !important; width: 100% !important; }
html.rk-phone .sa-split-back { display: inline-flex; }

/* Formularios cómodos para el dedo (y sin el zoom automático del iPhone, que pide 16 px) */
html.rk-phone body.sa-rubiku .window-body :is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea) {
    min-height: 44px;
    font-size: 1rem !important;
}

html.rk-phone .window-body [style*="width:260px"],
html.rk-phone .window-body [style*="width:220px"],
html.rk-phone .window-body [style*="width: 260px"] { width: 100% !important; }

/* Ventanas emergentes: suben desde abajo, a todo el ancho, como en una app del celular */
html.rk-phone body.sa-rubiku .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
}

html.rk-phone body.sa-rubiku .modal {
    zoom: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90dvh !important;
    margin: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)) !important;
}

html.rk-phone body.sa-rubiku .modal-actions {
    position: sticky;
    bottom: calc(-18px - env(safe-area-inset-bottom, 0px));
    margin: 18px -16px calc(-18px - env(safe-area-inset-bottom, 0px)) !important;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    background: var(--sa-bg);
}

html.rk-phone body.sa-rubiku .modal-actions > * { flex: 1; justify-content: center; min-height: 46px; }
