/* Modern Dark Theme Variables */
:root {
    --bg-body: #0f0f12;
    --bg-surface: #1a1a1f;
    --bg-surface-hover: #24242b;
    --bg-input: #131316;

    --primary: #fe2c55;
    --primary-hover: #e62248;
    --primary-glow: rgba(254, 44, 85, 0.3);

    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --text-dark: #71717a;

    --border: #2d2d35;
    --border-hover: #3f3f4b;

    --success: #25f4ee;
    --success-glow: rgba(37, 244, 238, 0.2);
    --danger: #ff3b30;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px var(--primary-glow);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 1.5rem;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* Header */
header {
    background: rgba(15, 15, 18, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 40px;
}

header h1 {
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.card h2 {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.25rem;
}

/* Stats Grid */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 8px;
    background: linear-gradient(to right, var(--text-main), var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="text"],
select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-surface);
}

/* Buttons */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

button:active {
    transform: translateY(0);
}

button.secondary {
    background: var(--bg-surface-hover);
    color: var(--text-main);
    border: 1px solid var(--border);
}

button.secondary:hover {
    border-color: var(--text-muted);
    background: var(--border);
}

button.danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

button.danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

/* Lists */
.user-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.user-item:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-actions {
    display: flex;
    gap: 8px;
}

.username {
    font-weight: 600;
    color: var(--text-main);
    font-size: 1.05rem;
}

.timestamp {
    color: var(--text-dark);
    font-size: 0.85rem;
    margin-top: 2px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge.live {
    background: rgba(37, 244, 238, 0.1);
    color: var(--success);
    border-color: rgba(37, 244, 238, 0.3);
    box-shadow: 0 0 12px rgba(37, 244, 238, 0.1);
    animation: pulse 2s infinite;
}

.badge.live::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    margin-right: 6px;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 244, 238, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(37, 244, 238, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(37, 244, 238, 0);
    }
}

/* Alerts */
.alert {
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.95rem;
    display: none;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert.success {
    background: rgba(37, 244, 238, 0.1);
    border: 1px solid rgba(37, 244, 238, 0.2);
    color: var(--success);
}

.alert.error {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.2);
    color: var(--danger);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.2;
}

/* Utilities */
.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, #ff0050 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    header {
        padding: 16px 0;
        margin-bottom: 24px;
        position: relative;
        top: auto;
    }
    
    /* Active Recordings Mobile Styles */
    #active-recordings-container .user-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }
    
    #active-recordings-container .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    #active-recordings-container .timestamp {
        font-size: 0.8rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    header nav {
        flex-wrap: wrap;
        gap: 12px !important;
        margin-top: 12px;
    }

    header nav a {
        font-size: 0.875rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .card {
        padding: 20px;
        margin-bottom: 16px;
    }

    .card h2 {
        font-size: 1.1rem;
        margin-bottom: 16px;
    }

    .stats {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-bottom: 24px;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 2rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .form-group {
        margin-bottom: 16px;
    }

    input[type="text"],
    select {
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    button {
        padding: 10px 20px;
        font-size: 0.9rem;
        width: 100%;
        margin-bottom: 8px;
    }

    button.secondary,
    button.danger {
        width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    table thead,
    table tbody,
    table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }

    table th,
    table td {
        padding: 8px !important;
        font-size: 0.85rem;
    }

    .badge {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    #edit-modal .card {
        margin: 10px;
        max-width: calc(100% - 20px);
        padding: 20px;
    }

    #edit-modal h2 {
        font-size: 1.1rem;
    }

    #edit-modal button {
        width: 100%;
        margin-bottom: 8px;
    }

    #pagination {
        flex-wrap: wrap;
        gap: 6px !important;
    }

    #pagination button {
        padding: 8px 12px;
        font-size: 0.85rem;
        width: auto;
        min-width: 40px;
        margin-bottom: 0;
    }

    .user-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 16px;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .alert {
        padding: 12px;
        font-size: 0.9rem;
    }

    canvas {
        max-height: 300px !important;
    }

    header .container>div {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    td button {
        display: block;
        width: 100%;
        margin: 4px 0;
    }

    button:hover {
        transform: none;
    }

    button.secondary:hover,
    button.danger:hover {
        transform: none;
    }

    button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 0 20px;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    table th,
    table td {
        padding: 10px !important;
    }
}

/* Header & Nav Refactor */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: 16px;
}

.nav-links a {
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--text-main);
}

/* Toggle Button Styles for Statistics Page */
.toggle-btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
}

/* Admin Page Styles */
.admin-actions {
    display: flex;
    gap: 12px;
}

.admin-nav-buttons {
    display: flex;
    gap: 12px;
}

.nav-button {
    flex: 1;
    padding: 12px;
    text-align: center;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.nav-button:hover {
    opacity: 0.9;
}

.nav-button.secondary {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border);
}

/* Mobile Responsiveness Updates */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .admin-actions {
        width: 100%;
        gap: 8px;
    }
    
    .admin-actions button {
        flex: 1;
        padding: 10px;
        font-size: 0.9rem;
    }
    
    .admin-nav-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .nav-button {
        width: 100%;
        padding: 12px;
    }
    
    /* Admin Stats Card Mobile */
    .admin-stats-card > div {
        grid-template-columns: 1fr 1fr !important;
        gap: 16px !important;
    }
    
    /* Search Input Mobile */
    #search-input {
        padding: 10px !important;
        font-size: 0.95rem !important;
    }
    
    /* User Management Mobile Styles */
    .user-item {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }
    
    .user-info {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    
    .user-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .user-actions button {
        width: 100%;
        margin: 0;
    }
    
    /* Active Users Table Mobile Styles */
    #users-container table {
        font-size: 0.9rem;
    }
    
    #users-container table tbody td {
        padding: 8px 4px;
    }
    
    #users-container table tbody td[data-label="User Agent"] {
        font-size: 0.8rem;
    }
    
    /* Responsive Table (Card View) */
    .responsive-table thead {
        display: none;
    }
    
    .responsive-table tr {
        display: block;
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: 16px;
        padding: 16px;
    }
    
    .responsive-table td {
        display: block;
        text-align: right;
        padding: 8px 0;
        border-bottom: 1px solid var(--border-light);
    }
    
    .responsive-table td:last-child {
        border-bottom: none;
    }
    
    .responsive-table td::before {
        content: attr(data-label) ": ";
        float: left;
        font-weight: bold;
        color: var(--text-muted);
    }
    
    /* Admin Users Page Specific */
    #users-container table thead {
        display: none;
    }
    
    #users-container table tbody tr {
        display: block;
        background: var(--bg-surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: 16px;
        padding: 16px;
    }
    
    #users-container table tbody td {
        display: block;
        text-align: right;
        padding: 8px 0;
        border-bottom: 1px solid var(--border-light);
        font-size: 0.9rem;
    }
    
    #users-container table tbody td:last-child {
        border-bottom: none;
    }
    
    #users-container table tbody td::before {
        content: attr(data-label) ": ";
        float: left;
        font-weight: bold;
        color: var(--text-muted);
    }
}