/* === Forms Page === */
.forms-page {
  padding: 84px 0 0;
  background: var(--paper);
  min-height: 100vh;
}
.forms-page__layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.forms-loading {
  text-align: center;
  padding: 80px 0;
  color: var(--slate);
  font-size: 16px;
}
.forms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}
.forms-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.form-card {
  background: var(--white);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.form-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.form-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.form-card__title {
  font-size: 16px;
  font-weight: 700;
}
.form-card__dept {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.form-card__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--slate);
}
.forms-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 0;
  color: var(--slate);
}
.forms-empty svg {
  margin-bottom: 16px;
  opacity: 0.4;
}
.forms-empty p {
  font-size: 15px;
}

/* === Editor === */
.editor-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.editor-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  flex: 1;
  text-align: center;
}
.editor-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.editor-body {
  background: var(--white);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 16px;
  padding: 32px;
  animation: editorSlideIn 0.4s ease;
}
.editor-section {
  margin-bottom: 28px;
  animation: editorFadeIn 0.3s ease both;
}
.editor-section:nth-child(1) { animation-delay: 0.1s; }
.editor-section:nth-child(2) { animation-delay: 0.2s; }
.editor-section:nth-child(3) { animation-delay: 0.3s; }
.editor-section:nth-child(4) { animation-delay: 0.4s; }
.editor-section:last-child {
  margin-bottom: 0;
}
@keyframes editorSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes editorFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.editor-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.editor-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}
.editor-section__header .editor-label {
  margin-bottom: 0;
}
.editor-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  font-size: 15px;
  background: var(--paper);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.editor-input:focus {
  outline: none;
  border-color: var(--blurple);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(88,101,242,0.15), 0 4px 12px rgba(88,101,242,0.1);
  transform: translateY(-1px);
}
.editor-webhook-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.editor-webhook-row .editor-input {
  flex: 1;
}
.editor-webhook-toggle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(0,0,0,0.08) !important;
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  color: var(--slate);
  transition: all 0.2s ease;
  padding: 0;
}
.editor-webhook-toggle:hover {
  border-color: var(--blurple) !important;
  color: var(--blurple);
  background: rgba(88,101,242,0.06);
}
.preview-msg {
  color: #dcddde;
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
.preview-embed {
  background: #2f3136;
  border-left: 4px solid #5865F2;
  border-radius: 4px;
  padding: 12px 16px;
  max-width: 500px;
}
.preview-embed__title {
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}
.preview-embed__field {
  margin-top: 8px;
}
.preview-embed__field-name {
  color: #dcddde;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
.preview-embed__field-value {
  color: #b9bbbe;
  font-size: 14px;
  line-height: 1.3;
}
.preview-embed__footer {
  display: flex;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 12px;
  color: #949ba4;
}
.preview-embed__footer-dot {
  margin: 0 4px;
}
.editor-textarea {
  min-height: 100px;
  resize: vertical;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.5;
}
.editor-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.editor-hint__item {
  font-size: 11px;
  color: var(--slate);
  background: rgba(0,0,0,0.04);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.editor-color-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.editor-color-picker {
  width: 48px;
  height: 40px;
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: var(--white);
}
.editor-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}
.editor-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}
.editor-color-hex {
  width: 100px;
  font-family: monospace;
}
.editor-color-preview {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid rgba(0,0,0,0.08);
}
.field-add {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.fields-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fields-empty {
  text-align: center;
  padding: 40px 0;
  color: var(--slate);
  font-size: 14px;
}
.field-item {
  display: flex;
  gap: 12px;
  background: var(--paper);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 16px;
  transition: background 0.15s;
}
.field-item--dragging {
  opacity: 0.5;
  background: var(--white);
}
.field-item__handle {
  display: flex;
  align-items: center;
  cursor: grab;
  color: var(--slate);
  flex-shrink: 0;
}
.field-item__content {
  flex: 1;
  min-width: 0;
}
.field-item__row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.field-item__label {
  flex: 1;
  min-width: 150px;
  padding: 8px 12px;
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 8px;
  font-size: 14px;
  background: var(--white);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.field-item__label:focus {
  outline: none;
  border-color: var(--blurple);
  box-shadow: 0 0 0 3px rgba(88,101,242,0.12);
  transform: scale(1.01);
}
.field-item__input {
  flex: 1;
  width: 100%;
  padding: 10px 14px;
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 8px;
  font-size: 14px;
  background: var(--white);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}
.field-item__input:focus {
  outline: none;
  border-color: var(--blurple);
  box-shadow: 0 0 0 3px rgba(88,101,242,0.12);
  transform: scale(1.01);
}
.field-item__type {
  font-size: 12px;
  color: var(--slate);
  background: rgba(0,0,0,0.04);
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.field-item__required {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--slate);
  cursor: pointer;
  white-space: nowrap;
}
.field-item__required input {
  accent-color: var(--blurple);
}
.editor-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  user-select: none;
}
.editor-toggle input[type="checkbox"] {
  display: none;
}
.editor-toggle__switch {
  position: relative;
  width: 42px;
  height: 24px;
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.editor-toggle__switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.editor-toggle input:checked + .editor-toggle__switch {
  background: var(--blurple);
}
.editor-toggle input:checked + .editor-toggle__switch::after {
  transform: translateX(18px);
}
.field-item__options {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field-option {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-option__input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 8px;
  font-size: 13px;
  background: var(--white);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.field-option__input:focus {
  outline: none;
  border-color: var(--blurple);
  box-shadow: 0 0 0 3px rgba(88,101,242,0.12);
}
.btn--icon {
  padding: 6px;
  min-width: auto;
}
.btn--danger {
  background: #E74C3C;
  color: white;
  border: none;
}
.btn--danger:hover {
  background: #C0392B;
}
.editor-banner__upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  border: 2px dashed rgba(0,0,0,0.15);
  border-radius: 12px;
  cursor: pointer;
  color: var(--slate);
  transition: all 0.2s ease;
  background: var(--paper);
}
.editor-banner__upload:hover {
  border-color: var(--blurple);
  color: var(--blurple);
  background: rgba(88,101,242,0.04);
}
.editor-banner__upload svg {
  opacity: 0.5;
}
.editor-banner__upload:hover svg {
  opacity: 1;
}
.editor-banner__upload span {
  font-size: 13px;
}
.editor-banner__preview {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(0,0,0,0.06);
}
.editor-banner__preview img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}
.editor-banner__preview .btn {
  position: absolute;
  top: 8px;
  right: 8px;
}
.editor-banner__crop {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 2px solid rgba(0,0,0,0.06);
  width: 100%;
}
.editor-banner__crop img {
  position: absolute;
  top: 0;
  left: 0;
  user-select: none;
  -webkit-user-drag: none;
  cursor: grab;
  transition: none;
  object-fit: none;
  max-width: none;
  max-height: none;
}
.editor-banner__crop img:active {
  cursor: grabbing;
}
.editor-banner__handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: var(--blurple);
  cursor: ns-resize;
  opacity: 0;
  transition: opacity 0.2s;
}
.editor-banner__crop:hover .editor-banner__handle {
  opacity: 1;
}
.editor-banner__delete {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}
.editor-banner__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.editor-banner__controls label {
  font-size: 13px;
  color: var(--slate);
  white-space: nowrap;
  min-width: 70px;
}
.editor-banner__controls input[type="range"] {
  flex: 1;
  accent-color: var(--blurple);
}
.editor-banner__height-val,
.editor-banner__scale-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-width: 50px;
  text-align: right;
}
.editor-banner__hint {
  font-size: 12px;
  color: var(--slate);
  margin-top: 8px;
  text-align: center;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .forms-page__layout {
    padding: 24px 16px;
  }
  .forms-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .editor-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .editor-actions {
    width: 100%;
  }
  .editor-actions .btn {
    flex: 1;
  }
  .field-item__row {
    flex-direction: column;
    align-items: flex-start;
  }
  .field-add {
    width: 100%;
  }
  .field-add .btn {
    flex: 1;
  }
}

/* === Dark Theme Forms === */
[data-theme="dark"] .form-card {
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .form-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] .editor-body {
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .editor-input {
  border-color: rgba(255,255,255,0.08);
  color: var(--ink);
}

[data-theme="dark"] .editor-input:focus {
  background: #1C2128;
}

[data-theme="dark"] .editor-webhook-toggle {
  border-color: rgba(255,255,255,0.08);
  background: #1C2128;
  color: var(--slate);
}
[data-theme="dark"] .editor-webhook-toggle:hover {
  border-color: var(--blurple);
  color: var(--blurple);
}

/* === Form Field Description === */
.form-field__description {
  font-size: 13px;
  color: #475569;
  margin: 4px 0 8px 0;
  line-height: 1.4;
  white-space: pre-wrap;
}

[data-theme="dark"] .form-field__description {
  color: #a8b3c0;
}

/* === Statistics Tab === */
.stats-period-selector {
  display: flex;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.stats-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s;
}

.stats-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stats-card__icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stats-card__content {
  flex: 1;
}

.stats-card__label {
  font-size: 13px;
  color: var(--slate);
  margin-bottom: 4px;
}

.stats-card__value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}

.stats-forms-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-form-item {
  background: var(--white);
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
}

.stats-form-item:hover {
  border-color: var(--blurple);
}

.stats-form-item__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stats-form-item__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.stats-form-item__count {
  font-size: 14px;
  font-weight: 700;
  color: var(--blurple);
}

.stats-form-item__bar {
  height: 8px;
  background: rgba(0,0,0,0.06);
  border-radius: 4px;
  overflow: hidden;
}

.stats-form-item__bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blurple), #7289da);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme stats */
[data-theme="dark"] .stats-card {
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .stats-form-item {
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .stats-form-item:hover {
  border-color: var(--blurple);
}

[data-theme="dark"] .stats-form-item__bar {
  background: rgba(255,255,255,0.06);
}

/* === Loading Spinner === */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(88,101,242,0.1);
  border-top-color: var(--blurple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 14px;
  color: var(--slate);
  font-weight: 500;
}

[data-theme="dark"] .loading-spinner {
  border-color: rgba(88,101,242,0.2);
  border-top-color: var(--blurple);
}

[data-theme="dark"] .editor-hint__item {
  background: rgba(255,255,255,0.06);
}

[data-theme="dark"] .editor-color-picker {
  border-color: rgba(255,255,255,0.08);
  background: #0D1117;
}

[data-theme="dark"] .editor-color-preview {
  border-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .field-item {
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .field-item__label {
  border-color: rgba(255,255,255,0.06);
  background: #0D1117;
  color: var(--ink);
}

[data-theme="dark"] .field-item__input {
  border-color: rgba(255,255,255,0.06);
  background: #0D1117;
  color: var(--ink);
}

[data-theme="dark"] .field-item__type {
  background: rgba(255,255,255,0.06);
}

[data-theme="dark"] .field-item__options {
  border-top-color: rgba(255,255,255,0.04);
}

[data-theme="dark"] .field-option__input {
  border-color: rgba(255,255,255,0.06);
  background: #0D1117;
  color: var(--ink);
}

[data-theme="dark"] .editor-link-row .editor-input {
  background: #0D1117;
  color: var(--ink);
}

[data-theme="dark"] .editor-toggle__switch {
  background: rgba(255,255,255,0.15);
}

[data-theme="dark"] .editor-banner__upload {
  border-color: rgba(255,255,255,0.12);
  background: #0D1117;
}
[data-theme="dark"] .editor-banner__upload:hover {
  background: rgba(88,101,242,0.08);
}
[data-theme="dark"] .editor-banner__preview {
  border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .editor-banner__crop {
  border-color: rgba(255,255,255,0.06);
}
