/* User Permissions Management Styles */

/* Permission Sections */
.permission-section {
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background-color: #f8f9fa;
}

.permission-section-title {
  color: #495057;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.permission-section-title i {
  color: #6c757d;
}

.permission-section-title .select-section-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  margin-left: auto;
  border-radius: 0.25rem;
}

/* Country and Continent Lists */
.countries-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 0.75rem;
  background-color: #f8f9fa;
}

.countries-list .country-item {
  margin-bottom: 0.5rem;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s ease;
}

.countries-list .country-item:hover {
  background-color: rgba(0, 123, 255, 0.1);
}

.countries-list .country-item.d-none {
  display: none;
}

.countries-list .form-check-label small {
  font-size: 0.75rem;
  color: #6c757d;
  margin-right: 0.25rem;
}

/* Permission Checkboxes */
.permission-checkbox,
.country-checkbox,
.continent-checkbox,
.role-checkbox {
  margin-right: 0.5rem;
}

.permission-checkbox:checked,
.country-checkbox:checked,
.continent-checkbox:checked,
.role-checkbox:checked {
  background-color: #0d6efd;
  border-color: #0d6efd;
}

/* Select All Buttons */
.btn-outline-primary.select-all-btn {
  transition: all 0.2s ease;
}

.btn-outline-primary.select-all-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-outline-danger.select-all-btn {
  transition: all 0.2s ease;
}

/* Card Headers */
.card-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.card-header h5 {
  margin-bottom: 0;
}

/* New Permission Categories */
.permission-category {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
  transition: all 0.3s ease;
}

.permission-category:hover {
  border-color: #0d6efd;
  box-shadow: 0 2px 8px rgba(13, 110, 253, 0.1);
}

.permission-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e9ecef;
}

.permission-category-title {
  font-weight: 600;
  color: #495057;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.permission-category-title i {
  color: #0d6efd;
  font-size: 1.1em;
}

.permission-category-description {
  color: #6c757d;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Task Permissions Special Styling */
.permission-section[data-section="tasks"] {
  border-left: 4px solid #28a745;
  background: linear-gradient(135deg, #f8fff9 0%, #e8f5e8 100%);
}

.permission-section[data-section="tasks"] .permission-section-title {
  color: #155724;
}

.permission-section[data-section="tasks"] .permission-section-title i {
  color: #28a745;
}

/* Roles Permissions Special Styling */
.permission-section[data-section="roles"] {
  border-left: 4px solid #17a2b8;
  background: linear-gradient(135deg, #f8fbfc 0%, #e8f4f8 100%);
}

.permission-section[data-section="roles"] .permission-section-title {
  color: #0c5460;
}

.permission-section[data-section="roles"] .permission-section-title i {
  color: #17a2b8;
}

/* Analytics Permissions Special Styling */
.permission-section[data-section="analytics"] {
  border-left: 4px solid #ffc107;
  background: linear-gradient(135deg, #fffdf8 0%, #fef8e8 100%);
}

.permission-section[data-section="analytics"] .permission-section-title {
  color: #856404;
}

.permission-section[data-section="analytics"] .permission-section-title i {
  color: #ffc107;
}

/* System Permissions Special Styling */
.permission-section[data-section="system"] {
  border-left: 4px solid #dc3545;
  background: linear-gradient(135deg, #fef8f8 0%, #f8e8e8 100%);
}

.permission-section[data-section="system"] .permission-section-title {
  color: #721c24;
}

.permission-section[data-section="system"] .permission-section-title i {
  color: #dc3545;
}
  font-weight: 600;
  color: #495057;
}

.card-header .btn {
  margin-left: auto;
}

/* Form Controls */
.form-select {
  border-radius: 0.375rem;
}

.form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Responsive Design */
@media (max-width: 768px) {
  .permission-section {
    padding: 0.75rem;
  }

  .countries-list {
    max-height: 300px;
  }

  .card-header .btn {
    margin-top: 0.5rem;
    margin-left: 0;
  }

  .card-header .d-flex {
    flex-direction: column;
    align-items: flex-start !important;
  }

  .card-header .btn {
    align-self: flex-end;
  }
}

@media (max-width: 576px) {
  .countries-list {
    max-height: 250px;
  }

  .permission-section-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .permission-section-title .select-section-btn {
    margin-left: 0;
    margin-top: 0.25rem;
  }
}

/* Loading States */
.permission-section.loading {
  opacity: 0.6;
  pointer-events: none;
}

.permission-section.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Success/Selected States */
.permission-checkbox:checked + label,
.country-checkbox:checked + label,
.continent-checkbox:checked + label,
.role-checkbox:checked + label {
  font-weight: 600;
  color: #0d6efd;
}

/* Filter Section */
.continent-filter {
  background-color: #e9ecef;
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

.continent-filter .form-label {
  font-weight: 600;
  color: #495057;
}

/* Button Groups */
.btn-group-vertical .btn {
  margin-bottom: 0.25rem;
}

.btn-group-vertical .btn:last-child {
  margin-bottom: 0;
}

/* Tooltips */
.tooltip-inner {
  max-width: 300px;
  text-align: center;
}

/* Scrollbar Styling */
.countries-list::-webkit-scrollbar {
  width: 8px;
}

.countries-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.countries-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.countries-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Print Styles */
@media print {
  .permission-section {
    border: 1px solid #000;
    background-color: #fff !important;
  }

  .countries-list {
    max-height: none;
    overflow: visible;
    border: 1px solid #000;
  }

  .btn {
    display: none !important;
  }
}

/* Dark Mode Support - Using project theme system */
body[data-theme='dark'] .permission-section {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
  color: var(--text-color);
}

body[data-theme='dark'] .permission-section-title {
  color: var(--text-color);
}

body[data-theme='dark'] .permission-section-title i {
  color: #6c757d;
}

body[data-theme='dark'] .countries-list {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .card-header {
  background-color: var(--sidebar-bg);
  border-color: var(--card-border-color);
  color: var(--sidebar-text);
}

body[data-theme='dark'] .card-header h5 {
  color: var(--sidebar-text);
}

body[data-theme='dark'] .card {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
  color: var(--text-color);
}

body[data-theme='dark'] .continent-filter {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .continent-filter .form-label {
  color: var(--text-color);
}

body[data-theme='dark'] .countries-list .country-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

body[data-theme='dark'] .form-control,
body[data-theme='dark'] .form-select {
  background-color: var(--secondary-bg);
  color: var(--text-color);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .form-control:focus,
body[data-theme='dark'] .form-select:focus {
  background-color: var(--secondary-bg);
  color: var(--text-color);
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

body[data-theme='dark'] .btn-outline-primary {
  color: var(--link-color);
  border-color: var(--link-color);
}

body[data-theme='dark'] .btn-outline-primary:hover {
  background-color: var(--link-color);
  border-color: var(--link-color);
}

body[data-theme='dark'] .btn-outline-danger {
  color: #dc3545;
  border-color: #dc3545;
}

body[data-theme='dark'] .btn-outline-danger:hover {
  background-color: #dc3545;
  border-color: #dc3545;
}

/* Additional dark theme improvements */
body[data-theme='dark'] .form-check-label {
  color: var(--text-color);
}

body[data-theme='dark'] .form-check-input {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .form-check-input:checked {
  background-color: var(--link-color);
  border-color: var(--link-color);
}

body[data-theme='dark'] .text-muted {
  color: #adb5bd !important;
}

body[data-theme='dark'] .alert {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
  color: var(--text-color);
}

body[data-theme='dark'] .alert-info {
  background-color: rgba(13, 202, 240, 0.1);
  border-color: #0dcaf0;
  color: #0dcaf0;
}

body[data-theme='dark'] .alert-info .alert-heading {
  color: #0dcaf0;
}

body[data-theme='dark'] .btn {
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .btn-primary {
  background-color: var(--link-color);
  border-color: var(--link-color);
}

body[data-theme='dark'] .btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
}

body[data-theme='dark'] .btn-warning {
  background-color: #ffc107;
  border-color: #ffc107;
  color: #000;
}

body[data-theme='dark'] .btn-danger {
  background-color: #dc3545;
  border-color: #dc3545;
}

/* Animation for checkboxes */
.permission-checkbox,
.country-checkbox,
.continent-checkbox,
.role-checkbox {
  transition: all 0.2s ease;
}

.permission-checkbox:checked,
.country-checkbox:checked,
.continent-checkbox:checked,
.role-checkbox:checked {
  transform: scale(1.1);
}

/* Focus states */
.permission-checkbox:focus,
.country-checkbox:focus,
.continent-checkbox:focus,
.role-checkbox:focus {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
  outline: none;
}

/* Dark theme focus states */
body[data-theme='dark'] .permission-checkbox:focus,
body[data-theme='dark'] .country-checkbox:focus,
body[data-theme='dark'] .continent-checkbox:focus,
body[data-theme='dark'] .role-checkbox:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 191, 165, 0.25);
}

/* Ensure all text is visible in dark mode */
body[data-theme='dark'] * {
  color: inherit;
}

body[data-theme='dark'] .permission-section h6,
body[data-theme='dark'] .permission-section p,
body[data-theme='dark'] .permission-section li {
  color: var(--text-color);
}

body[data-theme='dark'] .countries-list .country-item {
  color: var(--text-color);
}

/* Button text colors for dark mode */
body[data-theme='dark'] .btn-outline-primary {
  color: var(--link-color);
}

body[data-theme='dark'] .btn-outline-primary:hover {
  color: white;
}

body[data-theme='dark'] .btn-outline-danger {
  color: #dc3545;
}

body[data-theme='dark'] .btn-outline-danger:hover {
  color: white;
}

/* Form control placeholder colors */
body[data-theme='dark'] .form-control::placeholder,
body[data-theme='dark'] .form-select::placeholder {
  color: #6c757d;
}

/* Links in dark mode */
body[data-theme='dark'] a {
  color: var(--link-color);
}

body[data-theme='dark'] a:hover {
  color: var(--link-color);
  opacity: 0.8;
}

/* Permission highlighting styles */
.from-role {
  background-color: rgba(0, 123, 255, 0.05);
  border-left: 3px solid #007bff;
}

.individual-only {
  background-color: rgba(255, 193, 7, 0.05);
  border-left: 3px solid #ffc107;
}

.role-permission {
  position: relative;
}

.role-permission::before {
  content: "دور";
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: #007bff;
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
}

.individual-permission::before {
  content: "فردي";
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: #ffc107;
  color: #000;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
}

/* Dark mode permission highlighting */
body[data-theme='dark'] .from-role {
  background-color: rgba(0, 123, 255, 0.1);
  border-left-color: #0d6efd;
}

body[data-theme='dark'] .individual-only {
  background-color: rgba(255, 193, 7, 0.1);
  border-left-color: #ffc107;
}

body[data-theme='dark'] .role-permission::before {
  background-color: #0d6efd;
}

body[data-theme='dark'] .individual-permission::before {
  background-color: #ffc107;
  color: #000;
}

/* Animation for permission changes */
.from-role,
.individual-only {
  transition: all 0.3s ease;
}

.permission-checkbox {
  transition: all 0.2s ease;
}

.permission-checkbox:checked {
  transform: scale(1.1);
}

/* Legend for permission types */
.permission-legend {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.permission-legend .legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

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

.permission-legend .legend-color {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  margin-left: 10px;
  border: 2px solid;
}

.permission-legend .legend-color.role {
  background-color: rgba(0, 123, 255, 0.05);
  border-color: #007bff;
}

.permission-legend .legend-color.individual {
  background-color: rgba(255, 193, 7, 0.05);
  border-color: #ffc107;
}

/* Dark mode legend */
body[data-theme='dark'] .permission-legend {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
  color: var(--text-color);
}

body[data-theme='dark'] .permission-legend .legend-color.role {
  background-color: rgba(0, 123, 255, 0.1);
}

body[data-theme='dark'] .permission-legend .legend-color.individual {
  background-color: rgba(255, 193, 7, 0.1);
}

/* Additional dark theme fixes */
body[data-theme='dark'] {
  color: var(--text-color);
}

body[data-theme='dark'] .card-body {
  background-color: var(--secondary-bg);
  color: var(--text-color);
}

body[data-theme='dark'] .permission-section {
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .countries-list {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .countries-list .country-item label {
  color: var(--text-color);
}

body[data-theme='dark'] .countries-list .country-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Ensure all form elements have proper dark theme */
body[data-theme='dark'] input[type="checkbox"],
body[data-theme='dark'] input[type="radio"] {
  background-color: var(--secondary-bg);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] input[type="checkbox"]:checked,
body[data-theme='dark'] input[type="radio"]:checked {
  background-color: var(--link-color);
  border-color: var(--link-color);
}

/* Dropdown/select styling for dark mode */
body[data-theme='dark'] select option {
  background-color: var(--secondary-bg);
  color: var(--text-color);
}

/* Table styling for dark mode */
body[data-theme='dark'] .table {
  color: var(--text-color);
}

body[data-theme='dark'] .table thead th {
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .table tbody tr {
  background-color: var(--secondary-bg);
  color: var(--text-color);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Icon colors in dark mode */
body[data-theme='dark'] .fas,
body[data-theme='dark'] .far,
body[data-theme='dark'] .fab {
  color: var(--text-color);
}

body[data-theme='dark'] .fa-users,
body[data-theme='dark'] .fa-key,
body[data-theme='dark'] .fa-globe,
body[data-theme='dark'] .fa-continent {
  color: var(--link-color);
}

/* Badge styling for dark mode */
body[data-theme='dark'] .badge {
  background-color: var(--link-color);
  color: white;
}

body[data-theme='dark'] .badge.bg-primary {
  background-color: var(--link-color) !important;
}

body[data-theme='dark'] .badge.bg-secondary {
  background-color: #6c757d !important;
}

body[data-theme='dark'] .badge.bg-success {
  background-color: #198754 !important;
}

body[data-theme='dark'] .badge.bg-danger {
  background-color: #dc3545 !important;
}

body[data-theme='dark'] .badge.bg-warning {
  background-color: #ffc107 !important;
  color: #000 !important;
}

/* Modal styling for dark mode */
body[data-theme='dark'] .modal-content {
  background-color: var(--secondary-bg);
  color: var(--text-color);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .modal-header {
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .modal-footer {
  border-color: var(--card-border-color);
}

/* Ensure all text in permission sections is visible */
body[data-theme='dark'] .permission-section-title {
  color: var(--text-color);
}

body[data-theme='dark'] .permission-section-title .btn-xs {
  color: var(--text-color);
  border-color: var(--card-border-color);
}

body[data-theme='dark'] .permission-section-title .btn-xs:hover {
  background-color: var(--link-color);
  border-color: var(--link-color);
  color: white;
}

/* Fix for any missing text colors */
body[data-theme='dark'] .form-check-label,
body[data-theme='dark'] label,
body[data-theme='dark'] .card-title,
body[data-theme='dark'] .card-subtitle {
  color: var(--text-color);
}

/* Ensure buttons have proper contrast */
body[data-theme='dark'] .btn-outline-primary:not(:hover) {
  color: var(--link-color) !important;
}

body[data-theme='dark'] .btn-outline-danger:not(:hover) {
  color: #dc3545 !important;
}

/* Final dark theme overrides to ensure everything is visible */
body[data-theme='dark'] * {
  /* Reset any inherited colors that might cause issues */
}

body[data-theme='dark'] .container,
body[data-theme='dark'] .row,
body[data-theme='dark'] .col,
body[data-theme='dark'] .col-md-4,
body[data-theme='dark'] .col-md-6,
body[data-theme='dark'] .col-md-12 {
  color: inherit;
}

body[data-theme='dark'] .d-flex {
  color: inherit;
}

body[data-theme='dark'] .justify-content-between {
  color: inherit;
}

body[data-theme='dark'] .align-items-center {
  color: inherit;
}

/* Ensure form validation messages are visible */
body[data-theme='dark'] .invalid-feedback {
  color: #dc3545;
}

body[data-theme='dark'] .valid-feedback {
  color: #198754;
}

/* Ensure placeholder text is visible */
body[data-theme='dark'] ::placeholder {
  color: #6c757d !important;
  opacity: 1;
}

/* Fix for any potential Bootstrap conflicts */
body[data-theme='dark'] .form-control:focus {
  background-color: var(--secondary-bg) !important;
  color: var(--text-color) !important;
  border-color: var(--link-color) !important;
}

body[data-theme='dark'] .form-select:focus {
  background-color: var(--secondary-bg) !important;
  color: var(--text-color) !important;
  border-color: var(--link-color) !important;
}

/* Ensure all text in cards is visible */
body[data-theme='dark'] .card .card-body * {
  color: inherit;
}

/* Special handling for text-muted in dark mode */
body[data-theme='dark'] .text-muted {
  color: #6c757d !important;
}

/* Ensure tooltips work in dark mode */
body[data-theme='dark'] .tooltip-inner {
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
}

body[data-theme='dark'] .tooltip .arrow::before {
  border-color: var(--sidebar-bg);
}
