/* MARK: Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2c3e50;
}

/* MARK: Header Styles */
.header {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 2em;
    font-weight: 300;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* MARK: Search Section */
.search-section {
    background: white;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.search-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 1em;
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.filter-select {
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
}

/* MARK: Date Filter Styles */
.date-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    min-width: 200px;
}

.date-filter-label {
    font-size: 0.9em;
    color: #2c3e50;
    font-weight: 500;
    white-space: nowrap;
    margin-right: 5px;
}

.date-time-input-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

.date-filter-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.9em;
    min-width: 0;
}

.time-filter-input {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.9em;
    min-width: 80px;
}

.date-filter-input:focus,
.time-filter-input:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.filter-select:focus {
    border-color: #3498db;
    outline: none;
}

.search-results {
    max-width: 1200px;
    margin: 10px auto 0;
    color: #7f8c8d;
    font-size: 0.9em;
}

/* MARK: Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.identities-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* MARK: Identity Card */
.identity-card {
    border-bottom: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.identity-card:last-child {
    border-bottom: none;
}

.identity-card.selected {
    background: #f8f9fa;
    border-left: 4px solid #3498db;
}

.identity-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    cursor: pointer;
    transition: background 0.3s ease;
}

.identity-header:hover {
    background: linear-gradient(135deg, #2980b9, #1f6391);
}

.identity-info {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    flex: 1;
}

.identity-checkbox {
    transform: scale(1.2);
    cursor: pointer;
    margin-top: 8px;
    align-self: flex-start;
}

.identity-name {
    font-size: 1.3em;
    font-weight: bold;
}

.identity-type {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* MARK: Identity Type Colors */
.identity-header .identity-type.Unknown {
    background: #95a5a6 !important;
}

.identity-header .identity-type.Staff-Member {
    background: #27ae60 !important;
}

.identity-header .identity-type.Regular {
    background: #1abc9c !important;
}

.identity-header .identity-type.Bad-Actor {
    background: #e74c3c !important;
}

.identity-dates {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9em;
    opacity: 0.9;
}

.date-row {
    line-height: 1.3;
}

.identity-actions {
    display: flex;
    gap: 10px;
}

.identity-face-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

/* MARK: Faces Grid */
.faces-section {
    padding: 20px;
    background: #f8f9fa;
}

.faces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.face-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: white;
}

.face-item:hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.face-checkbox {
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 2;
    transform: scale(1.2);
}

.face-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.face-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.face-item:hover .face-actions {
    opacity: 1;
}

/* MARK: Face Expansion Section */
.faces-expand-section {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.faces-expand-section .btn {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.faces-expand-section .btn:hover {
    background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* MARK: Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-disabled {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-disabled:hover {
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.8em;
}

/* MARK: Footer Action Menu */
.footer-action-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.selection-info {
    font-size: 1.1em;
    font-weight: bold;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

/* MARK: Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal h3 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.5em;
}

.modal-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    font-size: 1em;
    margin-bottom: 20px;
}

.modal-input:focus {
    border-color: #3498db;
    outline: none;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-buttons {
    margin-left: auto;
}

.identity-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    margin-bottom: 20px;
}

.identity-option {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.3s ease;
}

.identity-option:hover {
    background: #f8f9fa;
}

.identity-option.selected {
    background: #3498db;
    color: white;
}

.identity-option:last-child {
    border-bottom: none;
}

/* MARK: Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding: 20px;
}

.page-numbers {
    display: flex;
    gap: 5px;
}

.page-number {
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-number:hover {
    background: #3498db;
    color: white;
}

.page-number.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.page-number.ellipsis {
    background: #ffffff;
    border: none;
    cursor: default;
}

.page-number.ellipsis:hover {
    background: transparent;
    color: inherit;
}

/* MARK: Utility Classes */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.error {
    background: #e74c3c;
    color: white;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
}

.success {
    background: #27ae60;
    color: white;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* MARK: Bitrix Link Styles */
.bitrix-link {
    color: #6698e2e8;
    text-decoration: none;
    font-weight: bold;
    border-bottom: 1px dotted #ffeb3b;
    transition: all 0.3s ease;
}

.bitrix-link:hover {
    color: #fff;
    border-bottom-color: #fff;
    text-decoration: none;
}

/* MARK: Bitrix Modal Controls */
.bitrix-modal-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.bitrix-modal-controls .modal-input {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9em;
    color: #2c3e50;
}

.checkbox-label input[type="checkbox"] {
    transform: scale(1.2);
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

/* MARK: Bitrix Users List Styles */
.bitrix-users-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bitrix-user-option {
    background: white;
    color: #2c3e50;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.bitrix-user-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
    border-color: #3498db;
}

.bitrix-user-option.selected {
    background: #f8f9fa;
    border-color: #3498db;
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.2);
}

.bitrix-user-info {
    flex: 1;
}

.bitrix-user-name {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 5px;
    color: #2c3e50;
}

.bitrix-user-id {
    font-size: 0.9em;
    color: #7f8c8d;
    font-family: monospace;
    display: inline-block;
}

.bitrix-user-terminated {
    background: #e74c3c;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
}

.bitrix-user-option.selected .bitrix-user-terminated {
    background: #c0392b;
}

/* MARK: Face Preview Overlay */
.face-preview {
    position: fixed;
    z-index: 9999;
    display: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 2px solid #3498db;
    overflow: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.face-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* MARK: Selected Face Styles */
.face-item.selected {
    border: 3px solid #3498db;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
}

.face-item {
    cursor: pointer;
    transition: all 0.3s ease;
}

.face-item:hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

/* MARK: Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .search-container {
        flex-direction: column;
        align-items: stretch;
    }

    .date-filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        min-width: auto;
    }

    .date-filter-label {
        text-align: center;
        margin-right: 0;
    }

    .date-filter-input {
        width: 100%;
    }

    .identity-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .identity-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .identity-dates {
        flex-direction: column;
        gap: 5px;
    }

    .footer-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .action-buttons {
        justify-content: center;
    }

    .faces-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .pagination {
        flex-wrap: wrap;
    }

    .bitrix-user-option {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .bitrix-user-info {
        width: 100%;
    }
    
    .face-preview {
        max-width: 300px;
        max-height: 300px;
    }
}
