/* ========================= Nexus Advanced UI Components ========================= */

/* Modern Icon System */
.nexus-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.nexus-icon--sm {
    width: 16px;
    height: 16px;
    font-size: 12px;
}

.nexus-icon--lg {
    width: 32px;
    height: 32px;
    font-size: 24px;
}

.nexus-icon--xl {
    width: 48px;
    height: 48px;
    font-size: 32px;
}

.nexus-icon--accent {
    color: hsl(var(--accent));
    text-shadow: 0 0 10px hsl(var(--accent) / 0.3);
}

.nexus-icon--glow {
    animation: nexus-glow 2s ease-in-out infinite alternate;
}

/* Enhanced Dashboard Widgets */
.nexus-widget {
    background: var(--gradient-card);
    border: 1px solid hsl(var(--gray-800));
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nexus-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-button);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nexus-widget:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: hsl(var(--accent) / 0.3);
}

.nexus-widget:hover::before {
    opacity: 1;
}

.nexus-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid hsl(var(--gray-800) / 0.5);
}

.nexus-widget__title {
    font-family: var(--accent-font);
    font-size: 16px;
    font-weight: 600;
    color: hsl(var(--text-primary));
    margin: 0;
}

.nexus-widget__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--gradient-button);
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--obsidian));
    font-size: 18px;
    box-shadow: var(--shadow-md);
}

.nexus-widget__content {
    position: relative;
    z-index: 2;
}

.nexus-widget__value {
    font-family: var(--accent-font);
    font-size: 2.25rem;
    font-weight: 700;
    color: hsl(var(--text-primary));
    margin-bottom: 4px;
    line-height: 1;
}

.nexus-widget__label {
    font-size: 14px;
    color: hsl(var(--text-secondary));
    margin-bottom: 12px;
}

.nexus-widget__trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
}

.nexus-widget__trend--up {
    color: hsl(var(--accent));
}

.nexus-widget__trend--down {
    color: hsl(0 100% 60%);
}

/* Advanced Tooltips */
.nexus-tooltip {
    position: relative;
    display: inline-block;
}

.nexus-tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: hsl(var(--obsidian) / 0.95);
    color: hsl(var(--text-primary));
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid hsl(var(--gray-700));
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.nexus-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 4px solid transparent;
    border-top-color: hsl(var(--obsidian) / 0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.nexus-tooltip:hover::before,
.nexus-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Modern Dropdown System */
.nexus-dropdown {
    position: relative;
    display: inline-block;
}

.nexus-dropdown__toggle {
    background: var(--gradient-charcoal);
    border: 1px solid hsl(var(--gray-700));
    border-radius: 8px;
    padding: 10px 16px;
    color: hsl(var(--text-primary));
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.nexus-dropdown__toggle:hover {
    background: var(--gradient-slate);
    border-color: hsl(var(--accent) / 0.5);
}

.nexus-dropdown__menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--gradient-card);
    border: 1px solid hsl(var(--gray-800));
    border-radius: 8px;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    min-width: 200px;
    margin-top: 4px;
}

.nexus-dropdown.active .nexus-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nexus-dropdown__item {
    padding: 12px 16px;
    color: hsl(var(--text-secondary));
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid hsl(var(--gray-800) / 0.3);
}

.nexus-dropdown__item:last-child {
    border-bottom: none;
}

.nexus-dropdown__item:hover {
    background: hsl(var(--slate) / 0.5);
    color: hsl(var(--text-primary));
}

.nexus-dropdown__item.active {
    background: var(--gradient-button);
    color: hsl(var(--obsidian));
}

/* Enhanced Modal System */
.nexus-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: hsl(var(--obsidian) / 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 2000;
}

.nexus-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.nexus-modal-dialog {
    background: var(--gradient-card);
    border: 1px solid hsl(var(--gray-800));
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(20px);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nexus-modal-overlay.active .nexus-modal-dialog {
    transform: scale(1) translateY(0);
}

.nexus-modal-header {
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nexus-modal-title {
    font-family: var(--accent-font);
    font-size: 20px;
    font-weight: 600;
    color: hsl(var(--text-primary));
    margin: 0;
}

.nexus-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid hsl(var(--gray-700));
    color: hsl(var(--text-secondary));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.nexus-modal-close:hover {
    background: hsl(var(--slate));
    border-color: hsl(var(--accent) / 0.5);
    color: hsl(var(--text-primary));
}

.nexus-modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.nexus-modal-footer {
    padding: 0 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Advanced Data Visualization */
.nexus-chart-container {
    background: var(--gradient-card);
    border: 1px solid hsl(var(--gray-800));
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.nexus-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.nexus-chart-title {
    font-family: var(--accent-font);
    font-size: 16px;
    font-weight: 600;
    color: hsl(var(--text-primary));
}

.nexus-chart-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.nexus-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: hsl(var(--text-secondary));
}

.nexus-chart-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Enhanced Timeline Component */
.nexus-timeline {
    position: relative;
    padding-left: 30px;
}

.nexus-timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, hsl(var(--accent)) 0%, hsl(var(--gray-800)) 100%);
}

.nexus-timeline-item {
    position: relative;
    margin-bottom: 24px;
    background: var(--gradient-card);
    border: 1px solid hsl(var(--gray-800));
    border-radius: 8px;
    padding: 16px;
    margin-left: 15px;
}

.nexus-timeline-item::before {
    content: '';
    position: absolute;
    left: -23px;
    top: 20px;
    width: 12px;
    height: 12px;
    background: hsl(var(--accent));
    border-radius: 50%;
    border: 2px solid hsl(var(--charcoal));
    box-shadow: 0 0 10px hsl(var(--accent) / 0.3);
}

.nexus-timeline-time {
    font-size: 12px;
    color: hsl(var(--text-muted));
    margin-bottom: 4px;
}

.nexus-timeline-title {
    font-weight: 600;
    color: hsl(var(--text-primary));
    margin-bottom: 4px;
}

.nexus-timeline-desc {
    font-size: 14px;
    color: hsl(var(--text-secondary));
    line-height: 1.4;
}

/* Modern Toggle Switch */
.nexus-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.nexus-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.nexus-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: hsl(var(--gray-700));
    transition: 0.3s;
    border-radius: 24px;
    border: 1px solid hsl(var(--gray-600));
}

.nexus-toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: hsl(var(--white));
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.nexus-toggle input:checked + .nexus-toggle-slider {
    background: var(--gradient-button);
    border-color: hsl(var(--accent));
}

.nexus-toggle input:checked + .nexus-toggle-slider::before {
    transform: translateX(24px);
    background: hsl(var(--obsidian));
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .nexus-widget {
        padding: 16px;
    }
    
    .nexus-widget__value {
        font-size: 1.75rem;
    }
    
    .nexus-modal-dialog {
        width: 95%;
        margin: 20px;
    }
    
    .nexus-timeline {
        padding-left: 20px;
    }
    
    .nexus-timeline-item {
        margin-left: 10px;
    }
}
