/* ========================
   COMPONENTS — NexusPoint
   Toast, Loader, Confirm
======================== */

/* ——— Toast Notifications ——— */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 420px;
    padding: 16px 20px;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    backdrop-filter: blur(12px);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.toast.toast-out {
    animation: toastOut 0.3s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

.toast-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.toast-body {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.toast-msg {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    flex-shrink: 0;
}

.toast-close:hover {
    color: white;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 12px 12px;
    animation: progressShrink 4s linear forwards;
}

.toast.success {
    border-left: 4px solid #38ef7d;
}

.toast.success .toast-progress {
    background: var(--bg-global);
}

.toast.error {
    border-left: 4px solid #f5576c;
}

.toast.error .toast-progress {
    background: #f5576c;
}

.toast.warning {
    border-left: 4px solid #fee140;
}

.toast.warning .toast-progress {
    background: #fee140;
}

.toast.info {
    border-left: 4px solid var(--primary);
}

.toast.info .toast-progress {
    background: var(--primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(80px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(80px);
    }
}

@keyframes progressShrink {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

/* ——— Loading Overlay ——— */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
    display: inline-block;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ——— Inline loader for buttons ——— */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

/* ——— Confirm Modal ——— */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.confirm-box {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 90vw;
    box-shadow: var(--shadow);
    text-align: center;
}

.confirm-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.confirm-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.confirm-msg {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.confirm-actions .btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
    transition: 0.2s;
}

.confirm-cancel {
    background: var(--border);
    color: var(--text-primary);
}

.confirm-cancel:hover {
    background: var(--border);
}

.confirm-accept {
    background: var(--primary);
    color: white;
}

.confirm-accept:hover {
    background: #5a6fd6;
}

.confirm-danger {
    background: #ef4444;
    color: white;
}

.confirm-danger:hover {
    background: #dc2626;
}

/* ——— Empty States ——— */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-msg {
    font-size: 0.85rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ——— Focus indicators ——— */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ——— Hamburger Menu ——— */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 8px;
    z-index: 10001;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    z-index: 9990;
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    /* Stat grids */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Table overflow */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modals responsive */
    .modal-content {
        width: 95vw !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    /* Charts responsive */
    .charts-container {
        grid-template-columns: 1fr !important;
    }

    /* Toast position */
    .toast-container {
        top: auto;
        bottom: 16px;
        left: 16px;
        right: 16px;
    }

    .toast {
        min-width: unset;
        width: 100%;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .charts-container {
        grid-template-columns: 1fr !important;
    }
}

/* ——— Utility fades ——— */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ——— Skeleton Loader ——— */
.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--hover-bg) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 10px;
    width: 80%;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-text.full {
    width: 100%;
}

.skeleton-card {
    height: 120px;
    border-radius: var(--radius-lg);
}

.skeleton-row {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.skeleton-cell {
    height: 16px;
    flex: 1;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ——— Success Animation ——— */
.success-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(56, 239, 125, 0.15);
    color: var(--success);
    font-size: 1.5rem;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================
   SPRINT 15 — Glassmorphism
======================== */

/* ——— Glass Card ——— */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

/* ——— Sidebar Dock — vars.css es la fuente de verdad ——— */
/* nav-text eliminado — reemplazado por .nav-label en vars.css */
.sidebar .nav-item .nav-text { display: none; }
.sidebar .nav-item:hover .nav-text { display: none; }

/* ——— Top Header Bar ——— */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--hover-bg-subtle);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--table-border);
    margin-bottom: 24px;
    border-radius: 0;
    gap: 16px;
}

.top-header .page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.top-header .search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.top-header .search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.top-header .search-box input::placeholder {
    color: var(--text-secondary);
}

.top-header .search-box input:focus {
    border-color: var(--primary);
    background: var(--input-focus-bg);
}

.top-header .search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.top-header .user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-header .avatar-wrapper {
    position: relative;
    width: 38px;
    height: 38px;
}

.top-header .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
}

.top-header .online-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--bg-dark);
    animation: pulse-online 2s ease-in-out infinite;
}

@keyframes pulse-online {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
}

.top-header .user-info {
    display: flex;
    flex-direction: column;
}

.top-header .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.top-header .user-role {
    font-size: 0.7rem;
    color: #22c55e;
    font-weight: 500;
}

/* ——— Main content — margen gestionado por vars.css ——— */

/* ——— Mobile override ——— */
@media (max-width: 768px) {
    .main-content,
    .main {
        margin-left: 0 !important;
        /* padding gestionado por vars.css @media 640px */
    }

    .top-header {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .top-header .search-box {
        order: 3;
        max-width: 100%;
        width: 100%;
    }

    .top-header .user-info {
        display: none;
    }
}