/* assets/css/nexus.css - Global Nexus Design System */

.nexus-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-base);
    backdrop-filter: blur(var(--blur-radius));
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.premium-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    background: var(--bg-surface);
    backdrop-filter: blur(var(--blur-radius));
    padding: 1.25rem 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-base);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.nexus-stat-card {
    background: var(--bg-glass);
    padding: 1rem;
    border-radius: var(--radius-md, 14px);
    border: 1px solid var(--border-base);
    backdrop-filter: blur(var(--blur-radius));
    box-shadow: var(--shadow-sm);
}

.nexus-stat-card .label {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nexus-stat-card .value {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 0.5rem;
    color: var(--text-main);
}

.nexus-table {
    width: 100%;
    border-collapse: collapse;
}

.nexus-table th {
    text-align: left;
    padding: 1.25rem 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 2px solid var(--border-subtle);
}

.nexus-table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text-main);
}

.nexus-table tr:hover {
    background: var(--nav-active-bg);
}

.nexus-table tr:last-child td {
    border-bottom: none;
}

.nexus-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-color), rgba(var(--primary-rgb), 0.7));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white !important;
    font-weight: 800;
    font-size: 1.2rem;
    box-shadow: var(--shadow-md);
}

.nexus-btn-primary {
    background: linear-gradient(135deg, var(--primary-color), rgba(var(--primary-rgb), 0.8));
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white !important;
    padding: 0.75rem 1.8rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.nexus-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.nexus-btn-secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border-base);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.nexus-btn-secondary:hover {
    background: var(--nav-active-bg);
    border-color: var(--text-muted);
}

.nexus-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white !important;
    padding: 0.75rem 1.8rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
}

.nexus-btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
    filter: brightness(1.1);
}

.nexus-btn-outline-danger {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444 !important;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.nexus-btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.status-badge {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
}

.status-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 900;
}

.nexus-tag {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-offline {
    background: rgba(100, 116, 139, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.2);
}

.status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.pulse-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
    animation: nexusPulse 2s infinite;
}

@keyframes nexusPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.2);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

/* Modal System */
.nexus-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(var(--blur-radius));
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.nexus-modal {
    background: var(--bg-surface);
    width: 500px;
    max-width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-base);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    /* display: none;  <-- REMOVED: Managed by Overlay */
    animation: modalIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.02);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.form-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.modal-footer {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.02);
    border-top: 1px solid var(--border-subtle);
}

.btn-confirm {
    background: var(--primary-color);
    border: none;
    color: white !important;
    padding: 0.75rem 2rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.btn-confirm:hover {
    box-shadow: var(--shadow-accent);
    transform: translateY(-1px);
}

.btn-cancel {
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    padding: 0.8rem 1.5rem;
    transition: color 0.2s;
}

.btn-cancel:hover {
    color: white;
}

.nexus-input-wrapper {
    position: relative;
    width: 100%;
}

.nexus-input-wrapper.search .nexus-input {
    padding-left: 3rem;
    background: var(--bg-surface);
}

.nexus-input-wrapper.search .search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
    transition: color 0.2s;
}

.nexus-input-wrapper.search .nexus-input:focus~.search-icon {
    color: var(--primary-color);
}

.nexus-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.nexus-input {
    background: var(--bg-elevated);
    border: 1px solid var(--border-base);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    /* Consistent rounding */
    width: 100%;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.95rem;
    appearance: none;
    /* For selects */
}

.nexus-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: var(--bg-surface);
}

.nexus-search {
    /* Legacy - kept for compatibility but preferred wrapper approach below */
    background: var(--bg-surface);
    border: 1px solid var(--border-base);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    width: 300px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nexus-search:focus {
    outline: none;
    border-color: var(--primary-color);
    width: 380px;
    box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Action Buttons */
.nexus-action-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-base);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
    text-decoration: none;
}

.nexus-action-btn:hover {
    background: var(--bg-elevated);
    transform: translateY(-2px);
    border-color: var(--primary-color) !important;
}

.nexus-action-btn.delete:hover {
    border-color: #ef4444 !important;
    color: #ef4444 !important;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* --- Mobile Responsiveness (Added Phase 30) --- */
@media (max-width: 900px) {

    /* 1. Global Stacking */
    .premium-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        padding: 1.5rem;
    }

    .premium-header>div {
        width: 100%;
    }

    .premium-header h1 {
        font-size: 1.8rem;
    }

    /* 2. Full Width Inputs */
    .nexus-search {
        width: 100% !important;
    }

    .search-container {
        width: 100%;
    }

    .nexus-btn-primary,
    .nexus-btn-secondary {
        width: 100%;
        justify-content: center;
    }

    /* 3. Stat Cards Grid */
    /* 3. Stat Cards Grid */
    /* html body .container .nexus-stat-card {} - Handled by grid-template-columns */

    /* 4. Table "Card View" Transformation */
    .mobile-card-view thead {
        display: none;
    }

    .mobile-card-view tr {
        display: block;
        background: var(--bg-surface);
        border: 1px solid var(--border-base);
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: var(--shadow-sm);
        position: relative;
    }

    .mobile-card-view td {
        display: flex;
        flex-wrap: wrap;
        /* Allow wrapping */
        justify-content: space-between;
        align-items: center;
        border: none;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--border-subtle);
        text-align: right;
        gap: 0.5rem;
        word-break: break-word;
        /* Ensure long words break */
    }

    /* Primary Column as Card Header */
    .mobile-card-view td:first-child {
        flex-direction: column;
        align-items: center;
        text-align: center;
        background: rgba(255, 255, 255, 0.03);
        margin: -1rem -1rem 1rem -1rem;
        /* Bleed to edges */
        padding: 1.5rem 1rem;
        border-bottom: 1px solid var(--border-base);
    }

    .mobile-card-view td:first-child::before {
        display: none;
        /* Hide Label for Header */
    }

    /* Force inner flex content of first cell to stack */
    .mobile-card-view td:first-child>div {
        flex-direction: column;
        gap: 0.5rem !important;
        width: 100%;
    }

    /* Ensure text in first cell wraps too */
    .mobile-card-view td:first-child span,
    .mobile-card-view td:first-child div {
        white-space: normal;
        word-break: break-word;
    }

    .mobile-card-view td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        /* Right align actions */
        padding-top: 1rem;
        width: 100%;
        gap: 0.8rem;
        position: relative;
        z-index: 10;
        /* Ensure clickable */
    }

    /* Hide Label for Actions Column to prevent overlap */
    .mobile-card-view td:last-child::before {
        display: none;
    }

    /* Larger Touch Targets on Mobile */
    .mobile-card-view .nexus-action-btn {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .mobile-card-view td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.75rem;
        margin-right: auto;
        /* Push label to left */
        text-align: left;
        flex-shrink: 0;
        /* Prevent label from shrinking */
    }

    .mobile-card-view .nexus-avatar {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }

    /* 5. Footer Stacking */
    footer div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        text-align: center;
    }

    footer p {
        margin: 0 auto;
    }

    footer div[style*="display: flex; flex-direction: column"] {
        align-items: center;
    }

    /* 6. Mobile Navigation (Drawer) */
    .mobile-menu-toggle {
        display: block !important;
        /* Visible on mobile */
        background: none;
        border: none;
        color: white;
        cursor: pointer;
        padding: 0.5rem;
    }

    .nav-links {
        display: none !important;
        /* Hide standard nav */
    }

    /* Fixed Drawer */
    #mobile-drawer {
        position: fixed;
        top: 0;
        left: 0;
        right: auto;
        bottom: 0;
        width: 300px;
        /* Slightly wider */
        background: rgba(15, 23, 42, 0.95);
        /* Deep dark blue */
        z-index: 3000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        padding: 2rem 1.5rem;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        /* Tighter gap */
        overflow-y: auto;
        backdrop-filter: blur(20px);
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.5);
    }

    #mobile-drawer.active {
        transform: translateX(0);
    }

    /* Overlay */
    #mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 2999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    #mobile-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile Nav Items */
    .mobile-nav-item {
        color: var(--text-muted);
        font-size: 1rem;
        font-weight: 500;
        padding: 0.75rem 1rem;
        border-radius: 8px;
        /* Rounded pill style */
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-decoration: none;
        border: 1px solid transparent;
        transition: all 0.2s;
    }

    .mobile-nav-item:hover {
        background: rgba(255, 255, 255, 0.05);
        color: white;
        transform: translateX(4px);
    }

    .mobile-nav-item.active {
        background: rgba(var(--primary-rgb), 0.1);
        color: var(--primary-color);
        font-weight: 700;
        border: 1px solid rgba(var(--primary-rgb), 0.2);
    }

    .mobile-nav-item.highlight {
        /* New Ticket Button Style */
        margin-top: 1rem;
        background: linear-gradient(135deg, var(--primary-color), rgba(var(--primary-rgb), 0.8));
        color: white !important;
        font-weight: 700;
        justify-content: center;
        box-shadow: 0 4px 15px var(--primary-glow);
    }

    .mobile-nav-item.exit {
        color: var(--danger-color);
        border-color: var(--danger-color);
    }

    .mobile-drawer-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--border-base);
    }

    .mobile-drawer-header .brand-text {
        font-size: 1.5rem;
        font-weight: 800;
        color: white;
    }

    .mobile-drawer-header .brand-text span {
        color: var(--primary-color);
    }

    .close-drawer-btn {
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 0.5rem;
    }

    .mobile-section-label {
        font-size: 0.75rem;
        text-transform: uppercase;
        color: var(--text-muted);
        font-weight: 800;
        letter-spacing: 0.05em;
        margin-top: 1rem;
        margin-bottom: 0.5rem;
    }

    .mobile-divider {
        height: 1px;
        background: var(--border-base);
        margin: 0.5rem 0;
    }
}

/* Default state for toggle (Hidden on Desktop) */
.mobile-menu-toggle {
    display: none;
}