/* =========================================================================
   AGUACATE COMPONENTS — librería de componentes UX modernos.
   Se carga DESPUÉS de aguacate-theme.css.
   ========================================================================= */

/* ============= PAGE HERO ============= */
.page-hero {
    position: relative;
    padding: 24px 0 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}
.page-hero__intro { min-width: 0; }
.page-hero__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 700;
    color: var(--ag-primary);
    background: var(--ag-primary-50);
    padding: 5px 12px;
    border-radius: 999px;
    margin-bottom: 10px;
}
.page-hero__title {
    font-family: var(--ag-font-display);
    font-weight: 800;
    font-size: clamp(1.4rem, 2vw, 1.85rem);
    letter-spacing: -0.02em;
    color: var(--ag-text);
    margin: 0 0 6px;
    line-height: 1.15;
}
.page-hero__subtitle {
    color: var(--ag-text-mute);
    margin: 0;
    font-size: .9375rem;
}
.page-hero__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============= STAT TILE ============= */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .stat-grid { grid-template-columns: 1fr; } }

.stat-tile {
    position: relative;
    background: var(--ag-surface);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    padding: 20px 22px;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
    box-shadow: var(--ag-shadow-sm);
}
.stat-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--ag-shadow);
    border-color: color-mix(in srgb, var(--ag-primary) 30%, var(--ag-border) 70%);
}
.stat-tile__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.stat-tile__label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--ag-text-mute);
    font-weight: 700;
    margin: 0;
}
.stat-tile__icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1rem;
    background: var(--ag-primary-50);
    color: var(--ag-primary-700);
}
.stat-tile__icon.is-info    { background: rgba(14, 165, 233, .12); color: #0369a1; }
.stat-tile__icon.is-warning { background: rgba(245, 158, 11, .14); color: #b45309; }
.stat-tile__icon.is-danger  { background: rgba(239, 68, 68, .12); color: #b91c1c; }
.stat-tile__icon.is-violet  { background: rgba(139, 92, 246, .14); color: #6d28d9; }
.stat-tile__value {
    font-family: var(--ag-font-display);
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--ag-text);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin: 0;
}
.stat-tile__delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--ag-text-mute);
    margin-top: 6px;
}
.stat-tile__delta.is-up    { color: #16a34a; }
.stat-tile__delta.is-down  { color: #dc2626; }
.stat-tile__sparkline {
    margin-top: 12px;
    height: 36px;
}

/* ============= ACTION TOOLBAR ============= */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--ag-surface);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.toolbar__search {
    flex: 1 1 240px;
    position: relative;
}
.toolbar__search input.form-control {
    padding-left: 38px !important;
    background: var(--ag-surface-alt) !important;
    border: 1px solid var(--ag-border) !important;
}
.toolbar__search::before {
    content: "\f002";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ag-text-mute);
    pointer-events: none;
}
.toolbar__divider {
    width: 1px;
    align-self: stretch;
    background: var(--ag-border);
    margin: 0 2px;
}
.toolbar .btn { white-space: nowrap; }

/* ============= TABS UNDERLINE ============= */
.tabs-underline.nav-pills,
.tabs-underline.nav-tabs {
    border-bottom: 1px solid var(--ag-border) !important;
    background: transparent;
    gap: 4px;
    margin-bottom: 16px;
}
.tabs-underline.nav-pills .nav-link,
.tabs-underline.nav-tabs .nav-link {
    background: transparent !important;
    border: 0 !important;
    color: var(--ag-text-soft) !important;
    font-weight: 600;
    font-size: .875rem;
    padding: 10px 14px !important;
    position: relative;
    border-radius: 0 !important;
}
.tabs-underline.nav-pills .nav-link::after,
.tabs-underline.nav-tabs .nav-link::after {
    content: "";
    position: absolute;
    left: 12px; right: 12px; bottom: -1px;
    height: 2px;
    background: transparent;
    border-radius: 2px;
    transition: background .15s ease;
}
.tabs-underline.nav-pills .nav-link:hover,
.tabs-underline.nav-tabs .nav-link:hover {
    color: var(--ag-text) !important;
}
.tabs-underline.nav-pills .nav-link.active,
.tabs-underline.nav-tabs .nav-link.active {
    color: var(--ag-primary) !important;
    background: transparent !important;
}
.tabs-underline.nav-pills .nav-link.active::after,
.tabs-underline.nav-tabs .nav-link.active::after {
    background: var(--ag-primary);
}

/* ============= EMPTY STATE ============= */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    border: 1px dashed var(--ag-border-strong);
    border-radius: var(--ag-radius);
    background: var(--ag-surface-alt);
    color: var(--ag-text-soft);
}
.empty-state__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--ag-primary-50);
    color: var(--ag-primary-700);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    font-size: 1.5rem;
}
.empty-state__title {
    font-family: var(--ag-font-display);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--ag-text);
    margin: 0 0 4px;
}
.empty-state__text { margin: 0 0 16px; }

/* ============= FORM SECTION ============= */
.form-section {
    background: var(--ag-surface);
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    box-shadow: var(--ag-shadow-sm);
    margin-bottom: 16px;
}
.form-section__header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--ag-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.form-section__title {
    font-family: var(--ag-font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--ag-text);
    margin: 0;
}
.form-section__hint {
    font-size: .8125rem;
    color: var(--ag-text-mute);
    margin: 4px 0 0;
}
.form-section__body { padding: 20px 22px; }
.form-section__footer {
    padding: 14px 22px;
    border-top: 1px solid var(--ag-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    background: var(--ag-surface-alt);
    border-radius: 0 0 var(--ag-radius) var(--ag-radius);
}

/* ============= STATUS PILL ============= */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.status-pill::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-pill.is-active,   .status-pill.is-success { background: #dcfce7; color: #15803d; }
.status-pill.is-pending,  .status-pill.is-warning { background: #fef3c7; color: #b45309; }
.status-pill.is-rejected, .status-pill.is-danger  { background: #fee2e2; color: #b91c1c; }
.status-pill.is-info     { background: rgba(14,165,233,.14); color: #0369a1; }
.status-pill.is-neutral  { background: #e5e7eb; color: #374151; }
.status-pill.is-violet   { background: rgba(139,92,246,.14); color: #6d28d9; }

/* ============= RANKED LIST ============= */
.ranked-list { display: flex; flex-direction: column; gap: 8px; }
.ranked-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius-sm);
    background: var(--ag-surface);
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
    text-decoration: none !important;
}
.ranked-item:hover {
    border-color: color-mix(in srgb, var(--ag-primary) 40%, var(--ag-border) 60%);
    background: var(--ag-primary-50);
    transform: translateX(2px);
}
.ranked-item__rank {
    width: 30px; height: 30px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--ag-surface-alt);
    color: var(--ag-text-soft);
    font-weight: 700;
    font-family: var(--ag-font-display);
    font-size: .85rem;
    flex: 0 0 30px;
}
.ranked-item:nth-of-type(1) .ranked-item__rank { background: linear-gradient(135deg,#fbbf24,#f59e0b); color:#fff; }
.ranked-item:nth-of-type(2) .ranked-item__rank { background: linear-gradient(135deg,#a3a3a3,#737373); color:#fff; }
.ranked-item:nth-of-type(3) .ranked-item__rank { background: linear-gradient(135deg,#d97706,#92400e); color:#fff; }
.ranked-item__body { flex: 1 1 auto; min-width: 0; }
.ranked-item__title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--ag-text);
    margin: 0 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ranked-item__meta {
    font-size: .8rem;
    color: var(--ag-text-mute);
    margin: 0;
}
.ranked-item__badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.ranked-item__badge img { width: 18px; height: 18px; }

/* ============= DROPZONE ============= */
.dropzone-ag {
    border: 2px dashed var(--ag-border-strong);
    border-radius: var(--ag-radius);
    padding: 28px;
    text-align: center;
    color: var(--ag-text-mute);
    background: var(--ag-surface-alt);
    transition: border-color .15s ease, background .15s ease;
    cursor: pointer;
}
.dropzone-ag:hover, .dropzone-ag.is-dragover {
    border-color: var(--ag-primary);
    background: var(--ag-primary-50);
    color: var(--ag-primary-700);
}
.dropzone-ag__icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    margin: 0 auto 10px;
    background: var(--ag-surface);
    border: 1px solid var(--ag-border);
    display: flex; align-items: center; justify-content: center;
    color: var(--ag-primary);
    font-size: 1.1rem;
}
.dropzone-ag__title { font-weight: 600; color: var(--ag-text); margin: 0; }
.dropzone-ag__hint  { font-size: .825rem; margin: 4px 0 0; }

/* ============= SKELETON LOADER ============= */
.skeleton {
    background: linear-gradient(90deg, #eef1f5 25%, #f8fafc 50%, #eef1f5 75%);
    background-size: 200% 100%;
    animation: ag-skeleton 1.4s ease infinite;
    border-radius: var(--ag-radius-sm);
    height: 16px;
}
.skeleton.skel-line  { height: 14px; margin-bottom: 8px; }
.skeleton.skel-title { height: 22px; width: 60%; }
.skeleton.skel-block { height: 80px; }
.skeleton.skel-avatar { height: 40px; width: 40px; border-radius: 50%; }
@keyframes ag-skeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============= CHART CARD (heading + acciones) ============= */
.chart-card .card-header {
    align-items: center;
    border-bottom: 1px solid var(--ag-border);
}
.chart-card .card-header .card-title { display: flex; align-items: center; gap: 8px; }
.chart-card .card-header .card-title h4 { margin: 0; }
.chart-card .card-body canvas { width: 100% !important; height: auto !important; max-height: 320px; }

/* ============= AVATAR ============= */
.avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--ag-surface-alt);
    border: 1px solid var(--ag-border);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
    color: var(--ag-text-soft);
}
.avatar-sm { width: 28px; height: 28px; font-size: .75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar-group { display: inline-flex; }
.avatar-group .avatar + .avatar { margin-left: -10px; box-shadow: 0 0 0 2px var(--ag-surface); }

/* ============= UTILIDADES ============= */
.gap-2  { gap: 8px !important; }
.gap-3  { gap: 12px !important; }
.gap-4  { gap: 16px !important; }
.gap-5  { gap: 24px !important; }
.text-soft { color: var(--ag-text-soft) !important; }
.text-mute { color: var(--ag-text-mute) !important; }
.fw-700 { font-weight: 700 !important; }
.fw-600 { font-weight: 600 !important; }
