/* Variables */
:root {
  /* Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.1);
  --secondary: #6c757d;
  --danger: #dc3545;
  --danger-light: rgba(220, 53, 69, 0.1);
  --error-background: #d9534f;

  /* Neutral Colors */
  --gray-50: #f9fafb;
  --gray-100: #f8fafc;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;

  /* Border & Shadow */
  --border-color: #ddd;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Search */
.search-container {
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.search-input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

/* List/Table */
.list-container {
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.list-header {
  background-color: var(--gray-50);
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 120px;
  gap: 10px;
  font-weight: bold;
}

.list-item {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 120px;
  gap: 10px;
  align-items: center;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background-color: var(--gray-50);
}

/* Table Footer */
.table-footer {
  padding: 12px;
  background-color: var(--gray-50);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.items-per-page {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pagination */
.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  background: white;
  cursor: pointer;
}

.pagination button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination button:disabled {
  background: var(--gray-50);
  cursor: not-allowed;
}

/* Form Container */
.form-container {
  display: none;
}

.form-container.active {
  display: block;
  padding: 20px;
  background-color: var(--gray-100);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

/* Form Layout */
.form-section {
  margin-bottom: 32px;
  padding: 15px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.fields-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

/* Form Field Base */
.form-field {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  vertical-align: top;
  box-sizing: border-box;
}

/* Form Field Sizes */
.form-field.size-xs {
  width: 8rem !important;
}

.form-field.size-sm {
  width: 12rem !important;
}

.form-field.size-md {
  width: 16rem !important;
}

.form-field.size-lg {
  width: 20rem !important;
}

.form-field.size-xl {
  width: 24rem !important;
}

.form-field.size-full {
  width: 100% !important;
  display: flex;
}

/* Form Field Elements */
.form-field input,
.form-field select,
.form-field textarea,
.text-input,
.textarea-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-field textarea,
.textarea-input {
  min-height: 100px;
  resize: vertical;
}

.text-input:focus,
.textarea-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Form Labels */
.form-field label,
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.form-field label.required::after {
  content: ' *';
  color: var(--danger);
}

/* Select Field Styles */
.form-select[multiple] {
  min-height: 120px;
  padding: 8px;
}

.form-select[multiple] option {
  padding: 4px 8px;
  margin: 2px 0;
  border-radius: 4px;
}

.form-select[multiple] option:checked {
  background-color: var(--gray-200);
}

.form-select option:checked {
  background-color: #062f6c;
  color: rgb(8, 2, 23);
}

.form-select option:checked:hover {
  background-color: var(--primary);
  color: white;
}

.form-select option:hover {
  background-color: var(--gray-50);
}

.multiselect-search {
  margin-bottom: 8px;
  width: 100%;
}

/* Form Header */
.form-header {
  padding: 24px;
  background-color: white;
  border-bottom: 1px solid var(--gray-200);
}

.form-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--gray-800);
}

.form-subtitle {
  margin: 4px 0 0;
  color: var(--gray-500);
  font-size: 14px;
}

/* Form Footer */
.form-footer {
  padding: 16px 24px;
  background-color: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.form-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Buttons */
.button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.button.primary {
  background-color: var(--primary);
  color: white;
  border: none;
}

.button.primary:hover {
  background-color: var(--primary-hover);
}

.button.secondary {
  background-color: white;
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
}

.button.secondary:hover {
  background-color: var(--gray-50);
}

.button.danger {
  background-color: var(--danger);
  color: white;
}

.button:hover {
  opacity: 0.9;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

/* Scroll Container */
.form-scroll-container {
  max-height: 600px;
  overflow-y: auto;
  padding: 24px;
}

/* Card Styles */
.agent-form.card {
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.error-message-critical {
  display: none;
  color: white;
  background-color: var(--error-background);
  padding: 10px 15px;
  border-radius: 4px;
  margin-bottom: 15px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Field Error Styling */
.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px var(--danger-light) !important;
}

.input-error:focus {
  box-shadow: 0 0 0 3px var(--danger-light) !important;
}

/* Shake Animation for Errors */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px);
  }
}

.error-shake {
  animation: shake 0.5s;
  animation-iteration-count: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .form-field[class*='size-'] {
    width: 100% !important;
  }

  .search-container {
    grid-template-columns: 1fr;
  }

  .list-header,
  .list-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .action-buttons {
    justify-content: flex-start;
  }
}
