/**
 * Zammad Support Form Custom Styling
 * 
 * Custom styling for Zammad Forms using Horsify's Tailwind design system.
 * This file provides styling when noCSS: true is set in the Zammad configuration.
 * 
 * The form is rendered as a modal overlay with Horsify branding and design tokens.
 */

/* ============================================================================
   MODAL OVERLAY & CONTAINER
   ========================================================================= */

/* Modal backdrop overlay */
.zammad-form-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgb(0 0 0 / 50%);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

/* Modal container */
.zammad-form-modal {
  background-color: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 10%), 0 10px 10px -5px rgb(0 0 0 / 4%);
  max-width: 42rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

/* Dark mode support for modal */
[data-theme="dark"] .zammad-form-modal {
  background-color: #2d2d2d;
  border: 1px solid #404040;
}

/* ============================================================================
   MODAL HEADER
   ========================================================================= */

.zammad-form-modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

[data-theme="dark"] .zammad-form-modal-header {
  border-bottom-color: #404040;
}

.zammad-form-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #212529;
  margin: 0;
}

[data-theme="dark"] .zammad-form-modal-title {
  color: #f5f5f5;
}

/* Close button */
.zammad-form-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #495057;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.15s ease-in-out;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
}

.zammad-form-modal-close:hover {
  color: #212529;
}

.zammad-form-modal-close:focus {
  outline: none;
  box-shadow: 0 0 0 2px #2e4e3f;
}

[data-theme="dark"] .zammad-form-modal-close {
  color: #a0a0a0;
}

[data-theme="dark"] .zammad-form-modal-close:hover {
  color: #f5f5f5;
}

[data-theme="dark"] .zammad-form-modal-close:focus {
  box-shadow: 0 0 0 2px #8a6b14;
}

/* ============================================================================
   MODAL BODY & FORM
   ========================================================================= */

.zammad-form-modal-body {
  padding: 1.5rem;
}

.zammad-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Form group */
.zammad-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* Labels */
.zammad-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #212529;
  margin-bottom: 0.375rem;
}

[data-theme="dark"] .zammad-form label {
  color: #f5f5f5;
}

/* Required indicator */
.zammad-form label .required {
  color: #dc2626;
  margin-left: 0.125rem;
}

/* Form inputs */
.zammad-form input[type="text"],
.zammad-form input[type="email"],
.zammad-form textarea,
.zammad-form select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #212529;
  background-color: #fff;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

[data-theme="dark"] .zammad-form input[type="text"],
[data-theme="dark"] .zammad-form input[type="email"],
[data-theme="dark"] .zammad-form textarea,
[data-theme="dark"] .zammad-form select {
  background-color: #2d2d2d;
  border-color: #404040;
  color: #f5f5f5;
}

.zammad-form input:focus,
.zammad-form textarea:focus,
.zammad-form select:focus {
  outline: none;
  border-color: #2e4e3f;
  box-shadow: 0 0 0 2px rgb(46 78 63 / 20%);
}

[data-theme="dark"] .zammad-form input:focus,
[data-theme="dark"] .zammad-form textarea:focus,
[data-theme="dark"] .zammad-form select:focus {
  border-color: #8a6b14;
  box-shadow: 0 0 0 2px rgb(138 107 20 / 20%);
}

/* Textarea specific */
.zammad-form textarea {
  min-height: 120px;
  resize: vertical;
}

/* File upload */
.zammad-form input[type="file"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px dashed #dee2e6;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  background-color: #f8f9fa;
}

[data-theme="dark"] .zammad-form input[type="file"] {
  background-color: #1a1a1a;
  border-color: #404040;
  color: #f5f5f5;
}

.zammad-form input[type="file"]:hover {
  background-color: #e9ecef;
}

[data-theme="dark"] .zammad-form input[type="file"]:hover {
  background-color: #3a3a3a;
}

/* ============================================================================
   CHECKBOXES & AGREEMENTS
   ========================================================================= */

.zammad-form-agreement {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  background-color: #f8f9fa;
  border-radius: 0.5rem;
  border: 1px solid #dee2e6;
}

[data-theme="dark"] .zammad-form-agreement {
  background-color: #1a1a1a;
  border-color: #404040;
}

.zammad-form-agreement input[type="checkbox"] {
  margin-top: 0.25rem;
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.zammad-form-agreement label {
  font-size: 0.75rem;
  color: #495057;
  margin-bottom: 0;
  cursor: pointer;
}

[data-theme="dark"] .zammad-form-agreement label {
  color: #a0a0a0;
}

.zammad-form-agreement a {
  color: #2e4e3f;
  text-decoration: underline;
}

.zammad-form-agreement a:hover {
  color: #4a6f5c;
}

[data-theme="dark"] .zammad-form-agreement a {
  color: #8a6b14;
}

[data-theme="dark"] .zammad-form-agreement a:hover {
  color: #6f5610;
}

/* ============================================================================
   ERROR MESSAGES
   ========================================================================= */

.zammad-form-error {
  color: #dc2626;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.zammad-form input.error,
.zammad-form textarea.error,
.zammad-form select.error {
  border-color: #dc2626;
}

.zammad-form input.error:focus,
.zammad-form textarea.error:focus,
.zammad-form select.error:focus {
  box-shadow: 0 0 0 2px rgb(220 38 38 / 20%);
}

/* ============================================================================
   BUTTONS
   ========================================================================= */

.zammad-form-modal-footer {
  padding: 1.5rem;
  border-top: 1px solid #dee2e6;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

[data-theme="dark"] .zammad-form-modal-footer {
  border-top-color: #404040;
}

.zammad-form button[type="submit"],
.zammad-form-submit {
  padding: 0.5rem 1rem;
  background-color: #2e4e3f;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
  min-width: 44px;
  min-height: 44px;
}

.zammad-form button[type="submit"]:hover,
.zammad-form-submit:hover {
  background-color: #4a6f5c;
}

.zammad-form button[type="submit"]:focus,
.zammad-form-submit:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(46 78 63 / 40%);
}

.zammad-form button[type="submit"]:disabled,
.zammad-form-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

[data-theme="dark"] .zammad-form button[type="submit"],
[data-theme="dark"] .zammad-form-submit {
  background-color: #2e4e3f;
}

[data-theme="dark"] .zammad-form button[type="submit"]:hover,
[data-theme="dark"] .zammad-form-submit:hover {
  background-color: #4a6f5c;
}

[data-theme="dark"] .zammad-form button[type="submit"]:focus,
[data-theme="dark"] .zammad-form-submit:focus {
  box-shadow: 0 0 0 2px rgb(138 107 20 / 40%);
}

/* Cancel button */
.zammad-form-cancel,
.zammad-form button[type="button"] {
  padding: 0.5rem 1rem;
  background-color: #6b5f4f;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease-in-out;
  min-width: 44px;
  min-height: 44px;
}

.zammad-form-cancel:hover,
.zammad-form button[type="button"]:hover {
  opacity: 0.9;
}

.zammad-form-cancel:focus,
.zammad-form button[type="button"]:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgb(107 95 79 / 40%);
}

/* ============================================================================
   SUCCESS MESSAGE
   ========================================================================= */

.zammad-form-message-success {
  padding: 1rem;
  background-color: #d1fae5;
  color: #047857;
  border-radius: 0.5rem;
  border: 1px solid #10b981;
  font-size: 0.875rem;
}

[data-theme="dark"] .zammad-form-message-success {
  background-color: rgb(16 185 129 / 10%);
  color: #10b981;
  border-color: #10b981;
}

/* ============================================================================
   LOADING SPINNER
   ========================================================================= */

.zammad-form-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgb(255 255 255 / 30%);
  border-top-color: #fff;
  border-radius: 50%;
  animation: zammad-spin 0.6s linear infinite;
  margin-right: 0.5rem;
}

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

/* ============================================================================
   MOBILE RESPONSIVE
   ========================================================================= */

@media (width <= 640px) {
  .zammad-form-modal-backdrop {
    padding: 0.5rem;
  }

  .zammad-form-modal {
    max-height: 95vh;
  }

  .zammad-form-modal-header,
  .zammad-form-modal-body,
  .zammad-form-modal-footer {
    padding: 1rem;
  }

  .zammad-form-modal-footer {
    flex-direction: column;
  }

  .zammad-form button[type="submit"],
  .zammad-form-submit,
  .zammad-form-cancel,
  .zammad-form button[type="button"] {
    width: 100%;
  }
}
