/**
 * Custom Content Form Styles
 * Phase 1: 「その他」ジャンル選択時のカスタムコンテンツフォーム
 * Phase 1.1: 共通フィールドとカスタムフィールドの分離対応
 */

/* ===== 共通フィールド（通常ジャンル用） ===== */
.common-fields {
  /* 共通フィールドの基本スタイル */
  transition: all 0.3s ease;
}

.common-fields .input-group {
  margin-bottom: 20px;
}

.common-fields .input-label {
  display: flex;
  align-items: center;
  font-weight: 500;
  color: #495057;
  margin-bottom: 8px;
  font-size: 14px;
}

.common-fields .input-label.required::after {
  content: ' *';
  color: #dc3545;
  font-weight: bold;
}

.common-fields .input-desc {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: #6c757d;
  line-height: 1.4;
}

.common-fields .brand-input,
.common-fields .brand-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  transition: all 0.2s ease;
  background: white;
  font-family: inherit;
}

.common-fields .brand-input:focus,
.common-fields .brand-textarea:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.common-fields .brand-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.common-fields .validation-error {
  margin-top: 6px;
  padding: 8px 12px;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  color: #721c24;
  font-size: 13px;
  line-height: 1.4;
}

/* 共通フィールドの非表示状態 */
.common-fields[aria-hidden="true"] {
  display: none !important;
}

/* 共通フィールドの表示状態 */
.common-fields[aria-hidden="false"] {
  display: block;
}

/* ===== カスタムフィールド（その他ジャンル用） ===== */
.custom-content-form {
  margin-top: 20px;
  padding: 20px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  transition: all 0.3s ease;
}

/* カスタムフィールドの非表示状態 */
.custom-content-form[aria-hidden="true"] {
  display: none !important;
}

/* カスタムフィールドの表示状態 */
.custom-content-form[aria-hidden="false"] {
  display: block;
}

.custom-content-form.show {
  display: block !important;
  animation: slideDown 0.3s ease-out;
}

.custom-content-form.hide {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 500px;
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translateY(0);
    max-height: 500px;
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
  }
}

.custom-form-header {
  margin-bottom: 20px;
  text-align: center;
}

.custom-form-header h4 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
}

.custom-form-description {
  margin: 0;
  font-size: 14px;
  color: #6c757d;
  line-height: 1.4;
}

.custom-content-form .input-group {
  margin-bottom: 20px;
}

.custom-content-form .input-label {
  display: flex;
  align-items: center;
  font-weight: 500;
  color: #495057;
  margin-bottom: 8px;
  font-size: 14px;
}

.custom-content-form .input-label.required::after {
  content: ' *';
  color: #dc3545;
  font-weight: bold;
}

.custom-content-form .optional {
  font-weight: normal;
  color: #6c757d;
  font-size: 12px;
}

.custom-content-form input[type="text"],
.custom-content-form textarea,
.custom-content-form select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  transition: all 0.2s ease;
  background: white;
  font-family: inherit;
}

.custom-content-form input[type="text"]:focus,
.custom-content-form textarea:focus,
.custom-content-form select:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.custom-content-form input[type="text"]:invalid,
.custom-content-form textarea:invalid,
.custom-content-form select:invalid {
  border-color: #dc3545;
}

.custom-content-form input[type="text"]:invalid:focus,
.custom-content-form textarea:invalid:focus,
.custom-content-form select:invalid:focus {
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* textarea専用スタイル */
.custom-content-form textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* select専用スタイル */
.custom-content-form select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
}

/* optgroupスタイル */
.custom-content-form optgroup {
  font-weight: 600;
  color: #374151;
  padding: 8px 0;
}

.custom-content-form optgroup option {
  font-weight: normal;
  color: #6b7280;
  padding: 4px 8px;
}

.input-help {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #6c757d;
  line-height: 1.3;
}

/* 文字数カウント用のコンテナ */
.input-help-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 4px;
  gap: 8px;
}

.input-help-container .input-help {
  flex: 1;
  margin-top: 0;
}

/* 文字数カウント表示 */
.char-count {
  font-size: 12px;
  font-weight: 500;
  color: #6c757d;
  white-space: nowrap;
  transition: color 0.2s ease;
}

/* 文字数制限の状態別スタイル */
.char-count.warning {
  color: #ffc107;
}

.char-count.error {
  color: #dc3545;
}

.char-count.success {
  color: #28a745;
}

/* 入力フィールドの状態に応じた文字数カウントの色 */
.custom-content-form input:focus + .input-help-container .char-count,
.custom-content-form textarea:focus + .input-help-container .char-count {
  color: #007bff;
}

.custom-content-form input.error + .input-help-container .char-count,
.custom-content-form textarea.error + .input-help-container .char-count {
  color: #dc3545;
}

.custom-content-form .validation-error {
  margin-top: 6px;
  padding: 8px 12px;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  color: #721c24;
  font-size: 13px;
  line-height: 1.4;
}

.custom-content-form .error-message {
  margin-top: 16px;
  padding: 12px 16px;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  color: #721c24;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

/* ===== Pre-Guide (最小スタイル) ===== */
.pre-guide {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0 16px;
  color: #6c757d;
  font-size: 14px;
  line-height: 1.6;
}
.pre-guide h4 {
  margin: 0 0 8px 0;
  color: #495057;
  font-size: 15px;
  font-weight: 600;
}
.pre-guide ul {
  margin: 8px 0 0 16px;
  padding: 0;
}
.pre-guide li { margin: 4px 0; }

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .common-fields .input-group {
    margin-bottom: 16px;
  }
  
  .common-fields .brand-input,
  .common-fields .brand-textarea {
    padding: 10px 14px;
    font-size: 16px; /* iOS Safari のズーム防止 */
  }
  
  .custom-content-form {
    margin-top: 16px;
    padding: 16px;
  }
  
  .custom-form-header h4 {
    font-size: 16px;
  }
  
  .custom-content-form input[type="text"] {
    padding: 10px 14px;
    font-size: 16px; /* iOS Safari のズーム防止 */
  }
}

/* ダークモード対応（将来の拡張用） */
@media (prefers-color-scheme: dark) {
  .common-fields .input-label {
    color: #e2e8f0;
  }
  
  .common-fields .input-desc {
    color: #a0aec0;
  }
  
  .common-fields .brand-input,
  .common-fields .brand-textarea {
    background: #4a5568;
    border-color: #718096;
    color: #e2e8f0;
  }
  
  .common-fields .brand-input:focus,
  .common-fields .brand-textarea:focus {
    border-color: #63b3ed;
    box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.1);
  }
  
  .custom-content-form {
    background: #2d3748;
    border-color: #4a5568;
  }
  
  .custom-form-header h4 {
    color: #e2e8f0;
  }
  
  .custom-form-description {
    color: #a0aec0;
  }
  
  .custom-content-form .input-label {
    color: #e2e8f0;
  }
  
  .custom-content-form input[type="text"] {
    background: #4a5568;
    border-color: #718096;
    color: #e2e8f0;
  }
  
  .custom-content-form input[type="text"]:focus {
    border-color: #63b3ed;
    box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.1);
  }
  
  .input-help {
    color: #a0aec0;
  }
}
