/**
 * Apply Modal Styles
 * Job application creation modal with responsive design
 */

/* Modal Container */
#apply-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#apply-modal.open {
  display: flex;
  opacity: 1;
  z-index: 2001;
}

/* Modal Overlay (Backdrop) */
.apply-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: -1;
}

/* Modal Content Box */
.apply-modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 2002;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translate(-50%, -48%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
}

/* Modal Header */
.apply-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px 12px 0 0;
}

.apply-modal-header h2 {
  margin: 0;
  color: #fff;
  font-size: 20px;
  font-weight: 600;
}

/* Close Button */
.apply-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.apply-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.apply-modal-close:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Modal Body */
.apply-modal-body {
  padding: 24px;
}

/* Not Logged In State */
.apply-modal-not-logged-in {
  text-align: center;
  padding: 40px 20px;
}

.apply-modal-not-logged-in p {
  color: #6b7280;
  font-size: 16px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Form Groups */
.form-group {
  margin-bottom: 20px;
}

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

.form-group .form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-color: #f9fafb;
}

.form-group .form-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background-color: #fff;
}

.form-group .form-control[readonly] {
  background-color: #f3f4f6;
  cursor: not-allowed;
  color: #6b7280;
}

.form-group select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23374151'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 20px;
  padding-right: 32px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.form-group small {
  display: block;
  margin-top: 6px;
  color: #9ca3af;
  font-size: 13px;
  line-height: 1.4;
}

/* Modal Actions */
.apply-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

/* Button Styles */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

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

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.btn-primary:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Secondary Button */
.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.btn-secondary:focus {
  outline: 2px solid #9ca3af;
  outline-offset: 2px;
}

/* Loading State */
.apply-modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.apply-modal-loading p {
  color: #6b7280;
  font-size: 14px;
  margin: 0;
}

/* Error State */
.apply-modal-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 20px;
}

.apply-modal-error p {
  color: #991b1b;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

/* Responsive Design */

/* Tablet (768px and below) */
@media (max-width: 768px) {
  .apply-modal-content {
    width: 95%;
    max-height: 85vh;
  }

  .apply-modal-header {
    padding: 16px;
  }

  .apply-modal-header h2 {
    font-size: 18px;
  }

  .apply-modal-body {
    padding: 16px;
  }

  .apply-modal-actions {
    flex-direction: column;
    gap: 8px;
  }

  .btn {
    width: 100%;
    padding: 12px;
  }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
  .apply-modal-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    max-height: 100vh;
    overflow-y: auto;
    top: 0;
    left: 0;
    transform: none;
  }

  .apply-modal-overlay {
    display: none;
  }

  .apply-modal-header {
    padding: 12px;
    position: sticky;
    top: 0;
  }

  .apply-modal-header h2 {
    font-size: 16px;
  }

  .apply-modal-body {
    padding: 12px;
  }

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

  .form-group label {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .form-group .form-control {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
  }

  .apply-modal-actions {
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
  }

  .btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
  }

  .apply-modal-not-logged-in {
    padding: 24px 12px;
  }

  .apply-modal-loading {
    padding: 32px 12px;
  }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
  .apply-modal-content {
    background: #1f2937;
    color: #f3f4f6;
  }

  .apply-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom-color: #374151;
  }

  .apply-modal-header h2 {
    color: #fff;
  }

  .form-group label {
    color: #e5e7eb;
  }

  .form-group .form-control {
    background-color: #111827;
    border-color: #374151;
    color: #f3f4f6;
  }

  .form-group .form-control:focus {
    background-color: #1f2937;
    border-color: #667eea;
  }

  .form-group .form-control[readonly] {
    background-color: #111827;
    color: #9ca3af;
  }

  .form-group small {
    color: #6b7280;
  }

  .btn-secondary {
    background: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
  }

  .btn-secondary:hover:not(:disabled) {
    background: #4b5563;
    border-color: #6b7280;
  }

  .apply-modal-error {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fecaca;
  }

  .apply-modal-error p {
    color: #fecaca;
  }

  .spinner {
    border-color: #374151;
    border-top-color: #667eea;
  }

  .apply-modal-actions {
    border-top-color: #374151;
  }

  .apply-modal-not-logged-in p,
  .apply-modal-loading p {
    color: #d1d5db;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  #apply-modal,
  .apply-modal-content,
  .form-group .form-control,
  .btn {
    animation: none !important;
    transition: none !important;
  }
}
