/* Users Table Styles */
.users-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    background: white;
    transition: var(--transition);
}

.users-table-wrapper:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 14px;
}

.users-table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--dark);
    font-weight: 700;
    text-align: left;
    padding: 15px 12px;
    border-bottom: 3px solid var(--primary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    position: relative;
}

.users-table th::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 50%, transparent 100%);
}

.users-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
    transition: var(--transition);
}

.users-table tbody tr {
    transition: var(--transition);
}

.users-table tbody tr:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

/* User Status Badge */
.user-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-status.active {
    background: #d1fae5;
    color: #065f46;
}

.user-status.inactive {
    background: #fee2e2;
    color: #991b1b;
}

.user-status.pending {
    background: #fed7aa;
    color: #92400e;
}

/* User Role Badge */
.user-role {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}

.user-role.superadmin {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.user-role.admin {
    background: var(--primary);
    color: white;
}

.user-role.manager {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    font-weight: 500;
}

.user-role.user {
    background: var(--gray);
    color: white;
}

/* Бейдж менеджерів */
.managers-badge {
    height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: 8px;
}

.managers-badge:hover {
    max-width: none;
    z-index: 10;
    position: relative;
}

.user-card-id .managers-badge {
    max-width: 60px;
    font-size: 11px;
    padding: 3px 6px;
}

/* Стилі для multi-select менеджерів */
#userManagers option:checked {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-weight: 600;
}

#userManagers option:hover {
    background: #e0e7ff;
}

#userManagers:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    height: 32px;
}

.action-btn {
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-btn.view {
    background: #3b82f6;
    color: white;
}

.action-btn.view:hover {
    background: #2563eb;
}

.action-btn.edit {
    background: var(--primary);
    color: white;
}

.action-btn.edit:hover {
    background: var(--primary-dark);
}

.action-btn.delete {
    background: var(--danger);
    color: white;
}

.action-btn.delete:hover {
    background: #dc2626;
}

.action-btn.toggle {
    background: var(--warning);
    color: white;
}

.action-btn.toggle:hover {
    background: #d97706;
}

.action-btn.chat {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.action-btn.chat:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.action-btn.checklists {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    position: relative;
}

.action-btn.checklists:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.checklists-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    line-height: 1;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 6px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    color: #166534;
}

/* Модальне вікно з чек-листами користувача */
.user-checklists-modal-content {
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.user-checklists-modal-content .modal-header {
    padding: 20px 30px;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    overflow-y: visible !important;
    overflow-x: visible;
}

.user-checklists-modal-content .modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-checklists-modal-content .modal-header .close {
    color: white;
    font-size: 20px;
    font-weight: 300;
    cursor: pointer;
    transition: var(--transition);
}

.user-checklists-modal-content .modal-header .close:hover {
    transform: rotate(90deg);
    opacity: 0.8;
}

.user-checklists-list {
    padding: 20px 30px;
    overflow-y: auto;
    flex: 1;
    max-height: calc(90vh - 140px);
}

.user-checklist-item {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 15px;
    transition: var(--transition);
}

.user-checklist-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.user-checklist-item.checklist-critical {
    border-color: var(--danger);
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.user-checklist-item.checklist-warning {
    border-color: var(--warning);
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.user-checklist-item.checklist-normal {
    border-color: var(--success);
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.user-checklist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.user-checklist-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-checklist-title i {
    color: var(--primary);
}

.user-checklist-status {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-checklist-status.status-critical {
    background: var(--danger);
    color: white;
}

.user-checklist-status.status-warning {
    background: var(--warning);
    color: white;
}

.user-checklist-status.status-normal {
    background: var(--success);
    color: white;
}

.user-checklist-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-checklist-description {
    color: var(--gray);
    font-size: 14px;
    line-height: 1.5;
}

.user-checklist-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-checklist-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--dark);
}

.user-checklist-info-item i {
    color: var(--primary);
    width: 16px;
}

.user-checklist-info-item.time-critical {
    color: var(--danger);
    font-weight: 600;
}

.user-checklist-info-item.time-warning {
    color: var(--warning);
    font-weight: 600;
}

.user-checklist-info-item.time-normal {
    color: var(--success);
}

.no-checklists {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
    font-size: 16px;
}

.user-checklists-modal-content .modal-footer {
    padding: 15px 30px;
    border-top: 2px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    background: #f8fafc;
    overflow-y: visible !important;
    overflow-x: visible;
}

/* Checkbox Styles */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    margin-top: 5px;
    gap: 8px;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-wrapper span {
    font-size: 14px;
    color: var(--dark);
    user-select: none;
    cursor: pointer;
}

.checkbox-wrapper:hover span {
    color: var(--primary);
}

/* No Users Message */
.no-users {
    color: var(--gray);
    font-style: italic;
    font-size: 12px;
    padding: 4px 6px;
    background: var(--light);
    border-radius: 4px;
    border-left: 3px solid var(--gray);
}

/* Sort Indicator */
.sort-indicator {
    margin-left: 5px;
    font-size: 10px;
    opacity: 0.5;
}

.sort-indicator.active {
    opacity: 1;
    color: var(--primary);
}

/* User Form Container - Разворачивающаяся форма */
.user-form-container {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out, margin 0.3s ease-out;
    margin: 0;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
}

.user-form-container.open {
    max-height: 2000px;
    opacity: 1;
    margin-bottom: 20px;
    padding: 30px;
}

.user-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 15px 20px;
    background: var(--light);
    border-radius: var(--radius-sm);
    border-bottom: 2px solid var(--primary);
    margin: -30px -30px 25px -30px;
}

.user-form-header h3 {
    margin: 0;
    color: var(--primary);
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 18px;
    color: white;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.form-section {
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.form-section:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.form-section-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section-title::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group label::before {
    content: '•';
    color: var(--primary);
    font-size: 16px;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
    background: #f8fafc;
    color: var(--dark);
    box-sizing: border-box;
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 36px;
    cursor: pointer;
}

/* Убеждаемся, что select в форме пользователя имеет правильные стили */
#userFormContainer .form-group select,
#userForm .form-group select {
    width: 100% !important;
    padding: 12px 36px 12px 16px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: var(--radius-sm) !important;
    font-size: 14px !important;
    transition: var(--transition) !important;
    background: #f8fafc !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px !important;
    color: var(--dark) !important;
    font-family: inherit !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    box-sizing: border-box !important;
    display: block !important;
    font-weight: 400 !important;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #cbd5e1;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    border-top: 2px solid #e2e8f0;
    margin: 30px -30px -30px -30px;
}

.form-actions .btn {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-actions .btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
}

.form-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.form-actions .btn-secondary {
    background: white;
    color: var(--dark);
    border: 2px solid #e2e8f0;
}

.form-actions .btn-secondary:hover {
    background: var(--light);
    border-color: #cbd5e1;
    transform: translateY(-2px);
}

/* Responsive Form */
@media (max-width: 768px) {
    .user-form-container.open {
        padding: 15px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .user-form-header {
        margin: -15px -15px 20px -15px;
        padding: 12px 15px;
    }
    
    .form-section {
        margin-bottom: 20px;
        padding: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .form-actions {
        flex-direction: column-reverse;
        margin: 20px -15px -15px -15px;
        padding: 15px;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Tablet Form */
@media (min-width: 769px) and (max-width: 1024px) {
    .user-form-container.open {
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .form-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .form-actions {
        margin: 30px -30px -30px -30px;
        padding: 20px;
    }
}

/* Responsive Users Table */
@media (max-width: 1024px) {
    .users-table {
        font-size: 13px;
    }
    
    .users-table th,
    .users-table td {
        padding: 10px 8px;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 5px;
    }
}

@media (max-width: 768px) {
    .users-table-wrapper {
        border-radius: 0;
        margin: 0 -20px;
    }
    
    .users-table {
        font-size: 12px;
    }
    
    .users-table th,
    .users-table td {
        padding: 8px 6px;
    }
    
    .action-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .no-users {
        font-size: 11px;
        padding: 3px 5px;
    }

    /* Активні чек-листи: у мобільній версії статус вище заголовка */
    .user-checklist-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .user-checklist-status {
        order: -1;
        justify-content: flex-start;
    }
}
