/* Admin-specific styles */

.section-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.inactive-toggle {
    white-space: nowrap;
}

.inactive-toggle .toggle-label {
    font-size: 0.8125rem;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: 22px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.toggle-label {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.search-container {
    position: relative;
    min-width: 220px;
}

.search-container input {
    width: 100%;
    padding: 8px 36px 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.8125rem;
    transition: all 0.15s ease;
}

.search-container input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-shadow);
}

.search-container input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Table */
.table-container {
    background: var(--container-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.users-table th,
.users-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.users-table th {
    background: var(--surface);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
}

.users-table tbody tr {
    transition: background 0.1s ease;
}

.users-table tbody tr:hover {
    background: var(--surface);
}

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

.users-table .user-info {
    display: block !important;
    padding: 0;
    background: none;
    border: none;
}

.username {
    font-weight: 600;
    color: var(--text-primary);
    display: inline !important;
}

.email {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.roles {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.role-badge.admin {
    background: var(--error-bg);
    color: var(--error-text);
}

.role-badge.user {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.role-badge.moderator {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
}

[data-theme="dark"] .role-badge.moderator {
    color: #6ee7b7;
}

.role-badge.service {
    background: var(--accent-subtle);
    color: var(--accent);
}

.role-badge.system {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.role-badge.vpn {
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
}

[data-theme="dark"] .role-badge.vpn {
    color: #34d399;
}

.role-badge.tester {
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
}

[data-theme="dark"] .role-badge.tester {
    color: #fbbf24;
}

.role-badge:not(.admin):not(.user):not(.moderator):not(.service):not(.system):not(.vpn):not(.tester) {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge.active {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-badge.inactive {
    background: var(--error-bg);
    color: var(--error-text);
}

.last-login {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.action-buttons {
    display: flex;
    gap: 4px;
}

.action-btn {
    padding: 10px 16px;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 8px var(--accent-shadow);
}

.action-btn.small {
    padding: 6px 8px;
    font-size: 0.75rem;
    min-width: auto;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.action-btn.small svg {
    margin: 0;
}

.action-btn.secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.action-btn.secondary:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

.loading-container {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 0.6s linear infinite;
    margin-bottom: 12px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state h3 {
    color: var(--text-primary);
    margin: 12px 0 8px 0;
    font-weight: 600;
}

.empty-state p {
    margin: 0;
    font-size: 0.875rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

[data-theme="dark"] .modal {
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background: var(--container-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

.close-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: all 0.15s ease;
}

.close-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.form-section {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
}

.section-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Role Checkboxes */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.role-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    background: var(--input-bg);
}

.role-checkbox:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.role-checkbox input[type="checkbox"] {
    display: none;
}

.role-checkmark {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    position: relative;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.role-checkmark::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 4px;
    width: 4px;
    height: 7px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.role-checkbox input[type="checkbox"]:checked + .role-checkmark {
    background: var(--accent);
    border-color: var(--accent);
}

.role-checkbox input[type="checkbox"]:checked + .role-checkmark::after {
    opacity: 1;
}

.role-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Modal Buttons */
.modal-buttons {
    display: flex;
    gap: 8px;
    padding: 20px 24px;
    justify-content: flex-end;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.8125rem;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 8px var(--accent-shadow);
}

.btn-primary:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

.modal-message {
    margin: 12px 24px 0;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 500;
    font-size: 0.8125rem;
}

.modal-message.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.modal-message.error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

/* Responsive */
@media (max-width: 768px) {
    .section-controls {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .search-container {
        min-width: auto;
    }

    .table-container {
        overflow-x: auto;
    }

    .users-table {
        min-width: 650px;
    }

    .modal-content {
        max-width: none;
        margin: 12px;
    }

    .modal-header, .form-section, .modal-buttons {
        padding-left: 16px;
        padding-right: 16px;
    }

    .roles-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .modal-buttons {
        flex-direction: column;
    }
}
