/**
 * Telegram Form Frontend Styles
 * Inspired by the reference screenshot — warm gradient, rounded inputs, modern feel
 */

/* ===== Wrapper ===== */
.tg-form-wrapper {
  max-width: var(--tg-max-width, 720px);
  margin: 30px auto;
  padding: var(--tg-padding-top, 36px) var(--tg-padding-right, 40px) var(--tg-padding-bottom, 36px) var(--tg-padding-left, 40px);
  border-radius: var(--tg-radius, 16px);
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ===== Subtitle ===== */
.tg-form-subtitle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #3a5a00;
  margin: 0 0 8px;
  opacity: 0.85;
}

/* ===== Title ===== */
.tg-form-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--tg-title-color, #1a1a2e);
  margin: 0 0 28px;
  line-height: 1.2;
}

/* ===== Grid ===== */
.tg-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 20px;
}

/* ===== Field widths ===== */
.tg-form-field {
  display: flex;
  flex-direction: column;
  position: relative;
}

.tg-form-field-w100 {
  width: 100%;
  flex: 0 0 100%;
}

.tg-form-field-w50 {
  width: calc(50% - 10px);
  flex: 0 0 calc(50% - 10px);
}

.tg-form-field-w33 {
  width: calc(33.333% - 14px);
  flex: 0 0 calc(33.333% - 14px);
}

/* ===== Label ===== */
.tg-form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-label-color, #2c2c3a);
  margin-bottom: 6px;
  display: block;
}

.tg-form-req {
  color: #e74c3c;
  font-weight: 700;
}

/* ===== Controls ===== */
.tg-form-control {
  width: 100%;
  padding: 14px 18px;
  font-size: 15px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  color: #1a1a2e;
  transition: all 0.25s ease;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
}

.tg-form-control::placeholder {
  color: #999;
  font-weight: 400;
}

.tg-form-control:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.06);
}

.tg-form-control:focus,
.tg-form-control.tg-form-focused {
  background: #fff;
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.tg-form-control.tg-form-invalid {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.12);
}

/* Textarea */
textarea.tg-form-control {
  resize: vertical;
  min-height: 100px;
}

/* Select */
select.tg-form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

/* Checkbox */
.tg-form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 0;
  font-size: 14px;
  color: var(--tg-label-color, #2c2c3a);
}

.tg-form-checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #4caf50;
  cursor: pointer;
}

/* ===== Error message ===== */
.tg-form-error {
  font-size: 12px;
  color: #e74c3c;
  margin-top: 4px;
  font-weight: 500;
}

/* ===== Footer & Submit ===== */
.tg-form-footer {
  margin-top: 5px;
  text-align: var(--tg-btn-align, center);
}

.tg-form-submit {
  display: inline-flex;
  width: var(--tg-btn-width, auto);
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 48px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
  font-family: inherit;
}

.tg-form-submit::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.tg-form-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.tg-form-submit:hover::before {
  left: 100%;
}

.tg-form-submit:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tg-form-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.tg-form-spinner {
  display: inline-flex;
  align-items: center;
}

/* ===== Messages ===== */
.tg-form-message {
  margin-top: 16px;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  animation: tgFadeIn 0.35s ease;
}

.tg-form-message-success {
  background: rgba(76, 175, 80, 0.15);
  color: #2e7d32;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.tg-form-message-error {
  background: rgba(231, 76, 60, 0.1);
  color: #c0392b;
  border: 1px solid rgba(231, 76, 60, 0.25);
}

/* ===== Success animation ===== */
.tg-form.tg-form-success .tg-form-grid {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* ===== Animations ===== */
@keyframes tgFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .tg-form-wrapper {
    padding: calc(var(--tg-padding-top, 36px) * 0.7) calc(var(--tg-padding-right, 40px) * 0.5) calc(var(--tg-padding-bottom, 36px) * 0.7) calc(var(--tg-padding-left, 40px) * 0.5);
    border-radius: 12px;
    margin: 16px;
  }

  .tg-form-title {
    font-size: 24px;
    margin-bottom: 20px;
  }

  .tg-form-subtitle {
    font-size: 11px;
  }

  .tg-form-field-w50,
  .tg-form-field-w33 {
    width: 100%;
    flex: 0 0 100%;
  }

  .tg-form-control {
    padding: 12px 14px;
    font-size: 14px;
  }

  .tg-form-submit {
    width: 100%;
    padding: 14px 32px;
  }
}

@media (max-width: 768px) and (min-width: 601px) {
  .tg-form-field-w33 {
    width: calc(50% - 10px);
    flex: 0 0 calc(50% - 10px);
  }
}
