/* 
 * Mobile-First Form Styles for FoodStudio
 * 
 * This file contains mobile-optimized styles for all forms in the app,
 * including authentication forms, recipe forms, and grocery list forms.
 * 
 * For intern learning: Forms are critical for mobile UX. Always ensure:
 * - Touch targets are at least 44px
 * - Input font-size is 16px+ to prevent zoom on iOS
 * - Labels are clearly associated with inputs
 * - Error states are visible and accessible
 */

/* =============================================================================
   MOBILE-FIRST FORM BASE STYLES
   ============================================================================= */

/* Form containers */
.form-container {
  padding: 20px 16px;
  max-width: 100%;
}

.form-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px 20px;
  margin-bottom: 20px;
}

/* Form groups and fields */
.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

/* Labels - mobile optimized */
.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}

.form-label.required::after {
  content: " *";
  color: var(--accent);
}

/* Input fields - mobile first */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 48px; /* Larger touch target for mobile */
  padding: 0 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* Prevent zoom on iOS */
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.form-textarea {
  height: auto;
  min-height: 120px;
  padding: 16px;
  resize: vertical;
  line-height: 1.5;
}

/* Focus states */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Error states */
.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-error {
  color: #dc2626;
  font-size: 14px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-error::before {
  content: "⚠";
  font-size: 16px;
}

/* Success states */
.form-input.success,
.form-select.success,
.form-textarea.success {
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.form-success {
  color: #16a34a;
  font-size: 14px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-success::before {
  content: "✓";
  font-size: 16px;
}

/* Form buttons - mobile optimized */
.form-button {
  width: 100%;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: 24px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s ease, transform 0.1s ease;
  text-decoration: none;
}

.form-button:hover {
  background: #dc2626;
}

.form-button:active {
  transform: translateY(1px);
}

.form-button:disabled {
  background: var(--muted);
  cursor: not-allowed;
  transform: none;
}

.form-button--secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
}

.form-button--secondary:hover {
  background: var(--border);
}

.form-button--ghost {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}

.form-button--ghost:hover {
  background: var(--accent);
  color: white;
}

/* Button groups */
.form-button-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

/* Checkbox and radio inputs */
.form-checkbox,
.form-radio {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  cursor: pointer;
}

.form-checkbox input,
.form-radio input {
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.form-checkbox label,
.form-radio label {
  margin: 0;
  cursor: pointer;
  font-weight: 400;
  line-height: 1.4;
}

/* File inputs */
.form-file {
  position: relative;
  overflow: hidden;
  display: inline-block;
  width: 100%;
}

.form-file input[type="file"] {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

.form-file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  padding: 0 24px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.form-file-label:hover {
  border-color: var(--accent);
  background: rgba(239, 68, 68, 0.05);
}

.form-file-label::before {
  content: "📁";
  font-size: 18px;
}

/* =============================================================================
   AUTHENTICATION FORMS
   ============================================================================= */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--heading);
  margin: 0 0 8px;
}

.auth-subtitle {
  font-size: 16px;
  color: var(--muted);
  margin: 0;
}

.auth-form .form-group {
  margin-bottom: 24px;
}

.auth-links {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  display: inline-block;
  margin: 8px 0;
}

.auth-link:hover {
  text-decoration: underline;
}

/* =============================================================================
   RECIPE FORMS
   ============================================================================= */

.recipe-form-container {
  max-width: 100%;
  margin: 0;
  padding: 16px;
}

.recipe-form-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 0;
}

.recipe-form-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--heading);
  margin: 0;
  flex: 1;
}

.recipe-form-back {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 18px;
}

.recipe-form-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px 20px;
  margin-bottom: 24px;
}

/* Dynamic list items (ingredients, instructions) */
.dynamic-list {
  margin: 20px 0;
}

.dynamic-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.dynamic-item-handle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: grab;
  font-size: 16px;
  margin-top: 12px;
}

.dynamic-item-handle:active {
  cursor: grabbing;
}

.dynamic-item-input {
  flex: 1;
  margin: 0;
}

.dynamic-item-remove {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  margin-top: 6px;
}

.dynamic-item-remove:hover {
  background: #fee2e2;
}

.dynamic-add {
  width: 100%;
  height: 44px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.dynamic-add:hover {
  border-color: var(--accent);
  background: rgba(239, 68, 68, 0.05);
}

.dynamic-add::before {
  content: "+";
  font-size: 20px;
  font-weight: 700;
}

/* =============================================================================
   SEARCH FORMS
   ============================================================================= */

.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.search-input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  border: 2px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.search-button {
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: 24px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.search-button:hover {
  background: #dc2626;
}

/* =============================================================================
   TABLET STYLES (768px and up)
   ============================================================================= */

@media (min-width: 768px) {
  .form-container {
    padding: 32px 24px;
  }
  
  .form-card {
    padding: 32px;
  }
  
  .form-button-group {
    flex-direction: row;
    justify-content: flex-end;
  }
  
  .form-button {
    width: auto;
    min-width: 120px;
  }
  
  .recipe-form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 24px;
  }
  
  .recipe-form-card {
    padding: 32px;
  }
  
  .dynamic-item {
    padding: 16px;
  }
  
  .auth-card {
    padding: 40px 32px;
  }
}

/* =============================================================================
   DESKTOP STYLES (1024px and up)
   ============================================================================= */

@media (min-width: 1024px) {
  .form-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 48px 32px;
  }
  
  .recipe-form-container {
    max-width: 1000px;
    padding: 48px 32px;
  }
  
  /* Two-column layout for larger forms */
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
  
  .form-grid .form-group--full {
    grid-column: 1 / -1;
  }
}

/* =============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================= */

/* High contrast mode */
@media (prefers-contrast: high) {
  .form-input,
  .form-select,
  .form-textarea {
    border-width: 3px;
  }
  
  .form-button {
    border: 2px solid currentColor;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .form-input,
  .form-select,
  .form-textarea,
  .form-button {
    transition: none;
  }
}

/* Focus visible for keyboard navigation */
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible,
.form-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
