/* ==========================================================================
   Torokoto + Muse — capa de personalización sobre el tema Studio v7.0
   (SeanTheme). El tema vive en vendor.min.css + app.min.css y pone toda
   la base (Bootstrap 5.3, Font Awesome 7, layout, componentes).
   Aquí solo van las reglas propias del admin que el tema no cubre.
   ========================================================================== */

/* --- Marca "T" + nombre (header y login) --- */
.logo-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #111;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    flex: 0 0 auto;
}
.brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--bs-body-color);
    line-height: 1.2;
}
.brand span { color: var(--bs-theme); }
.brand-logo {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}
.brand-logo:hover { text-decoration: none; }

/* --- Avatar con inicial (menú de usuario del header y sidebar) --- */
.tm-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bs-theme);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex: 0 0 auto;
}
.tm-avatar-sm { width: 24px; height: 24px; font-size: 12px; }

/* --- Miniatura con inicial en la lista de productos --- */
.tm-thumb {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bs-gray-100);
    color: var(--bs-body-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex: 0 0 auto;
}

/* --- Barra de selección masiva (lista de productos) --- */
.tm-bulk-bar {
    display: none;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    background: var(--bs-light);
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
}
.tm-bulk-bar.show { display: flex; }
.table > tbody > tr.selected { --bs-table-bg: rgba(0, 0, 0, .045); }

/* --- Paginación tipo píldora --- */
.tm-pager {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    background: var(--bs-body-bg);
}
.tm-pager a { text-decoration: none; font-weight: 700; }
.tm-pager .disabled { color: var(--bs-secondary-color); }

/* --- Icono de checklist del dashboard --- */
.tm-check-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bs-gray-200);
    color: var(--bs-body-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex: 0 0 auto;
}
.tm-check-done { background: var(--bs-success); color: #fff; }

/* --- Bloque plegable de tienda sin publicar (editar producto) --- */
.tm-tienda-bloque {
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
    padding: 1rem;
    margin-top: 1rem;
}
.tm-tienda-bloque summary { font-weight: 600; cursor: pointer; }

/* --- Filas clicables de los listados (decisión 2026-11-23) --- */
/* La fila completa abre el detalle; el cursor lo indica. El JS vive
   en app/Views/_filas-clicables.php (delegado en `document`). */
.tm-fila-clicable { cursor: pointer; }
.tm-fila-clicable:focus-visible { outline: 2px solid var(--bs-theme); outline-offset: -2px; }

/* --- Dropzone para subir archivos (decisión 2026-11-23) --- */
/* Caja con borde punteado estilo Studio: el input genérico del navegador
   nunca se ve. Clic abre el selector de archivos; también acepta
   arrastrar y soltar. El parcial es app/Views/_dropzone.php y el JS
   vive ahí mismo (delegado en `document`, una sola vez por página). */
.tm-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-width: 0;
    min-height: 7.5rem;
    padding: 1rem;
    text-align: center;
    color: var(--bs-secondary-color);
    background: var(--bs-light);
    border: 2px dashed var(--bs-border-color);
    border-radius: .375rem;
    cursor: pointer;
}
.tm-dropzone:hover { border-color: var(--bs-theme); }
.tm-dropzone.is-dragover {
    border-color: var(--bs-theme);
    background: rgba(var(--bs-theme-rgb), .06);
}
.tm-dropzone:focus-visible { outline: 2px solid var(--bs-theme); outline-offset: 2px; }
/* `hidden` debe ganar aunque el hijo sea flex (el estado vacío y el
   bloque de archivo se alternan con ese atributo). */
.tm-dropzone [hidden] { display: none !important; }
.tm-dropzone-vacio {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    min-width: 0;
}
.tm-dropzone-icon { font-size: 1.75rem; color: var(--bs-theme); }
.tm-dropzone-texto { font-size: .875rem; }
.tm-dropzone-archivo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    max-width: 100%;
}
.tm-dropzone-preview img { max-height: 80px; max-width: 100%; }
.tm-dropzone-nombre {
    font-size: .875rem;
    font-weight: 600;
    color: var(--bs-body-color);
    overflow-wrap: anywhere;
}
/* Input nativo: funcional pero invisible (nunca `display: none`, para
   que el label siga abriendo el selector). */
.tm-dropzone-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}
.tm-dropzone-quitar { margin-top: .5rem; }

/* --- Galería de fotos de producto (2026-11-23, §12.7) --- */
/* Contenedor del detalle: la cajita cuadrada del dropzone a la
   izquierda y las fotos en fila a su derecha, en orden (la 1ª a la
   izquierda). En móvil la fila envuelve: nunca desborda a lo ancho. */
.tm-galeria { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; }
.tm-galeria-fotos { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; min-width: 0; }
/* La caja cuadrada: mismo borde punteado del dropzone, en 7.5 rem. */
.tm-dropzone--cuadrado { width: 7.5rem; height: 7.5rem; min-height: 0; flex: 0 0 auto; padding: .5rem; }
.tm-dropzone--cuadrado .tm-dropzone-icon { font-size: 1.25rem; }
.tm-dropzone--cuadrado .tm-dropzone-texto { font-size: .75rem; }
.tm-galeria-foto {
    position: relative;
    width: 7.5rem;
    height: 7.5rem;
    flex: 0 0 auto;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
    background: var(--bs-light);
    cursor: grab;
}
.tm-galeria-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-galeria-foto.is-arrastrando { opacity: .4; }
.tm-galeria-foto.is-sobre { outline: 2px dashed var(--bs-theme); outline-offset: 2px; }
/* Pendiente de limpieza (/cleanwhite): borde ámbar + slot de
   procesando con spinner (decisión 2026-11-23: la pendiente NO
   muestra la original suelta; en su lugar va un slot cuadrado con
   spinner + "Procesando", y el sondeo lo cambia por la foto limpia
   cuando llega). */
.tm-galeria-foto.is-pendiente { border-color: var(--bs-warning); }
.tm-galeria-foto.is-procesando { display: flex; align-items: center; justify-content: center; cursor: default; }
.tm-galeria-procesando { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .5rem; font-size: .75rem; font-weight: 600; color: var(--bs-secondary); text-align: center; }
.tm-spinner { width: 1.75rem; height: 1.75rem; border-radius: 50%; border: .2rem solid var(--bs-border-color); border-top-color: var(--bs-theme); animation: tm-girar 1s linear infinite; }
@keyframes tm-girar { to { transform: rotate(360deg); } }
.tm-galeria-numero {
    position: absolute; left: .25rem; bottom: .25rem;
    min-width: 1.25rem; height: 1.25rem; padding: 0 .25rem;
    font-size: .75rem; font-weight: 600; line-height: 1.25rem; text-align: center;
    color: #fff; background: rgba(0, 0, 0, .65); border-radius: .25rem;
}
.tm-galeria-borrar {
    position: absolute; top: .25rem; right: .25rem;
    width: 1.5rem; height: 1.5rem; padding: 0;
    font-size: .75rem; line-height: 1;
    color: var(--bs-danger); background: rgba(255, 255, 255, .92);
    border: 1px solid var(--bs-border-color); border-radius: .25rem; cursor: pointer;
}
.tm-galeria-borrar:hover { background: var(--bs-danger); color: #fff; }
.tm-galeria-publicar {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: .2rem .25rem;
    font-size: .65rem; font-weight: 600; line-height: 1.2; text-align: center;
    color: #fff; background: rgba(0, 0, 0, .7); border: 0; cursor: pointer;
}
.tm-galeria-publicar:hover { background: var(--bs-theme); }

/* --- Móvil: la página nunca se mueve de lado (2026-11-22) --- */
/* Causa raíz: varios encabezados de página son `d-flex` sin envoltura y
   sus botones no cabían en 360 px, así que empujaban el ancho de la
   página (el peor caso: la lista de productos, con 5 botones). Las tablas
   no son el problema: todas van en `.table-responsive` y se desplazan
   dentro de su propio contenedor. Regla viva en docs/responsive-movil.md. */
@media (max-width: 767.98px) {
    /* Encabezados de página (título + botones) y sus grupos de botones:
       bajan a dos líneas en vez de empujar el ancho. */
    .app-content > .d-flex { flex-wrap: wrap; }
    .app-content > .d-flex > .d-flex { flex-wrap: wrap; }
    /* Encabezado de tarjeta con texto a la derecha (dashboard). */
    .app-content .card-header.d-flex { flex-wrap: wrap; }
}

/* El texto de los renglones del dashboard y el buscador del header pueden
   encogerse por debajo de su ancho intrínseco sin empujar la página. */
.app-content .flex-fill { min-width: 0; }
.app-header .menu .menu-search { min-width: 0; }

/* Red de seguridad: aunque algo futuro desborde, la página no se mueve
   de lado. `clip` (no `hidden`) no crea contenedor de scroll ni rompe
   el `position: fixed` del header/sidebar del tema. */
html, body { overflow-x: clip; }

/* ==========================================================================
   Autocomplete del sistema (regla permanente: ningún <select> nativo;
   ver app/Views/_autocomplete.php y public/js/autocomplete.js).
   Lista con estilo Studio: fondo y borde del tema, sombra, esquinas
   del tema; la opción activa lleva el acento del tema. Dentro de un
   input-group el texto pierde el radio derecho para pegarse al
   siguiente control, como hacía el <select>.
   ========================================================================== */
.tm-autocomplete { position: relative; }
.tm-autocomplete-texto {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 16px 12px;
    cursor: pointer;
}
.tm-autocomplete-texto:focus { cursor: text; }
.tm-autocomplete-lista {
    position: absolute;
    z-index: 1060;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 15rem;
    overflow-y: auto;
    margin: 0;
    padding: .25rem;
    list-style: none;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    box-shadow: var(--bs-box-shadow);
}
.tm-autocomplete-lista li {
    padding: .375rem .625rem;
    border-radius: var(--bs-border-radius-sm);
    cursor: pointer;
    white-space: normal;
    overflow-wrap: anywhere;
}
.tm-autocomplete-lista li.tm-activo {
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
}
.tm-autocomplete-lista li.tm-autocomplete-sin {
    color: var(--bs-secondary-color);
    cursor: default;
}
.input-group .tm-autocomplete .tm-autocomplete-texto {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
