/* =========================================================
   COMPONENTS.CSS · Botones, inputs, alertas, toasts, badges
   Design System limpio y organizado
   ========================================================= */

/* ── Botones ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radio, 10px);
    font-family: inherit;
    font-size: var(--text-body);
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn:hover {
    filter: brightness(.92);
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.btn-primario {
    background: var(--c-principal);
    color: var(--c-secundario-a);
}

.btn-primario:hover {
    background: var(--c-principal-hover);
}

.btn-secundario {
    background: var(--c-secundario-a);
    color: var(--c-blanco);
}

.btn-secundario:hover {
    background: #222;
}

.btn-acento {
    background: var(--peligro);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--texto);
    border-color: var(--borde);
}

.btn-ghost:hover {
    background: var(--fondo);
    filter: none;
}

.btn-outline {
    background: transparent;
    color: var(--c-principal-hover);
    border-color: var(--c-principal);
}

.btn-outline:hover {
    background: var(--c-principal-light);
    filter: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--text-xs);
}

/* ── Botones de Acción (icono) ─────────────────────────── */
.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radio-sm, 6px);

    background: none;
    color: var(--gris-texto, #6b7280);
    cursor: pointer;
    transition: all .15s;
    border: none;
}

.btn-icon:hover {
    color: var(--texto);
    background: var(--fondo);
}

.btn-icon svg {
    width: 15px;
    height: 15px;
}

.btn-icon.danger {
    color: var(--c-secundario-a);
}

.btn-icon.danger:hover {
    color: var(--c-secundario-a);
    background: rgba(239, 68, 68, .08);
}

.btn-icon.success {
    color: var(--exito, #10b981);
}

.btn-icon.success:hover {
    color: #059669;
    background: rgba(16, 185, 129, .08);
}

.btn-icon.primary {
    color: var(--c-principal);
}

.btn-icon.primary:hover {
    color: var(--c-principal-hover, #2563eb);
    background: rgba(59, 130, 246, .08);
}

/* ── Formularios ───────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: var(--text-2xs);
    font-weight: 600;
    color: var(--gris-texto);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

.form-label .req {
    color: var(--peligro);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--borde);
    border-radius: var(--radio-sm, 6px);
    font-family: inherit;
    font-size: var(--text-body);
    background: #fff;
    color: var(--texto);
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    outline: 0;
    border-color: var(--c-principal);
    box-shadow: 0 0 0 3px var(--c-principal-light);
}

.form-control::placeholder {
    color: var(--texto-soft, #a0a4ac);
}

.form-error {
    color: #c62828;
    font-size: .85rem;
    margin-top: .35rem;
}

/* ── Form Grid ─────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: var(--radio-lg, 14px);
    box-shadow: var(--sombra-sm);
    padding: 1.5rem;
}

.card-head {
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--borde-soft, #f0f1f4);
}

.card-head h2 {
    margin: 0;
    font-size: var(--text-base);
    font-weight: 600;
}

.card-head .muted {
    color: var(--gris-texto);
    font-size: var(--text-xs);
    font-weight: 400;
    margin-top: 2px;
}

.card-body {
    padding: 20px 22px;
}

/* ── Alertas ───────────────────────────────────────────── */
.alert {
    padding: .8rem 1rem;
    border-radius: var(--radio, 10px);
    margin-bottom: 1rem;
    font-size: .9rem;
}

.alert-error {
    background: #fdecea;
    color: #b71c1c;
    border-left: 4px solid #c62828;
}

.alert-success {
    background: #e8f5e9;
    color: #1b5e20;
    border-left: 4px solid #2e7d32;
}

.alert-info {
    background: #e3f2fd;
    color: #0d47a1;
    border-left: 4px solid #1976d2;
}

/* ── Toasts (notificaciones flotantes) ─────────────────── */
.toast-stack,
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    min-width: 320px;
    max-width: 440px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 14px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: none;

    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 500;
    color: #fff;

    animation: toast-in .28s cubic-bezier(.2, .8, .3, 1);
}

.toast.leaving {
    animation: toast-out .22s ease forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-6px) scale(.98);
    }
}

/* Ícono a la izquierda */
.toast .t-ic {
    flex: none;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    border-radius: 4px;
}

/* Cuerpo (título + mensaje opcional) */
.toast .t-body {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.toast .t-title {
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.005em;
}

.toast .t-msg {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.45;
}

/* Botón cerrar */
.toast .t-close {
    flex: none;
    border: 0;
    background: transparent;
    color: #fff;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.toast .t-close:hover {
    opacity: 1;
}

.toast .t-bar {
    display: none;
}

/* Variantes semánticas */
.toast.success {
    background: #16a34a;
    /* Verde */
}

.toast.error {
    background: #dc2626;
    /* Rojo */
}

.toast.info {
    background: #2563eb;
    /* Azul */
}

/* ── Spinner para botones ──────────────────────────────── */
.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}



.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* ── Avatar iniciales ──────────────────────────────────── */
.avatar-iniciales {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--c-principal-light);
    color: var(--c-principal-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: .03em;
    flex-shrink: 0;
}

.avatar-iniciales.dark {
    background: var(--c-secundario-a);
    color: var(--c-principal);
}

/* ── User Pill (tabla) ─────────────────────────────────── */
.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill .info .name {
    font-weight: 600;
    color: var(--texto);
    font-size: var(--text-body);
}

.user-pill .info .meta {
    color: var(--gris-texto);
    font-size: var(--text-xs);
}

/* ── Acciones wrap ─────────────────────────────────────── */
.acciones-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ── Tabs (page-level) & Segmented ─────────────────────────────────── */
.tabs,
.vista-switch,
.segmented {
    display: inline-flex;
    background: #ffffff;
    border-radius: var(--radio-pill, 999px);
    padding: 6px;
    gap: 4px;
    border: 1px solid var(--borde, #e8e9ed);
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.tab,
.vista-btn,
.segmented button {
    padding: 8px 18px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gris-texto);
    border: none;
    background: transparent;
    border-radius: var(--radio-pill, 999px);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all .15s;
    font-family: inherit;
    margin: 0;
}

.tab:hover,
.vista-btn:hover,
.segmented button:hover {
    color: var(--texto);
}

.tab.active,
.vista-btn.active,
.segmented button.active {
    background: var(--c-principal, #FE5100);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(254, 81, 0, 0.2);
}

.tab.active::after,
.vista-btn.active::after {
    display: none !important;
}

/* ── Empty State ───────────────────────────────────────── */
.empty {
    padding: 60px 24px;
    text-align: center;
    color: var(--gris-texto);
}

.empty h3 {
    color: var(--texto);
    margin: 12px 0 4px;
    font-size: var(--text-base);
}

.empty p {
    margin: 0;
    font-size: var(--text-body);
}

/* ── Pagination ────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 22px;
    border-top: 1px solid var(--borde-soft, #f0f1f4);
    font-size: var(--text-xs);
    color: var(--gris-texto);
}

.pagination .pages {
    display: flex;
    gap: 4px;
}

.pagination .pages button {
    width: 28px;
    height: 28px;
    border-radius: var(--radio-sm, 6px);
    border: 1px solid var(--borde);
    background: #fff;
    font-weight: 500;
    color: var(--gris-texto);
    font-size: var(--text-xs);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: inherit;
}

.pagination .pages button.active {
    background: var(--c-secundario-a);
    color: #fff;
    border-color: var(--c-secundario-a);
}

.pagination .pages button:hover:not(.active) {
    background: var(--fondo);
}

/* ── Scrollbar slim ────────────────────────────────────── */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--c-principal);
    border-radius: 10px;
    border: 2px solid var(--fondo);
}

::-webkit-scrollbar-thumb:hover {
    background: #b4b6bd;
}