/* Premium CSS Design System - Dark Mode, Glassmorphic Dashboard */
:root {
    --bg-dark: #0f111a;
    --bg-panel: rgba(22, 28, 45, 0.45);
    --bg-panel-solid: #161c2d;
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(255, 255, 255, 0.15);
    
    --primary: #5856d6;
    --primary-glow: rgba(88, 86, 214, 0.4);
    --primary-hover: #6c6af2;
    
    --success: #34c759;
    --success-glow: rgba(52, 199, 89, 0.3);
    
    --warning: #ff9500;
    
    --danger: #ff3b30;
    
    --text-main: #f5f6f9;
    --text-muted: #8e9bb2;
    --text-inverse: #ffffff;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --glass-blur: blur(16px) saturate(120%);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    /* Neon glow spots in background */
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(88, 86, 214, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(52, 199, 89, 0.1) 0%, transparent 40%);
    background-attachment: fixed;
}

/* App container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar navigation */
.sidebar {
    width: 280px;
    background: rgba(10, 12, 22, 0.8);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-glass);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3rem;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary) 0%, #007aff 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.logo-text h1 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: 10px;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--text-inverse);
    background: var(--primary);
    box-shadow: 0 4px 20px var(--primary-glow);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tenant-selector-area label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
    display: block;
}

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

select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    appearance: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.select-wrapper::after {
    content: '▼';
    font-size: 0.7rem;
    color: var(--text-muted);
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

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

.header-title h2 {
    font-size: 1.8rem;
    font-weight: 700;
}

.header-title p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

.status-indicator {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-indicator::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
}

.status-indicator.online::before {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

/* Cards & Layout */
.card {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: var(--border-glass-hover);
}

.card-header {
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.metric-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-icon svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.users-blue {
    background: rgba(88, 86, 214, 0.15);
    color: #5856d6;
}

.devices-purple {
    background: rgba(175, 82, 222, 0.15);
    color: #af52de;
}

.status-green {
    background: rgba(52, 199, 89, 0.15);
    color: #34c759;
}

.metric-info h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 4px;
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .grid-2-1 {
        grid-template-columns: 1fr;
    }
}

/* Buttons */
.btn {
    font-family: var(--font-sans);
    padding: 12px 24px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--border-glass-hover);
}

.btn-danger {
    background: rgba(255, 59, 48, 0.15);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(255, 59, 48, 0.25);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    background: transparent;
    padding: 8px;
    border-radius: 8px;
    color: var(--text-muted);
}

.btn-icon:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.btn-mini {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Enrollment box */
.enrollment-box {
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 0.95rem;
}

.token-display {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 8px 16px;
    align-items: center;
    justify-content: space-between;
}

.token-display code {
    font-family: monospace;
    font-size: 0.95rem;
    color: #e5c07b;
    word-break: break-all;
}

.info-alert {
    background: rgba(88, 86, 214, 0.08);
    border-left: 4px solid var(--primary);
    padding: 16px;
    border-radius: 4px 8px 8px 4px;
}

.info-alert pre {
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.85rem;
}

.actions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Tabs */
.tab-content {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 16px;
    border-bottom: 2px solid var(--border-glass);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-active {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
}

.badge-disabled {
    background: rgba(255, 59, 48, 0.15);
    color: var(--danger);
}

.badge-role {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
    margin-right: 4px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

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

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-sans);
    transition: var(--transition-smooth);
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    height: 18px;
    width: 18px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.checkbox-container:hover input ~ .checkmark {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--border-glass-hover);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.field-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 2rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(22, 28, 45, 0.9);
    border: 1px solid var(--primary);
    box-shadow: 0 4px 20px var(--primary-glow);
    padding: 12px 24px;
    border-radius: 8px;
    color: var(--text-main);
    z-index: 1100;
    display: none;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--danger); }

/* v0.2 MSP authentication and audit additions */
.login-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, rgba(124, 77, 255, 0.18), rgba(5, 8, 22, 0.96));
    backdrop-filter: blur(18px);
    z-index: 9999;
}

.login-card {
    width: min(420px, calc(100vw - 32px));
    padding: 32px;
    border: 1px solid var(--border-glass);
    border-radius: 22px;
    background: var(--card-bg);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.login-card h1 {
    margin: 12px 0 4px;
    font-size: 1.5rem;
}

.login-card p {
    margin: 0 0 22px;
    opacity: 0.75;
}

.login-logo {
    width: 52px;
    height: 52px;
    font-size: 0.95rem;
}

.login-help {
    margin-top: 14px;
    font-size: 0.8rem;
    opacity: 0.75;
    line-height: 1.35;
}

.login-error {
    margin-top: 12px;
    color: var(--danger);
    font-size: 0.9rem;
    min-height: 1.2em;
}

.app-container.locked {
    filter: blur(3px);
    pointer-events: none;
    user-select: none;
}

.version-label {
    margin-top: 12px;
    text-align: center;
    font-size: 0.75rem;
    opacity: 0.65;
}
