/**
 * Administration View Styles
 * Styles for the administration interface including audit logs and dashboards
 * (c) Adrian Ranta. All rights reserved. Unauthorised use, reproduction and or distribution is strictly prohibited.
 */

/* Admin Container */
.admin-container {
    background: white;
    border-radius: 20px;
    padding: 0;
    min-height: calc(100vh - 200px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* Admin Header */
.admin-header {
    padding: 25px 30px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.admin-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.admin-actions {
    display: flex;
    gap: 10px;
}

.admin-actions .btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.admin-actions .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 4px 20px 0;
}

.admin-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 0.875rem;
}

.admin-tab:hover {
    color: #495057;
}

.admin-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.admin-tab svg {
    width: 20px;
    height: 20px;
}

/* Admin Content */
.admin-content {
    padding: 30px;
}

.admin-loading {
    text-align: center;
    padding: 60px;
    color: #6c757d;
    font-size: 1.1rem;
}

.admin-placeholder {
    text-align: center;
    padding: 60px;
    color: #6c757d;
    font-size: 1.1rem;
}

/* Audit Log Viewer */
.audit-log-viewer {
    max-width: 100%;
}

/* Audit Filters */
.audit-filters {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
}

.filter-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-item {
    flex: 1;
    min-width: 200px;
}

.filter-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
    font-size: 0.875rem;
}

.filter-item .form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.875rem;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

/* Audit Stats */
.audit-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Audit Table */
.audit-table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
}

.audit-table thead {
    background: #f8f9fa;
}

.audit-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    font-size: 0.875rem;
    border-bottom: 2px solid #dee2e6;
}

.audit-table td {
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.875rem;
}

.audit-table tbody tr:hover {
    background: #f8f9fa;
}

.audit-table .timestamp {
    color: #6c757d;
    white-space: nowrap;
}

.audit-table .user {
    font-weight: 500;
}

.audit-table .entity {
    color: #495057;
}

.audit-table .action-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.action-badge.action-create {
    background: #d4edda;
    color: #155724;
}

.action-badge.action-update {
    background: #cce5ff;
    color: #004085;
}

.action-badge.action-delete {
    background: #f8d7da;
    color: #721c24;
}

.audit-table .loading-message,
.audit-table .empty-message,
.audit-table .error-message {
    text-align: center;
    padding: 60px;
    color: #6c757d;
}

/* Audit Pagination */
.audit-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 25px;
}

.pagination-btn {
    padding: 8px 16px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(.disabled) {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.pagination-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-ellipsis {
    padding: 0 10px;
    color: #6c757d;
}

/* Audit Details Modal */
.audit-details {
    padding: 20px;
}

.audit-details h3 {
    margin-bottom: 20px;
    color: #212529;
}

.audit-details h4 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.detail-item label {
    display: block;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 5px;
    font-size: 0.875rem;
}

.detail-item div {
    color: #212529;
}

.user-agent {
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

.changes-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.changes-table th,
.changes-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid #dee2e6;
}

.changes-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.changes-table td {
    font-family: monospace;
    font-size: 0.875rem;
}

/* Settings Sections */
.admin-settings,
.admin-data {
    max-width: 1200px;
}

.settings-grid,
.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

.setting-card,
.data-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
    border: 1px solid #e9ecef;
}

.setting-card h4,
.data-card h4 {
    margin-bottom: 20px;
    color: #212529;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.setting-item input[type="checkbox"] {
    margin-right: 8px;
}

.settings-actions {
    margin-top: 30px;
    display: flex;
    gap: 10px;
}

.data-card p {
    color: #6c757d;
    margin-bottom: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .admin-tabs {
        padding: 4px 10px 0;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-item {
        min-width: 100%;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

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

    .audit-table {
        min-width: 700px;
    }
}

/* Connectivity Settings Styles */
.connectivity-settings {
    max-width: 800px;
    margin: 0 auto;
}

.settings-header {
    margin-bottom: 30px;
}

.settings-header h2 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.settings-header p {
    color: #6c757d;
}

.connection-status-panel,
.data-source-panel,
.hybrid-options-panel,
.data-migration-panel {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.connection-status-panel h3,
.data-source-panel h3,
.hybrid-options-panel h3,
.data-migration-panel h3 {
    margin-bottom: 20px;
    color: #495057;
}

.connectivity-status {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.status-item:last-child {
    border-bottom: none;
}

.status-label {
    font-weight: 500;
    color: #495057;
}

.status-indicator {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-indicator.connected {
    background: #d4edda;
    color: #155724;
}

.status-indicator.disconnected {
    background: #f8d7da;
    color: #721c24;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    padding: 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-option:hover {
    border-color: #007bff;
    background: #e9ecef;
}

.radio-option input[type="radio"] {
    margin-right: 15px;
    margin-top: 2px;
}

.radio-option input[type="radio"]:checked + .option-content {
    color: #007bff;
}

.option-content {
    flex: 1;
}

.option-title {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
}

.option-desc {
    display: block;
    font-size: 14px;
    color: #6c757d;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
}

.migration-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.data-migration-panel p {
    color: #6c757d;
    margin-bottom: 20px;
}

/* Department Status Badges */
.dept-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.dept-status-badge.badge-active {
    background: #d4edda;
    color: #155724;
}

.dept-status-badge.badge-inactive {
    background: #f8d7da;
    color: #721c24;
}

/* Departments Table Actions */
.admin-departments .btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
}

.admin-departments .btn-danger {
    background: #dc3545;
    color: white;
    border: 1px solid #dc3545;
}

.admin-departments .btn-danger:hover {
    background: #c82333;
}

/* Department Form Card */
.dept-form-card .form-group label {
    font-size: 13px;
}

.dept-form-card .form-control {
    font-size: 13px;
}

/* ========================================================================
   Roles & Permissions Tab
   ======================================================================== */

.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.admin-section-header h3 {
    margin: 0;
    color: #212529;
    font-size: 1.25rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.admin-table thead {
    background: #f8f9fa;
}

.admin-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    font-size: 0.85rem;
    border-bottom: 2px solid #dee2e6;
}

.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.875rem;
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background: #f8f9fa;
}

.admin-form-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
}

.admin-form-card h4 {
    margin: 0 0 16px 0;
    color: #212529;
}

.form-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

.admin-empty {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.admin-error {
    text-align: center;
    padding: 40px;
    color: #dc3545;
}

/* Permission Matrix */
.perm-matrix {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e9ecef;
}

.perm-category {
    margin-bottom: 20px;
}

.perm-category:last-child {
    margin-bottom: 0;
}

.perm-category-title {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 6px;
}

.perm-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.perm-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #495057;
    transition: background 0.15s;
}

.perm-checkbox-label:hover {
    background: #e9ecef;
}

.perm-checkbox-label input[type="checkbox"] {
    margin: 0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: #cce5ff;
    color: #004085;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}
