/* Enhanced Manage Accounts Modal with Credit Allocation */

/* Credit Allocation Button in Table */
.credit-allocation-btn {
  border: 2px solid #28a745;
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: white;
  transition: all 0.3s ease;
  border-radius: 20px;
  font-weight: 600;
  min-width: 80px;
}

.credit-allocation-btn:hover {
  background: linear-gradient(135deg, #20c997 0%, #28a745 100%);
  border-color: #20c997;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.credit-allocation-btn i {
  margin-right: 4px;
  color: #ffc107;
}

/* Credit Allocation Panel */
.credit-allocation-panel {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px solid #dee2e6;
  border-radius: 12px;
  margin-top: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-header {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.panel-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title i {
  font-size: 1.2rem;
}

.btn-close-panel {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-close-panel:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.panel-body {
  padding: 25px;
}

/* Selected User Card */
.selected-user-card {
  background: white;
  border: 2px solid #e3f2fd;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.1);
  transition: all 0.3s ease;
}

.selected-user-card:hover {
  border-color: #2196f3;
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.15);
}

.user-avatar {
  margin-bottom: 15px;
}

.user-avatar i {
  font-size: 3rem;
  color: #007bff;
  filter: drop-shadow(0 2px 4px rgba(0, 123, 255, 0.3));
}

.user-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.user-email {
  font-size: 0.9rem;
  color: #6c757d;
  margin-bottom: 15px;
}

.current-credits {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 8px;
  padding: 10px;
  border: 1px solid #dee2e6;
}

.current-credits .label {
  font-weight: 600;
  color: #495057;
  font-size: 0.9rem;
}

.current-credits .credits-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #28a745;
  margin-left: 8px;
}

/* Credit Form */
.credit-form {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  border: 1px solid #e9ecef;
}

.form-label {
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-label i {
  font-size: 1rem;
}

.form-control {
  border-radius: 8px;
  border: 2px solid #e9ecef;
  padding: 12px 15px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.input-group-text {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px solid #e9ecef;
  border-left: none;
  color: #6c757d;
}

.form-text {
  font-size: 0.8rem;
  margin-top: 5px;
}

/* Credit Summary */
.credit-summary {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 15px;
  margin-top: 15px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 0.95rem;
}

.summary-item .label {
  color: #6c757d;
  font-weight: 500;
}

.summary-item .value {
  font-weight: 600;
  font-size: 1.1rem;
}

.summary-item.total {
  border-top: 2px solid #dee2e6;
  padding-top: 10px;
  margin-top: 5px;
}

.summary-item.total .value {
  font-size: 1.3rem;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn-allocate {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-weight: 600;
  transition: all 0.3s ease;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.btn-allocate:not(:disabled):hover {
  background: linear-gradient(135deg, #20c997 0%, #28a745 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(40, 167, 69, 0.3);
}

.btn-allocate:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

.btn-allocate .btn-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Messages */
#allocation-messages {
  margin-top: 15px;
}

#allocation-messages .alert {
  border-radius: 8px;
  border: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

#allocation-messages .alert-success {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  color: #155724;
  border-left: 4px solid #28a745;
}

#allocation-messages .alert-danger {
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
  color: #721c24;
  border-left: 4px solid #dc3545;
}

/* Enhanced Table Styling */
.table thead th {
  background: linear-gradient(135deg, #343a40 0%, #495057 100%);
  color: white;
  border: none;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  padding: 15px 10px;
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:hover {
  background-color: rgba(0, 123, 255, 0.05);
  transform: translateX(5px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.user-info .fw-bold {
  color: #333;
  font-size: 1rem;
}

.user-info .text-muted {
  font-size: 0.85rem;
}

/* Badge Enhancements */
.badge {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
}

.badge.bg-success {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.badge.bg-warning {
  background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%) !important;
}

.badge.bg-danger {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
}

.badge.bg-info {
  background: linear-gradient(135deg, #17a2b8 0%, #138496 100%) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .panel-body {
    padding: 15px;
  }
  
  .panel-body .row {
    flex-direction: column;
  }
  
  .selected-user-card {
    margin-bottom: 20px;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .form-actions .btn {
    width: 100%;
  }
  
  .summary-item {
    font-size: 0.9rem;
  }
  
  .table-responsive {
    font-size: 0.85rem;
  }
}

@media (max-width: 576px) {
  .panel-header {
    padding: 10px 15px;
  }
  
  .panel-title {
    font-size: 1rem;
  }
  
  .user-avatar i {
    font-size: 2.5rem;
  }
  
  .credits-value {
    font-size: 1.2rem !important;
  }
}

/* Loading States */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 12px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Animation for form validation */
.form-control.is-invalid {
  border-color: #dc3545;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Success animation */
.success-checkmark {
  display: inline-block;
  animation: checkmark 0.6s ease-in-out;
}

@keyframes checkmark {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Account Details Modal */
.account-details-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  animation: fadeIn 0.3s ease-out;
}

.account-details-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.account-details-header {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  padding: 20px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.account-details-header h4 {
  margin: 0;
  font-weight: 600;
}

.account-details-header .btn-close {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.account-details-body {
  padding: 30px;
}

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

.detail-label {
  font-weight: 600;
  color: #495057;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
  display: block;
}

.detail-value {
  font-size: 1rem;
  color: #212529;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #007bff;
}

.detail-value code {
  background: #e9ecef;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.85rem;
}

.detail-section {
  margin-top: 30px;
  border-top: 2px solid #e9ecef;
  padding-top: 20px;
}

.detail-section-title {
  font-weight: 600;
  color: #495057;
  margin-bottom: 15px;
  padding-bottom: 5px;
  border-bottom: 1px solid #dee2e6;
}

.detail-json {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 15px;
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.account-details-footer {
  padding: 20px 30px;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
}

.account-details-footer .btn {
  border-radius: 20px;
  font-weight: 600;
  padding: 8px 20px;
  transition: all 0.2s ease;
}

.account-details-footer .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Responsive design */
@media (max-width: 768px) {
  .account-details-modal {
    margin: 10px;
    width: calc(100% - 20px);
  }
  
  .account-details-body {
    padding: 20px;
  }
  
  .account-details-footer {
    flex-direction: column;
  }
  
  .account-details-footer .btn {
    width: 100%;
  }
}

/* Plan Change Modal */
.plan-change-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000; /* Much higher than Bootstrap modals */
  animation: fadeIn 0.3s ease-out;
}

.plan-change-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
  position: relative;
  z-index: 2001; /* Ensure modal content is also on top */
}

/* Ensure all plan modal elements are on top */
.plan-change-overlay * {
  position: relative;
  z-index: 2002;
}

.plan-change-header {
  background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
  color: white;
  padding: 20px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.plan-change-header h4 {
  margin: 0;
  font-weight: 600;
}

.plan-change-header .btn-close {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.plan-change-body {
  padding: 30px;
}

.selected-user-info, .current-plan-info {
  margin-bottom: 15px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #17a2b8;
}

.plan-options {
  margin: 25px 0;
}

.plan-options h6 {
  font-weight: 600;
  color: #495057;
  margin-bottom: 15px;
  padding-bottom: 5px;
  border-bottom: 1px solid #dee2e6;
}

.plan-option {
  display: flex;
  align-items: center;
  padding: 15px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
}

.plan-option:hover:not(.current-plan) {
  border-color: #17a2b8;
  background: #f8f9fa;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(23, 162, 184, 0.15);
}

.plan-option.selected {
  border-color: #17a2b8;
  background: linear-gradient(135deg, #e8f4f5 0%, #f0f9fa 100%);
  box-shadow: 0 4px 12px rgba(23, 162, 184, 0.2);
}

.plan-option.current-plan {
  border-color: #6c757d;
  background: #e9ecef;
  cursor: not-allowed;
  opacity: 0.7;
}

.plan-icon {
  font-size: 24px;
  margin-right: 15px;
  width: 40px;
  text-align: center;
}

.plan-details {
  flex-grow: 1;
}

.plan-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: #212529;
  margin-bottom: 4px;
}

.plan-description {
  font-size: 0.9rem;
  color: #6c757d;
}

.plan-select {
  margin-left: 15px;
}

.plan-select input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #17a2b8;
}

.plan-change-reason {
  margin: 25px 0;
}

.plan-change-reason label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 8px;
}

.plan-change-reason textarea {
  border: 2px solid #e9ecef;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.plan-change-reason textarea:focus {
  border-color: #17a2b8;
  box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.25);
}

/* Plan Change Messages Styling */
#plan-change-messages {
  margin: 15px 0;
}

#plan-change-messages .alert {
  border-radius: 8px;
  border: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  animation: fadeIn 0.3s ease-out;
  position: relative;
  padding-right: 50px; /* Make room for close button */
}

#plan-change-messages .alert-success {
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
  color: #155724;
  border-left: 4px solid #28a745;
}

#plan-change-messages .alert-danger {
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
  color: #721c24;
  border-left: 4px solid #dc3545;
}

#plan-change-messages .btn-close {
  position: absolute;
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

#plan-change-messages .btn-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
}

.plan-change-footer {
  padding: 20px 30px;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
}

.plan-change-footer .btn {
  border-radius: 20px;
  font-weight: 600;
  padding: 8px 20px;
  transition: all 0.2s ease;
}

.plan-change-footer .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Clickable Plan Badge */
.plan-change-btn {
  border: none !important;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 4px 8px;
  font-size: 0.75rem;
}

.plan-change-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Responsive design */
@media (max-width: 768px) {
  .plan-change-modal {
    margin: 10px;
    width: calc(100% - 20px);
  }
  
  .plan-change-body {
    padding: 20px;
  }
  
  .plan-change-footer {
    flex-direction: column;
  }
  
  .plan-change-footer .btn {
    width: 100%;
  }
  
  .plan-option {
    flex-direction: column;
    text-align: center;
  }
  
  .plan-icon {
    margin-bottom: 10px;
    margin-right: 0;
  }
  
  .plan-select {
    margin-left: 0;
    margin-top: 10px;
  }
}