:root {
    --bg-dark: #0f1115;
    --bg-secondary: #161b22;
    --bg-tertiary: #1f242c;
    --accent-primary: #3b82f6;
    /* Blue */
    --accent-glow: rgba(59, 130, 246, 0.4);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --border-color: #2d3139;
    --success: #10b981;
    --danger: #ef4444;
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-stack);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: rgba(22, 27, 34, 0.8);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-sizing: border-box;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background-color: var(--bg-tertiary);
    /* fallback */
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-item.active {
    border-left: 3px solid var(--accent-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.avatar {
    width: 32px;
    height: 32px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-logout {
    font-size: 0.75rem;
    color: white;
    background: var(--danger);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    margin-top: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    width: 100%;
}

.btn-logout:hover {
    filter: brightness(1.2);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}



/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top right, #1f2937 0%, transparent 25%);
    overflow-y: auto;
}

.top-bar {
    padding: 32px 48px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#page-title {
    font-size: 2rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.actions {
    display: flex;
    gap: 16px;
}

.btn-secondary,
.btn-primary {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: var(--transition);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
    filter: brightness(1.1);
}

.view-content {
    padding: 0 48px 48px 48px;
    flex: 1;
}

/* Dashboard Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.metric-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: var(--transition);
}

.metric-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.metric-card h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-card .value {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 12px 0;
    background: linear-gradient(90deg, #fff, #9ca3af);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;

}

.trend {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.trend.up {
    color: var(--success);
}

.trend.stable {
    color: var(--text-secondary);
}

.trend.down {
    color: var(--danger);
}

/* Utility */
.loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top: 3px solid var(--accent-primary);
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 24px;
}

th {
    text-align: left;
    color: var(--text-secondary);
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border-color);
}

/* scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* Test Mode Toggle */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.mode-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: #f59e0b;
    /* Orange for Test Mode */
}

input:focus+.slider {
    box-shadow: 0 0 1px #f59e0b;
}

input:checked+.slider:before {
    -webkit-transform: translateX(16px);
    -ms-transform: translateX(16px);
    transform: translateX(16px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Test Mode Active State */
body.test-mode-active .top-bar {
    border-bottom: 2px solid #f59e0b;
}

body.test-mode-active .mode-label {
    color: #f59e0b;
    font-weight: 700;
}

body.test-mode-active #page-title:after {
    content: " (TEST MODE)";
    font-size: 0.5em;
    vertical-align: middle;
    color: #f59e0b;
    margin-left: 10px;
    background: rgba(245, 158, 11, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: var(--transition);
}

.modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 24px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-badge.suspended {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.status-badge.cancelled {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.status-badge.expired {
    background: rgba(156, 163, 175, 0.2);
    color: var(--text-secondary);
}

/* Table Actions */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.search-bar {
    margin-bottom: 16px;
}

.search-bar input {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 80px;
        padding: 24px 12px;
    }

    .brand span,
    .user-info,
    .nav-item span {
        display: none;
    }
}