/* ============================================================
 * CSS del módulo "history" para el skin "sky".
 * Este archivo es un SUSTITUTO COMPLETO del CSS normal del
 * módulo cuando el skin activo es "sky" (no una capa de
 * ajustes encima) -- se carga en su lugar, nunca junto a él.
 * Edítalo libremente para dar a este módulo un aspecto
 * específico de este skin (incluye layout/estructura, no solo
 * colores). Ver también: assets/css/base.css (tokens/variables
 * por skin+modo).
 * ============================================================ */

/* ---- Historial de cambios ---- */
.history-layout { display: grid; gap: 14px; }

/* Contadores */
.history-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.history-stat {
    position: relative;
    display: grid;
    grid-template-columns: 44px 1fr;
    grid-template-areas: 'icon value' 'icon label';
    align-items: center;
    column-gap: 12px;
    padding: 14px 16px;
    border-radius: 3px;
    background: var(--surface);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 10%, transparent);
    overflow: hidden;
}
.history-stat::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--tone, var(--primary)); }
.history-stat__icon {
    grid-area: icon;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 3px;
    background: var(--tone-soft, var(--surface-soft));
    color: var(--tone, var(--primary));
    font-size: 1.2rem;
    font-weight: 900;
}
.history-stat__value { grid-area: value; font-size: 1.7rem; font-weight: 800; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.history-stat__label { grid-area: label; font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); }
.history-stat--today { --tone: var(--primary-dark); --tone-soft: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
.history-stat--insert { --tone: #22b27a; --tone-soft: #e3f8ef; }
.history-stat--update { --tone: #d99a00; --tone-soft: #fff4d6; }
.history-stat--delete { --tone: #dc2626; --tone-soft: #fdeaea; }

.history-panel { padding: 20px 22px 26px; }

.history-intro { margin: 0 0 16px; font-size: .9rem; line-height: 1.55; color: var(--text); }
.history-intro span { display: block; color: var(--primary-dark); font-weight: 700; }

/* Filtros */
.history-filters {
    display: grid;
    grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(120px, 1fr)) repeat(2, minmax(130px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    padding: 14px;
    border-radius: 3px;
    background: var(--surface-soft);
}
.history-filter { display: grid; gap: 4px; min-width: 0; }
.history-filter span { font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--primary-dark); }
.history-filter .input { min-height: 38px; background: var(--surface); }

.history-summary { margin: 18px 0 4px; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-soft); }

/* Línea de tiempo agrupada por día */
.history-list { position: relative; display: grid; gap: 12px; padding-left: 34px; }
.history-list::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: linear-gradient(180deg, var(--border-strong), var(--border));
}

.history-day {
    margin: 14px 0 0 -34px;
    padding: 6px 12px;
    width: fit-content;
    border-radius: 3px;
    background: var(--brand-fill-gradient);
    color: #fff !important;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 25%, transparent);
}
.history-day:first-child { margin-top: 0; }

.history-item { position: relative; }
.history-node {
    position: absolute;
    left: -34px;
    top: 12px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid #fff;
    color: #fff;
    font-size: .9rem;
    font-weight: 900;
    box-shadow: 0 3px 8px rgba(15, 23, 42, .25);
}
.history-node--insert { background: #22b27a; }
.history-node--update { background: #e0a100; }
.history-node--delete { background: #dc2626; }
.history-node--off { background: #64748b; }

.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    box-shadow: 0 3px 12px color-mix(in srgb, var(--primary) 6%, transparent);
    overflow: hidden;
    transition: box-shadow .15s ease, border-color .15s ease;
}
.history-card:hover { box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 14%, transparent); }
.history-item.is-open .history-card { border-color: var(--primary); box-shadow: 0 10px 26px color-mix(in srgb, var(--primary) 18%, transparent); }

.history-card__head {
    width: 100%;
    display: grid;
    gap: 8px;
    padding: 12px 16px 12px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    font: inherit;
}
.history-card__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history-card__time { margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.history-card__time em { font-style: normal; margin-left: 6px; padding: 1px 6px; border-radius: 3px; background: var(--surface-soft); color: var(--primary-dark); }

.history-item__sentence { font-size: 1rem; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
.history-item__sentence b { color: var(--primary-dark); }

.history-item__sub { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--text-soft); }
.history-item__sub strong { color: var(--text); }
.history-context { font-style: normal; padding: 1px 6px; border-radius: 3px; background: var(--warning-soft); color: var(--warning-soft-ink); font-weight: 700; }

.history-avatar {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 3px;
    overflow: hidden;
    background: var(--brand-fill-gradient);
    color: #fff;
    font-size: .74rem;
}
.history-avatar b { font-weight: 800; }
.history-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.history-item__chevron { font-size: 1.2rem; line-height: 1; color: var(--primary); transition: transform .15s ease; }
.history-item.is-open .history-item__chevron { transform: rotate(90deg); }

.history-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
}
.history-badge--insert { background: var(--success-soft); color: var(--success-soft-ink); }
.history-badge--update { background: var(--warning-soft); color: var(--warning-soft-ink); }
.history-badge--delete { background: var(--danger-soft-tint); color: var(--danger-soft-ink); }
.history-badge--off { background: #eceff4; color: #475569; }

.history-scope {
    padding: 4px 10px;
    border-radius: 3px;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .04em;
    white-space: nowrap;
}
.history-scope--labor { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary-dark); }
.history-scope--timeclock { background: #e0f7f4; color: #0f766e; }
.history-scope--logistics { background: #fff0e0; color: #b45309; }
.history-scope--dress { background: #f3e8ff; color: #7c3aed; }
.history-scope--users { background: #fde8ef; color: #be123c; }
.history-scope--welcome { background: #e3f8ef; color: #157a52; }

.history-inline { padding: 1px 7px; border-radius: 3px; font-weight: 700; }
.history-inline--old { background: var(--danger-soft-tint); color: var(--danger-soft-ink); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger-soft-ink) 60%, transparent); }
.history-inline--new { background: var(--success-soft); color: var(--success-soft-ink); }

/* Detalle */
.history-item__body { padding: 2px 16px 16px; border-top: 1px solid var(--border); background: var(--surface-soft); overflow-x: auto; }
.history-item__meta { margin: 12px 0 0; font-size: .74rem; color: var(--text-soft); }
.history-diff { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .86rem; }
.history-diff th, .history-diff td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.history-diff thead th { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; background: var(--surface-soft); color: var(--primary-dark); }
.history-diff tbody th { width: 28%; font-weight: 700; color: var(--text); }
.history-diff__old { background: var(--danger-soft-tint); color: var(--danger-soft-ink); }
.history-diff__new { background: var(--success-soft); color: var(--success-soft-ink); }
.history-empty { color: var(--text-soft); font-style: italic; }

.history-pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 20px; font-size: .84rem; font-weight: 700; }

@media (max-width: 1100px) {
    .history-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .history-filter--search { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
    .history-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
    .history-stat { grid-template-columns: 30px 1fr; padding: 8px 10px; column-gap: 8px; }
    .history-stat__icon { width: 30px; height: 30px; }
    .history-stat__value { font-size: 1.15rem; }
    .history-panel { padding: 8px; }
    .history-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px; gap: 8px; }
    .history-list { padding-left: 14px; gap: 8px; }
    .history-list::before { left: 5px; }
    .history-node { left: -14px; width: 18px; height: 18px; font-size: .62rem; border-width: 2px; }
    .history-day { margin-left: -14px; padding: 4px 8px; }
    .history-card__head { padding: 8px 10px; gap: 6px; }
    .history-item__sentence { font-size: .86rem; }
    .history-diff thead { display: none; }
    .history-diff, .history-diff tbody, .history-diff tr, .history-diff th, .history-diff td { display: block; width: 100% !important; }
    .history-diff tr { border-bottom: 1px solid var(--border); padding: 3px 0; }
    .history-diff th, .history-diff td { padding: 4px 6px; }
}

/* Botón de limpiar filtros: borrador amarillo */
.history-clear {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: #f5b301;
    color: #3b2a00;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(245, 179, 1, .45);
}
.history-clear:hover { background: #e0a200; }
.history-clear .app-icon { width: 20px; height: 20px; filter: none !important; }

/* Fechas más pequeñas */
.history-filter input[type='date'] { min-height: 32px; padding: 2px 8px; font-size: .78rem; background: var(--input-bg); }
.history-filters { grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(120px, 1fr)) repeat(2, minmax(104px, .7fr)) auto; }

/* Buscar más compacto */
.history-filters { grid-template-columns: minmax(150px, 1.1fr) repeat(4, minmax(110px, 1fr)) repeat(2, minmax(104px, .7fr)) auto; }
.history-filter--search .input { min-height: 32px; padding: 2px 10px; font-size: .8rem; background: var(--input-bg); }

.history-scope--warehouse { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); color: var(--primary-dark); }
.history-scope--training { background: #fef3c7; color: #b45309; }
.history-scope--epi { background: #ffedd5; color: #c2410c; }
.history-scope--norm { background: #ede9fe; color: #6d28d9; }
.history-scope--client { background: #fce7f3; color: #be185d; }
.history-scope--digitize { background: #e0f2fe; color: #0369a1; }
.history-scope--supplier { background: #ffedd5; color: #c2410c; }
.history-scope--project { background: #dcfce7; color: #166534; }
.history-scope--tool { background: #e0f2fe; color: #0369a1; }
.history-scope--gps { background: #f3e8ff; color: #7c3aed; }
.history-scope--notify { background: #fef3c7; color: #b45309; }
