/* ===== ORIGINAL COMPETITION WRAPPER STYLES ===== */
.competition-wrapper {
  background: #2C4177;
  padding: 2rem;
  border-radius: 12px;
  max-width: 720px;
  margin: 64px auto;
}

.competition-wrapper h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: #fff;
}

.competition-wrapper p,
.competition-wrapper label {
  color: #fff !important;
}

small.description {
  color: #fff !important;
  margin-top: 15px;
  display: block;
}

.competition-form {
  margin-top: 1rem;
  position: relative;
}

.competition-form input[type="text"],
.competition-form input[type="file"] {
  height: 45px;
}

.competition-form input#edit-imageuri-remove-button {
  background: #2C4177;
  color: #fff;
  border: 1px solid #fff !important;
  margin-top: 5px;
}

.competition-form input[type="submit"] {
  margin: 5px 0 0 0;
  border: none !important;
}

.competition-form input#edit-submit {
  margin: 40px 0 0 0;
}

.competition-form label#edit-mobilenumber-error {
  color: red;
  font-size: 12px;
}

.fade {
  opacity: 1 !important;
}

.always-on-terms-link, .always-on-terms-link a {
  color: #fff !important;
  text-decoration: none;
  text-align: left;
  margin: 1.5rem 0;
}

.file--image a {
  color: #fff !important;
}

input[data-drupal-selector="edit-imageuri-remove-button"] {
  margin: 0 20px !important;
  padding: 10px 30px;
  font-size: 1rem;
}

/* ===== ENHANCED ERROR AND SUCCESS MESSAGES ===== */
.messages--error {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #991b1b;
  font-size: 0.875rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideInError 0.4s ease-out;
  box-shadow: 0 4px 6px rgba(220, 38, 38, 0.1);
}

.messages--error::before {
  content: '⚠️';
  font-size: 1.2rem;
  flex-shrink: 0;
  animation: errorIconPulse 2s ease-in-out infinite;
}

.messages--status {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #bbf7d0;
  border-left: 4px solid #16a34a;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #15803d;
  font-size: 0.875rem;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInSuccess 0.4s ease-out;
  box-shadow: 0 4px 6px rgba(22, 163, 74, 0.1);
}

.messages--status::before {
  content: '✅';
  font-size: 1.2rem;
  flex-shrink: 0;
  animation: successPulse 0.6s ease-out;
}

.messages--warning {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #92400e;
  animation: slideInWarning 0.4s ease-out;
  box-shadow: 0 4px 6px rgba(245, 158, 11, 0.1);
}

.messages--warning::before {
  content: '⚠️';
  margin-right: 0.5rem;
}

/* ===== PROCESSING MESSAGE WITH SPINNER ===== */
.messages--info.processing-message {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-left: 4px solid #3b82f6;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #1e40af;
  font-size: 0.875rem;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInProcessing 0.3s ease-out;
  box-shadow: 0 4px 6px rgba(59, 130, 246, 0.1);
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: spinnerRotate 1s linear infinite;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* ===== SUBMIT BUTTON ENHANCEMENTS ===== */
.submit-button {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.submit-button.processing {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  cursor: wait;
  pointer-events: none;
}

.submit-button.processing::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #ffffff;
  border-radius: 50%;
  animation: buttonSpinnerRotate 1s linear infinite;
}

.submit-button.processing .button-text {
  opacity: 0;
}

/* ===== FORM LOADING OVERLAY ===== */
.form-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 12px;
  backdrop-filter: blur(2px);
}

.form-loading-content {
  text-align: center;
  padding: 2rem;
}

.form-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f4f6;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  animation: formSpinnerRotate 1s linear infinite;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
}

.form-loading-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.form-loading-subtext {
  font-size: 0.9rem;
  color: #6b7280;
}

/* ===== RATE LIMITED MESSAGE ===== */
.rate-limited-message {
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 2px solid #fecaca;
  border-radius: 12px;
  color: #dc2626;
  animation: slideInError 0.5s ease-out;
  box-shadow: 0 8px 32px rgba(220, 38, 38, 0.1);
}

.rate-limited-message::before {
  content: '🚫';
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

/* ===== ANIMATIONS ===== */
@keyframes slideInError {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

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

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

@keyframes errorIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes successPulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

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

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

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

/* ===== AUTO-FADE FOR SUCCESS MESSAGES ===== */
.messages--status.upload-success {
  animation: slideInSuccess 0.5s ease-out, 
             successFadeOut 0.5s ease-in 4s forwards;
}

@keyframes successFadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    padding: 0;
    margin: 0;
  }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .competition-wrapper {
    margin: 32px auto;
    padding: 1.5rem;
  }
  
  .form-loading-spinner {
    width: 32px;
    height: 32px;
    border-width: 2px;
  }
  
  .form-loading-text {
    font-size: 1rem;
  }
  
  .form-loading-subtext {
    font-size: 0.8rem;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .loading-spinner,
  .form-loading-spinner,
  .submit-button.processing::after {
    animation: none;
  }
  
  .messages--error,
  .messages--status,
  .messages--warning,
  .messages--info.processing-message {
    animation: none;
    transition: none;
  }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
  .messages--error,
  .messages--status,
  .messages--warning,
  .messages--info.processing-message {
    border-width: 2px;
    background: #fff;
  }
}

/* ===== TERMS AND MISCELLANEOUS ===== */
#terms.competitions-full-width-text {
  max-width: 1200px;
}

/* ===== ENHANCED LOADING STATES FOR FORM ITEMS ===== */
.js-form-item.processing,
.form-item.processing,
.js-form-item-imageuri.processing {
  position: relative;
  opacity: 0.8;
  pointer-events: none;
}

.js-form-item.processing::after,
.form-item.processing::after,
.js-form-item-imageuri.processing::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 10px;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  border: 2px solid #f3f4f6;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: itemSpinnerRotate 1s linear infinite;
  z-index: 10;
}

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

/* ===== ENHANCED SUBMIT BUTTON LOADING STATES ===== */

/* Make sure the submit button is visible and properly styled */
input[type="submit"], 
.submit-button {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  min-height: 45px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

/* Processing state for submit button */
input[type="submit"].processing,
.submit-button.processing {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%) !important;
  color: transparent !important;
  cursor: wait !important;
  pointer-events: none !important;
  border-color: #6b7280 !important;
}

/* Spinner for submit button */
input[type="submit"].processing::before,
.submit-button.processing::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #ffffff;
  border-radius: 50%;
  animation: submitSpinnerRotate 1s linear infinite;
  z-index: 10;
}

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

/* ===== FORM LOADING OVERLAY - ENHANCED ===== */
.form-loading-overlay {
  position: absolute !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(44, 65, 119, 0.95) !important; /* Your theme color with opacity */
  display: flex !important;
  align-items: center;
  justify-content: center;
  z-index: 9999 !important;
  border-radius: 12px;
  backdrop-filter: blur(4px);
  animation: overlayFadeIn 0.3s ease-out;
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(4px);
  }
}

.form-loading-content {
  text-align: center;
  padding: 2rem;
  color: #fff;
  animation: contentSlideUp 0.4s ease-out 0.1s both;
}

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

.form-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #ffffff;
  border-radius: 50%;
  animation: formSpinnerRotate 1s linear infinite;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

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

.form-loading-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.form-loading-subtext {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ===== ENSURE FORM HAS PROPER POSITIONING ===== */
.competition-form,
.upload-wrapper,
form.competition-form {
  position: relative !important;
  min-height: 200px; /* Ensure there's space for overlay */
}

/* ===== DISABLED BUTTON STATES ===== */
input[type="submit"]:disabled,
.submit-button:disabled,
input[type="submit"].disabled,
.submit-button.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: #9ca3af !important;
  border-color: #9ca3af !important;
}

/* ===== PROCESSING MESSAGE ENHANCED ===== */
.messages--info.processing-message {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-left: 4px solid #3b82f6;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #1e40af;
  font-size: 0.875rem;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInProcessing 0.3s ease-out;
  box-shadow: 0 4px 6px rgba(59, 130, 246, 0.1);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  animation: spinnerRotate 1s linear infinite;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

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

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

/* ===== DEBUG STYLES (visible indicators) ===== */
.debug-submit-processing {
  outline: 3px dashed #ff0000 !important;
  outline-offset: 2px;
}

.debug-overlay-active {
  outline: 5px solid #00ff00 !important;
}

/* ===== DRUPAL ERROR MESSAGE OVERRIDES FOR COMPETITION FORM ===== */

/* Target Drupal messages container within competition wrapper */
.competition-wrapper [data-drupal-messages],
.competition-form [data-drupal-messages],
.upload-wrapper [data-drupal-messages] {
  margin: 1rem 0;
}

/* Override Bootstrap alert styles for competition form */
.competition-wrapper .alert,
.competition-form .alert,
.upload-wrapper .alert {
  border-radius: 8px !important;
  padding: 1rem !important;
  margin: 1rem 0 !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  border: none !important;
  position: relative;
  animation: slideInError 0.4s ease-out;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
}

/* Error/Danger alerts */
.competition-wrapper .alert-danger,
.competition-form .alert-danger,
.upload-wrapper .alert-danger {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%) !important;
  border-left: 4px solid #dc2626 !important;
  color: #991b1b !important;
}

/* Add warning icon to error messages */
.competition-wrapper .alert-danger::before,
.competition-form .alert-danger::before,
.upload-wrapper .alert-danger::before {
  content: '⚠️';
  font-size: 1.2rem;
  margin-right: 0.75rem;
  animation: errorIconPulse 2s ease-in-out infinite;
  background-image: none !important;
}

/* Success alerts */
.competitionthe-heart-of-every-bake .alert-success,
.competitionsalwayson .alert-success,
.competition-wrapper .alert-success,
.competition-form .alert-success,
.upload-wrapper .alert-success {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
  border-left: 4px solid #16a34a !important;
  color: #15803d !important;
  position: relative !important;
}

.competition-wrapper .alert-success::before,
.competition-form .alert-success::before,
.upload-wrapper .alert-success::before {
  content: '✅';
  font-size: 1.2rem;
  margin-right: 0.75rem;
  animation: successPulse 0.6s ease-out;
}

/* Warning alerts */
.competitionthe-heart-of-every-bake .alert-warning,
.competitionsalwayson .alert-warning,
.competition-wrapper .alert-warning,
.competition-form .alert-warning,
.upload-wrapper .alert-warning {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%) !important;
  border-left: 4px solid #f59e0b !important;
  color: #92400e !important;
}

.competition-wrapper .alert-warning::before,
.competition-form .alert-warning::before,
.upload-wrapper .alert-warning::before {
  content: '⚠️';
  font-size: 1.2rem;
  margin-right: 0.75rem;
  background-image: none !important;
}

/* Info alerts */
.competition-wrapper .alert-info,
.competition-form .alert-info,
.upload-wrapper .alert-info {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%) !important;
  border-left: 4px solid #3b82f6 !important;
  color: #1e40af !important;
}

.competition-wrapper .alert-info::before,
.competition-form .alert-info::before,
.upload-wrapper .alert-info::before {
  content: 'ℹ️';
  font-size: 1.2rem;
  margin-right: 0.75rem;
}

/* Hide the default close button */
.competition-wrapper .alert .close,
.competition-form .alert .close,
.upload-wrapper .alert .close,
.competition-wrapper .alert [aria-hidden="true"],
.competition-form .alert [aria-hidden="true"],
.upload-wrapper .alert [aria-hidden="true"] {
  display: none !important;
}

/* Style the item list within error messages */
.competition-wrapper .alert .item-list,
.competition-form .alert .item-list,
.upload-wrapper .alert .item-list {
  margin: 0.5rem 0 0 0 !important;
}

.competition-wrapper .alert .list-group,
.competition-form .alert .list-group,
.upload-wrapper .alert .list-group {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

.competition-wrapper .alert .list-group-item,
.competition-form .alert .list-group-item,
.upload-wrapper .alert .list-group-item {
  background: rgba(220, 38, 38, 0.05) !important;
  border: 1px solid rgba(220, 38, 38, 0.2) !important;
  border-radius: 4px !important;
  padding: 0.5rem !important;
  margin: 0.25rem 0 !important;
  font-size: 0.8rem !important;
  color: #7f1d1d !important;
   width: 100% !important;
}

/* Style placeholder text (italicized file names) */
.competition-wrapper .alert .placeholder,
.competition-form .alert .placeholder,
.upload-wrapper .alert .placeholder {
  font-style: italic !important;
  font-weight: 600 !important;
  color: #dc2626 !important;
  background: rgba(220, 38, 38, 0.1) !important;
  padding: 2px 4px !important;
  border-radius: 3px !important;
  font-family: 'Courier New', monospace !important;
  font-size: 0.85em !important;
}

/* Remove Bootstrap fade and show classes interference */
.competition-wrapper .alert.fade,
.competition-form .alert.fade,
.upload-wrapper .alert.fade {
  opacity: 1 !important;
}

.competition-wrapper .alert.show,
.competition-form .alert.show,
.upload-wrapper .alert.show {
  display: block !important;
}

/* Ensure proper spacing and layout */
.competition-wrapper .col-12,
.competition-form .col-12,
.upload-wrapper .col-12 {
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Add proper animations */
@keyframes slideInError {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes errorIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes successPulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Make error messages more prominent */
.competition-wrapper .alert-danger,
.competition-form .alert-danger,
.upload-wrapper .alert-danger {
  border: 2px solid #fca5a5 !important;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15) !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .competition-wrapper .alert,
  .competition-form .alert,
  .upload-wrapper .alert {
    padding: 0.75rem !important;
    font-size: 0.8rem !important;
  }
  
  .competition-wrapper .alert::before,
  .competition-form .alert::before,
  .upload-wrapper .alert::before {
    font-size: 1rem !important;
  }
}
/* Add this to your competition_form.css file */

.upload-message {
  margin-top: 10px;
  padding: 10px 15px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.upload-message.loading {
  background-color: #e3f2fd;
  border: 1px solid #2196f3;
  color: #1976d2;
}

.upload-message.success {
  background-color: #e8f5e8;
  border: 1px solid #4caf50;
  color: #2e7d32;
}

.upload-message.error {
  background-color: #ffebee;
  border: 1px solid #f44336;
  color: #c62828;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e3f2fd;
  border-top: 2px solid #2196f3;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.success-icon {
  color: #4caf50;
  font-weight: bold;
  font-size: 16px;
}

.error-icon {
  color: #f44336;
  font-weight: bold;
  font-size: 16px;
}

.submit-button.uploading {
  opacity: 0.6;
  cursor: not-allowed;
}

.submit-button.uploading:after {
  content: " (Uploading...)";
  font-size: 12px;
}