/* ==========================================================================
   TEMA "NOCTURNO DORADO"
   Paleta extraida de la marca. Se aplica como capa de override sobre las
   utilidades de Tailwind para no reescribir las 20+ vistas.
   Todo override usa !important para ganar al orden de inyeccion del CDN.
   ========================================================================== */

:root {
    /* Marca */
    --brand-gold: #F5B400;
    --brand-gold-light: #FFC72C;
    --brand-gold-dark: #C99700;

    /* Neutros */
    --ink-900: #0A0A0A;
    --ink-800: #1A1A1A;
    --ink-700: #2E2E2E;

    /* Contraste */
    --paper: #FFFFFF;
    --line: #E5E5E5;
    --muted: #A0A0A0;

    /* Acentos calidos */
    --glow-orange: #FF8C00;
    --amber-soft: #FFB347;

    /* Estados de stock */
    --st-ok: #4CAF50;
    --st-low: #FFC107;
    --st-crit: #F44336;
}

/* --------------------------------------------------------------------------
   BASE
   -------------------------------------------------------------------------- */
body {
    background-color: var(--ink-900) !important;
    color: var(--paper) !important;
}

body.bg-gray-50 { background-color: var(--ink-900) !important; }

/* --------------------------------------------------------------------------
   SUPERFICIES  (cards, tablas, sidebar, inputs, nav)
   -------------------------------------------------------------------------- */
.bg-white {
    background-color: var(--ink-800) !important;
    color: var(--paper) !important;
}

.bg-gray-50 { background-color: var(--ink-900) !important; }
.bg-gray-100 { background-color: var(--ink-700) !important; }
.bg-gray-200 { background-color: var(--ink-700) !important; }

/* --------------------------------------------------------------------------
   TIPOGRAFIA
   -------------------------------------------------------------------------- */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

h1, h2, .font-display {
    font-family: 'Poppins', 'Inter', sans-serif;
    letter-spacing: -0.015em;
}

.text-gray-900,
.text-gray-700 {
    color: var(--paper) !important;
}

.text-gray-600,
.text-gray-500,
.text-gray-400 {
    color: var(--muted) !important;
}

/* --------------------------------------------------------------------------
   BORDES Y DIVISORES
   -------------------------------------------------------------------------- */
.border-gray-100,
.border-gray-200,
.border-gray-300 {
    border-color: var(--ink-700) !important;
}

.divide-gray-100 > :not([hidden]) ~ :not([hidden]),
.divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--ink-700) !important;
}

/* --------------------------------------------------------------------------
   MARCA (dorado)
   -------------------------------------------------------------------------- */
.bg-primary-500,
.bg-primary-600,
.bg-primary-700 {
    background-color: var(--brand-gold) !important;
    color: var(--ink-900) !important;
    font-weight: 600;
}

.hover\:bg-primary-600:hover,
.hover\:bg-primary-700:hover,
.hover\:bg-primary-500:hover {
    background-color: var(--brand-gold-light) !important;
}

.bg-primary-100,
.bg-primary-50 {
    background-color: rgba(245, 180, 0, 0.12) !important;
    color: var(--brand-gold) !important;
}

.text-primary-600,
.text-primary-700,
.text-primary-900,
.text-primary-500 {
    color: var(--brand-gold) !important;
}

.border-primary-200,
.border-primary-500,
.border-primary-600 {
    border-color: var(--brand-gold) !important;
}

.ring-primary-500 {
    --tw-ring-color: var(--brand-gold) !important;
    box-shadow: 0 0 0 3px rgba(245, 180, 0, 0.25) !important;
}

.hover\:text-primary-600:hover,
.hover\:text-primary-700:hover,
.hover\:text-primary-900:hover {
    color: var(--brand-gold-light) !important;
}

.focus\:ring-primary-500:focus {
    --tw-ring-color: var(--brand-gold) !important;
    box-shadow: 0 0 0 3px rgba(245, 180, 0, 0.25) !important;
}

.focus\:border-primary-500:focus,
.focus\:border-primary-600:focus {
    border-color: var(--brand-gold) !important;
}

/* --------------------------------------------------------------------------
   INPUTS
   -------------------------------------------------------------------------- */
input,
select,
textarea {
    background-color: var(--ink-800) !important;
    color: var(--paper) !important;
    border-color: var(--ink-700) !important;
}

input::placeholder,
textarea::placeholder {
    color: #6B6B6B !important;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-gold) !important;
    box-shadow: 0 0 0 3px rgba(245, 180, 0, 0.18) !important;
}

input:read-only,
.bg-gray-50 {
    background-color: #141414 !important;
    color: var(--muted) !important;
}

/* Select: la flecha nativa se ve poorly sobre fondo oscuro */
select {
    background-image: linear-gradient(45deg, transparent 50%, var(--brand-gold) 50%),
                      linear-gradient(135deg, var(--brand-gold) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(1em + 2px), calc(100% - 13px) calc(1em + 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    appearance: none;
    -webkit-appearance: none;
}

/* --------------------------------------------------------------------------
   NAVEGACION
   -------------------------------------------------------------------------- */
nav a { transition: color .15s ease, background-color .15s ease; }

nav a:hover {
    color: var(--brand-gold) !important;
}

aside a:hover {
    background-color: rgba(245, 180, 0, 0.10) !important;
    color: var(--brand-gold) !important;
}

/* --------------------------------------------------------------------------
   ESTADOS DE STOCK  (se mantienen, no se retonifican)
   -------------------------------------------------------------------------- */
.bg-green-100 { background-color: rgba(76, 175, 80, 0.16) !important; }
.text-green-700, .text-green-600, .text-green-500 {
    color: var(--st-ok) !important;
}
.bg-green-200 { background-color: rgba(76, 175, 80, 0.26) !important; }

.bg-yellow-100 { background-color: rgba(255, 193, 7, 0.16) !important; }
.text-yellow-700, .text-yellow-600 { color: var(--st-low) !important; }
.bg-yellow-200 { background-color: rgba(255, 193, 7, 0.26) !important; }

.bg-red-100, .bg-red-50 { background-color: rgba(244, 67, 54, 0.16) !important; }
.text-red-700, .text-red-600, .text-red-500, .text-red-900 {
    color: var(--st-crit) !important;
}
.bg-red-200 { background-color: rgba(244, 67, 54, 0.26) !important; }
.border-red-400, .border-red-200 { border-color: rgba(244, 67, 54, 0.5) !important; }

/* Metodos de pago / etiquetas informativas */
.bg-blue-100 { background-color: rgba(59, 130, 246, 0.16) !important; }
.text-blue-700 { color: #60A5FA !important; }
.bg-purple-100 { background-color: rgba(168, 85, 247, 0.16) !important; }
.text-purple-700, .text-purple-600 { color: #C084FC !important; }
.bg-pink-100 { background-color: rgba(236, 72, 153, 0.16) !important; }
.text-pink-600 { color: #F472B6 !important; }

/* --------------------------------------------------------------------------
   GLOW DORADO (hover en cards y filas)
   -------------------------------------------------------------------------- */
.shadow { box-shadow: none !important; }

.shadow-lg {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6) !important;
}

tr.hover\:bg-gray-50:hover,
.hover\:bg-gray-50:hover {
    background-color: rgba(245, 180, 0, 0.07) !important;
    box-shadow: inset 3px 0 0 var(--brand-gold);
}

a.hover\:bg-primary-50:hover,
.hover\:bg-primary-50:hover {
    background-color: rgba(245, 180, 0, 0.10) !important;
}

.bg-gray-100:hover {
    background-color: var(--ink-700) !important;
    box-shadow: 0 0 15px rgba(245, 180, 0, 0.2);
}

/* --------------------------------------------------------------------------
   SCROLLBARS
   -------------------------------------------------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ink-900); }
::-webkit-scrollbar-thumb {
    background: var(--ink-700);
    border-radius: 6px;
    border: 2px solid var(--ink-900);
}
::-webkit-scrollbar-thumb:hover { background: var(--brand-gold-dark); }

/* --------------------------------------------------------------------------
   LOGO
   -------------------------------------------------------------------------- */
img[src*="logo.png"] {
    filter: drop-shadow(0 0 10px rgba(245, 180, 0, 0.25));
}

/* --------------------------------------------------------------------------
   ACCESIBILIDAD
   -------------------------------------------------------------------------- */
::selection {
    background: var(--brand-gold);
    color: var(--ink-900);
}

/* ==========================================================================
   iOS / TABLET
   ========================================================================== */
html {
    /* Scroll con inercia en Safari, sin rubber-band en el body */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overscroll-behavior-y: none;
}

body {
    -webkit-overflow-scrolling: touch;
    /* Evita el highlight azul/gris al tocar links en iOS */
    -webkit-tap-highlight-color: transparent;
    /* Quita el delay de 300ms en tactiles */
    touch-action: manipulation;
}

/* No seleccionar texto al tocar la interfaz (solo donde no debe editarse) */
nav, aside, header, button, a, label, th {
    -webkit-user-select: none;
    user-select: none;
}

/* --------------------------------------------------------------------------
   SAFE AREAS (notch y barra de inicio del iPhone)
   -------------------------------------------------------------------------- */
#sidebar {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
}

/* El header mobile vive dentro del area segura superior */
header.sticky {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-right);
}

/* En body y no en main: main usa utilidades Tailwind (.p-*) que ganan
   en especificidad, y ademas el padding extra no debe pisar las classes. */
body {
    padding-bottom: env(safe-area-inset-bottom);
    padding-right: env(safe-area-inset-right);
}

/* --------------------------------------------------------------------------
   TARGETS TACTOUCHES (guia de Apple: 44x44)
   Solo donde el toque es una accion primaria; aplicar min-height a todo <a>
   deformaria los links de texto.
   -------------------------------------------------------------------------- */
aside nav a,
main button[type="submit"],
input[type="submit"],
input[type="button"],
select,
input[type="date"],
input[type="time"] {
    min-height: 44px;
}

/* Links y botones chicos (Ver todas, Ver todos) hay que agrandarlos solo
   en pantallas tactiles: en desktop un header de 44px se ve desproporcionado */
@media (hover: none) {
    .tap-44 {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* Feedback de presion: iOS no tiene :hover persistente */
@media (hover: none) {
    aside nav a:active,
    main button:active {
        opacity: 0.75;
    }
}

/* --------------------------------------------------------------------------
   INPUTS: iOS hace zoom automatico si el font-size es < 16px
   -------------------------------------------------------------------------- */
input,
select,
textarea {
    font-size: max(16px, 1rem);
}

@media (min-width: 768px) {
    input,
    select,
    textarea {
        font-size: 0.875rem;
    }
}

input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
}

/* --------------------------------------------------------------------------
   TABLAS: scroll horizontal suave en pantallas chicas.
   No se apilan a bloques porque varias tablas las maneja JS (POS, kardex)
   y romperian los <thead>.
   -------------------------------------------------------------------------- */
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

@media (max-width: 768px) {
    .overflow-x-auto table {
        min-width: 640px;
    }

    /* El contenedor scrolleable muestra una sombra cuando hay mas contenido */
    .overflow-x-auto {
        background:
            linear-gradient(to right, var(--ink-800) 30%, transparent),
            linear-gradient(to left, var(--ink-800) 30%, transparent) 100% 0,
            radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .5), transparent),
            radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .5), transparent) 100% 0;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }
}

/* --------------------------------------------------------------------------
   ESPACIADO EN PANTALLAS CHICAS
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
    main {
        padding: 1rem;
    }
}