/* /src/assets/css/global.css */
/* ==========================================================================
   BINTELX FRONT
   ==========================================================================
   This file provides a comprehensive set of base styles, design tokens,
   and utility classes for the Bintelx enterprise platform. It merges
   proven styles from `global_old.css` with the refined principles from
   the unified design guide.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CORE DESIGN TOKENS
   Foundation of the visual language. Do not use hardcoded values.
-------------------------------------------------------------------------- */
:root {
    /* =========================================================================
       HSL PRIMITIVES (Refactoring UI Pattern)
       Store HSL values WITHOUT hsl() wrapper for alpha flexibility.
       Usage: hsl(var(--slate-500)) or hsl(var(--slate-500) / 0.5) for alpha
       ========================================================================= */

    /* Slate (blue-tinted grays - Tailwind exact values) */
    --slate-50:  210 40% 98%;
    --slate-100: 210 40% 96%;
    --slate-200: 214 32% 91%;
    --slate-300: 213 27% 84%;
    --slate-400: 215 20% 65%;
    --slate-500: 215 16% 47%;
    --slate-600: 215 19% 35%;
    --slate-700: 215 25% 27%;
    --slate-800: 217 33% 17%;
    --slate-900: 222 47% 11%;

    /* Indigo (accent premium) */
    --indigo-50:  226 100% 97%;
    --indigo-100: 226 100% 94%;
    --indigo-500: 239 84% 67%;
    --indigo-600: 243 75% 59%;

    /* Orange (warm action) */
    --orange-50:  33 100% 96%;
    --orange-100: 34 100% 92%;
    --orange-400: 27 96% 61%;
    --orange-500: 25 95% 53%;
    --orange-600: 21 90% 48%;
    --orange-700: 17 88% 40%;

    /* Emerald (success/positive) */
    --emerald-50:  152 81% 96%;
    --emerald-100: 149 80% 90%;
    --emerald-400: 158 64% 52%;
    --emerald-500: 160 84% 39%;
    --emerald-600: 161 94% 30%;
    --emerald-700: 163 94% 24%;

    /* Green (confirm/active) */
    --green-50:  138 76% 97%;
    --green-100: 141 84% 93%;
    --green-500: 142 71% 45%;
    --green-600: 142 76% 36%;
    --green-700: 142 72% 29%;

    /* Amber (warning/caution) */
    --amber-50:  48 100% 96%;
    --amber-100: 48 96% 89%;
    --amber-500: 38 92% 50%;
    --amber-600: 32 95% 44%;

    /* Blue (info/primary) */
    --blue-50:  214 100% 97%;
    --blue-100: 214 95% 93%;
    --blue-500: 217 91% 60%;
    --blue-600: 221 83% 53%;

    /* Red (danger/error) */
    --red-50:  0 86% 97%;
    --red-100: 0 93% 94%;
    --red-300: 0 94% 82%;
    --red-400: 0 91% 71%;
    --red-500: 0 84% 60%;
    --red-600: 0 72% 51%;

    /* Fonts */
    --font-family-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-family-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'Liberation Mono', monospace;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --text-size-sm: 0.875rem;   /* 14px */
    --text-size-base: 1rem;     /* 16px */
    --text-size-lg: 1.125rem;   /* 18px */
    --text-size-xl: 1.25rem;    /* 20px */
    --text-size-2xl: 1.5rem;    /* 24px */
    --text-size-4xl: 2.5rem;    /* 40px - For featured data */
    --line-height-normal: 1.5;
    --line-height-heading: 1.25;
    --letter-spacing-caps: 0.08rem;

    /* Colors (Primary action color is Blue) */
    --color-primary-500: hsl(217, 91%, 60%);
    --color-primary-600: hsl(217, 91%, 55%);
    --color-primary-100: hsl(217, 91%, 95%);

    /* Grays (From the battle-tested palette) */
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-500: #6b7280;
    --color-gray-700: #374151;
    --color-gray-900: #111827;
    --color-white: #ffffff;
    --color-red: #ef4444;
    --color-background-body: var(--color-gray-50);
    --color-background-card: var(--color-white);
    --color-background-subtle: var(--color-gray-100);
    --color-border-default: var(--color-gray-300);
    --color-border-subtle: var(--color-gray-200);
    --color-green-100: #dcfce7; /* Verde claro para fondo de badge "Active" */
    --color-green-700: #166534; /* Verde oscuro para texto de badge "Active" */


    /* Semantic & UI Colors */
    --color-brand-primary: var(--color-primary-500);
    --color-brand-dark: hsl(217, 30%, 15%);
    --color-brand-teal: hsl(180, 50%, 55%);
    --color-brand-teal-dark: hsl(180, 50%, 45%);

    --color-text-primary: var(--color-gray-900);
    --color-text-secondary: var(--color-gray-700);
    --color-text-tertiary: var(--color-gray-500);
    --color-text-link: var(--color-brand-primary);


    /* Spacing (4px base scale) */
    --spacing-1: 0.25rem;   /* 4px */
    --spacing-2: 0.5rem;    /* 8px */
    --spacing-3: 0.75rem;   /* 12px */
    --spacing-4: 1rem;      /* 16px */
    --spacing-6: 1.5rem;    /* 24px */
    --spacing-8: 2rem;      /* 32px */

    /* Border Radius */
    --radius-md: 0.375rem; /* 6px */
    --radius-lg: 0.5rem;   /* 8px */
    --radius-full: 9999px;

    /* Breakpoints — @media no soporta var(), usar los valores directamente */
    --bp-sm: 435px;
    --bp-md: 768px;
    --bp-lg: 1024px;
    --bp-xl: 1280px;

    /* Z-Index Layers — Single source of truth para stacking context */
    --z-base: 1;              /* Stacking local: iconos, badges, overlaps internos */
    --z-sticky: 10;           /* Sticky dentro de contenido (action bars, sub-headers) */
    --z-content: 30;          /* Controles flotantes sobre contenido (offering controls) */
    --z-header: 40;           /* Headers sticky de página (contexto engagement) */
    --z-aside-backdrop: 55;   /* Backdrop semitransparente detrás de aside */
    --z-aside: 60;            /* Paneles aside (sidebars, slide-in mobile) */
    --z-dropdown: 100;        /* Dropdowns, popovers, tooltips */
    --z-modal: 1000;          /* Modales no-nativos, popovers fullscreen */
    --z-system: 9999;         /* Sistema: auth overlay, bloqueos críticos */

    /* Shadows (Based on Refactoring UI principles) */
    --shadow-sm: 0 1px 2px 0 hsla(0, 0%, 0%, 0.05);
    --shadow-md: 0 4px 6px -1px hsla(0, 0%, 0%, 0.1), 0 2px 4px -2px hsla(0, 0%, 0%, 0.1);
    --shadow-lg: 0 10px 15px -3px hsla(0, 0%, 0%, 0.1), 0 4px 6px -4px hsla(0, 0%, 0%, 0.1);
    --shadow-inner: inset 0 2px 4px 0 hsla(0, 0%, 0%, 0.05);
}

/* --------------------------------------------------------------------------
   2. GLOBAL RESETS & BODY STYLES
-------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body { height: 100%; }

body {
    font-family: emoji, var(--font-family-sans);
    color: var(--color-text-primary);
    background-color: var(--color-background-body);
    line-height: var(--line-height-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
}

/* App shell: cadena de alturas para que h-full funcione en módulos */
#slot-app { display: flex; flex-direction: column; height: 100%; }
#pre-app  { flex-shrink: 0; }
#app      { flex: 1; min-height: 0; overflow: auto; }
#post-app { flex-shrink: 0; }

/* --------------------------------------------------------------------------
   3. NATIVE & SEMANTIC ELEMENT STYLING
-------------------------------------------------------------------------- */
/* Typography */
h1, h2, h3, h4, h5, h6, legend {
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-heading);
    margin: 0;
}
p {
    margin: 0;
    color: var(--color-text-secondary);
}
a {
    color: var(--color-text-link);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
}
a:hover { text-decoration: underline; }

/* Forms & Fieldsets */
form { display: flex; flex-direction: column; height: 100%; }
fieldset {
    border: none;
    padding: 0;
    margin: 0;
    margin-bottom: var(--spacing-3);
}
legend {
    font-size: var(--text-size-lg);
    padding: 0;
    margin-bottom: var(--spacing-3);
    width: 100%;
}

/* Accordion / Collapsible */
details {
    padding-bottom: var(--spacing-3);
    border-bottom: 1px solid var(--color-border-subtle);
}
summary {
    list-style: none;
    cursor: pointer;
    padding: var(--spacing-4) 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    gap: var(--spacing-1);
}
summary::-webkit-details-marker { display: none; }



/* --------------------------------------------------------------------------
   4. NATIVE FORM CONTROLS
-------------------------------------------------------------------------- */
label {
    display: block;
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--spacing-2);
}

input,
textarea,
select {
    display: block;
    width: 100%;
    padding: var(--spacing-2) var(--spacing-3);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    font-size: var(--text-size-base);
    background-color: var(--color-white);
    transition: border-color 150ms, box-shadow 150ms;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-brand-primary);
    box-shadow: 0 0 0 3px var(--color-primary-100);
}

::placeholder {
    color: var(--color-gray-300);
    opacity: 1;
}

/* --------------------------------------------------------------------------
   5. BUTTONS
-------------------------------------------------------------------------- */
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 150ms, border-color 150ms, color 150ms;
    user-select: none;
}

.button-primary {
    background-color: var(--color-brand-primary);
    color: var(--color-white);
    border-color: var(--color-brand-primary);
}
.button-primary:hover {
    background-color: var(--color-primary-600);
    border-color: var(--color-primary-600);
}

/* For secondary actions like 'Reset' or 'Cancel' */
.button-secondary {
    background-color: var(--color-white);
    color: var(--color-text-secondary);
    border-color: var(--color-border-default);
}
.button-secondary:hover {
    background-color: var(--color-gray-50);
    border-color: var(--color-gray-700);
    color: var(--color-text-primary);
}

/* For text-only actions like 'Edit' */
.link {
    background: none;
    border: none;
    color: var(--color-text-link);
    padding: 0;
}
.link:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   6. CORE LAYOUT & COMPONENT CLASSES
-------------------------------------------------------------------------- */
.card {
    background-color: var(--color-background-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-subtle);
    padding: var(--spacing-6);
    margin-bottom: var(--spacing-8);
}

/* Main Layout Structure (Sidebar + Main Content) */
.main-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
@media (min-width: 768px) {
    .main-layout { flex-direction: row; gap: 2.5rem; }
}

.main-content {
    flex-grow: 1;
    min-width: 0; /* Prevents flex items from overflowing */
    display: flex;
    flex-direction: column;
}
.content-body {
    flex-grow: 1; /* Pushes action toolbar to the bottom */
}
.content-header h2 {
    font-size: var(--text-size-2xl);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--spacing-6);
}

/* Sidebar Navigation */
aside nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}
aside nav a {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
}
aside nav a:hover {
    background-color: var(--color-background-subtle);
    text-decoration: none;
}
aside nav a.is-active {
    background-color: var(--color-primary-100);
    color: var(--color-primary-600);
    font-weight: var(--font-weight-semibold);
}

aside .nav-icon {
    flex-shrink: 0;
    width: 1rem;  /* 16px */
    height: 1rem; /* 16px */
    color: currentColor;
}

aside .nav-icon svg {
    width: 100%;
    height: 100%;
}

/* Form Sectioning (as seen in demo) */
.form-section {
    background-color: var(--color-background-card);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--spacing-6);
    margin-bottom: var(--spacing-8);
}
.form-group {
    margin-bottom: var(--spacing-4);
}
@media (min-width: 768px) {
    .form-group {
        display: grid;
        /*grid-template-columns: 29vw 1fr;
        gap: 1.5rem;
         */
        align-items: flex-start; /* Use flex-start for multi-line textareas */
    }
    .form-group label {
        text-align: left;
        margin-bottom: 0;
        padding-top: var(--spacing-2); /* Align with text inside input */
    }
}

/* Action Toolbar (for save/reset buttons) */
.action-toolbar {
    background-color: var(--color-white);
    padding: var(--spacing-4);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-3);
    border-top: 1px solid var(--color-border-subtle);
    box-shadow: 0 -4px 15px -5px hsla(0, 0%, 0%, .05);
}
@media (min-width: 768px) {
    .action-toolbar {
        position: sticky;
        bottom: var(--spacing-6);
        align-self: flex-end; /* Aligns to the end of the flex container */
        width: auto;
        border-radius: var(--radius-lg);
        border: 1px solid var(--color-border-subtle);
        box-shadow: var(--shadow-md);
    }
}


/* --------------------------------------------------------------------------
   7. NATIVE TABLE DEFAULTS
-------------------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-6);
    text-align: left;
}

th, td {
    padding: var(--spacing-3);
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: top;
}

th {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
}

/* --------------------------------------------------------------------------
   8. DATA TABLE COMPONENT
-------------------------------------------------------------------------- */
.data-table-wrapper {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    min-width: 700px;
}

.data-table thead th {
    background-color: var(--color-background-subtle);
    border-bottom: 2px solid var(--color-border-subtle);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background-color: var(--color-background-subtle);
}

.data-table tbody td {
    vertical-align: middle; /* Alinea mejor el contenido con badges y otros elementos */
}

/* --- Status Badges  --- */
.status-badge {
    display: inline-block;
    padding: var(--spacing-1, 0.25rem) var(--spacing-3, 0.75rem);
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-medium);
    font-size: var(--text-size-sm);
    white-space: nowrap;
    line-height: 1.4;
}

.status-badge.status-active {
    background-color: var(--color-green-100);
    color: var(--color-green-700);
}

.status-badge.status-inactive {
    background-color: var(--color-gray-200);
    color: var(--color-gray-700);
}

/* --- Colapsable inside Talbes --- */
.data-table .details-summary {
    cursor: pointer;
    list-style: none;
    color: var(--color-text-link);
    font-weight: var(--font-weight-medium);
}
.data-table .details-summary::-webkit-details-marker { display: none; }

.data-table .details-content {
    margin-top: var(--spacing-3);
    padding: var(--spacing-4);
    background-color: var(--color-background-subtle);
    border-left: 4px solid var(--color-brand-primary);
}


/* --------------------------------------------------------------------------
   9. SUPERCHARGED LISTS (Mobile-Friendly Checkbox & Radio Blocks)
   -------------------------------------------------------------------------- */

.supercharged-list {
    display: grid;
    gap: var(--spacing-3);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.supercharged-list > label {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-subtle);
    cursor: pointer;
    transition: background-color 150ms, border-color 150ms;
    flex-wrap: wrap;
}

.supercharged-list > label:hover {
    background-color: var(--color-background-subtle);
    border-color: var(--color-border-default);
}

/* Ocultamos el input nativo */
.supercharged-list > label input[type="checkbox"],
.supercharged-list > label input[type="radio"] {
    display: none;
}

/* El icono falso que estilizamos */
.supercharged-list > label .checkbox-icon-placeholder {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--color-border-default);
    border-radius: var(--radius-md); /* Cuadrado para checkbox */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms, border-color 150ms;
    flex-shrink: 0;
}

.supercharged-list > label input[type="radio"] + .checkbox-icon-placeholder {
    border-radius: var(--radius-full);
}

/* status :checked */
.supercharged-list > label input[type="checkbox"]:checked + .checkbox-icon-placeholder,
.supercharged-list > label input[type="radio"]:checked + .checkbox-icon-placeholder {
    background-color: var(--color-brand-primary);
    border-color: var(--color-brand-primary);
}

/* Dibujamos el "check" o el "punto" */
.supercharged-list > label input[type="checkbox"]:checked + .checkbox-icon-placeholder::after {
    content: '✔';
    color: var(--color-white);
    font-size: 1rem;
    line-height: 1;
}

.supercharged-list > label input[type="radio"]:checked + .checkbox-icon-placeholder::after {
    content: '';
    display: block;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: var(--radius-full);
    background-color: var(--color-white);
}

/* -- Manejo del campo de texto "Other" -- */
.supercharged-list > label.has-textfield {
    align-content: flex-start;
}
.supercharged-list > label .list-item-textfield {
    flex-basis: 100%;
    margin-top: var(--spacing-2);
}

/* -- Accesibilidad: Foco visible -- */
.supercharged-list > label input[type="checkbox"]:focus-visible + .checkbox-icon-placeholder,
.supercharged-list > label input[type="radio"]:focus-visible + .checkbox-icon-placeholder {
    box-shadow: 0 0 0 3px var(--color-primary-100);
}

/* ==========================================================================
   MODERN POPOVER STYLES (Mobile-First, Desktop-Optimized)
   ========================================================================== */

/* Popover Base Styles */
.app-popover {
    /* --- Mobile First: Fullscreen by default --- */
    position: fixed;
    inset: 0; /* A shorthand for top, right, bottom, left = 0 */
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 0; /* No border radius on mobile for fullscreen effect */
    box-shadow: var(--shadow-lg);
    background-color: var(--color-background-card);
    color: var(--color-text-primary);
    overflow-y: auto; /* Allow content to scroll if it overflows */
    z-index: var(--z-modal);
}

/* Popover backdrop style */
.app-popover::backdrop {
    background-color: hsla(0, 0%, 0%, 0.5);
    backdrop-filter: blur(4px);
}

/* --- Desktop View: Bottom Half (2/4) Panel --- */
@media (min-width: 768px) {
    .app-popover {
        /* Override mobile fullscreen styles */
        inset: auto; /* Reset the inset property */
        top: 50%;    /* Start from the vertical midpoint */
        bottom: 0;
        left: 0;
        right: 0;

        width: 90%;  /* Not full width, but most of it */
        max-width: 1200px; /* Set a max-width for large screens */
        height: 50vh; /* Occupies 2/4 of the viewport height */
        max-height: 50vh;

        margin: 0 auto; /* Center the popover horizontally */

        /* Apply border-radius only to the top corners for a clean look */
        border-top-left-radius: var(--radius-lg);
        border-top-right-radius: var(--radius-lg);
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;

        border: 1px solid var(--color-border-subtle);
    }
}

/* Shared content styles for both mobile and desktop */
.popover-content {
    padding: var(--spacing-6);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-4);
}

.popover-close-button {
    /* Position the close button at the top-right of the content area */
    align-self: flex-end;
}

/*
   ACCESSIBLE NAVIGATION & TABS STYLING
   This styles navigation based on ARIA attributes instead of classes.
*/

/* Example for a Tab list */
[role="tablist"] {
    display: flex;
    gap: var(--spacing-1);
}

[role="tab"] {
    /* Base styles from our button/link defaults */
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-2) var(--spacing-4);
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 150ms, color 150ms;
}

[role="tab"]:hover {
    background-color: var(--color-background-subtle);
    color: var(--color-text-primary);
}

/* Style the active tab using the ARIA attribute */
[role="tab"][aria-selected="true"] {
    background-color: var(--color-primary-100);
    color: var(--color-primary-600);
    font-weight: var(--font-weight-semibold);
}

/* Styling for helper text directly following a form input */
input + p,
textarea + p,
select + p,
label + p,
input + small,
textarea + small,
select + small,
h1 + small, h2 + small, h3 + small, h4 + small, h5 + small, h6 + small
{
    color: var(--color-text-tertiary);
    font-size: var(--text-size-sm);
    margin-top: var(--spacing-1);
    /* Reset bottom margin if it's the last element in a group */
    padding: 0;
    margin-bottom: 0;
}

/*
 * The "Flow" utility class applies consistent vertical rhythm
 * to direct children elements using the "lobotomized owl" selector.
 */
.flow > * + * {
    margin-top: var(--spacing-6, 1.5rem);
}

/* Supercharged default styles for unordered and ordered lists */
ul, ol {
    padding-left: var(--spacing-6); /* CORRECTED */
    margin: var(--spacing-4) 0; /* CORRECTED */
    color: var(--color-text-secondary); /* CORRECTED */
}

ul li::marker {
    color: var(--color-brand-primary); /* Makes the bullet point use the primary brand color */
}

li {
    padding-left: var(--spacing-2);
    margin-top: var(--spacing-4);
}
li + li {
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/*
 * Use this class to highlight the most important piece of data
 * within a component, like a price, a percentage, or a key metric.
 */
.feature-data {
    color: var(--color-text-primary);
    font-size: var(--text-size-4xl); /* The largest font size for key data */
    font-weight: var(--font-weight-bold);
    line-height: 1.1; /* Tighter line height for large text */
}

.unstyled {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: inherit;
}

.flex {
    display: flex;
}
.flex.row, .flex .row {
    flex-direction: row;
}

.grow-1 {
    flex-grow: 1;
}


