/* ============================================================
   Bradley University UTM Link Builder — Styles
   Brand red: #CE1432 | Card gray: #D2D3D4
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --red: #CE1432;
  --red-dark: #a81028;
  --red-light: #f8e8eb;
  --gray-light: #D2D3D4;
  --gray-mid: #9a9b9c;
  --gray-dark: #4a4a4a;
  --white: #ffffff;
  --text: #1a1a1a;
  --success: #2E7D32;
  --success-bg: #e8f5e9;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --error: #C62828;
  --error-bg: #ffebee;
  --border-radius: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: #f0f0f1;
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

/* ---- Header ---- */

header {
  background: var(--red);
  color: var(--white);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: 64px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.header-logo {
  height: 36px;
  width: auto;
}

.header-divider {
  width: 1px;
  height: 32px;
  background: rgba(255,255,255,0.35);
}

.header-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---- Layout ---- */

main {
  max-width: 860px;
  margin: 2rem auto;
  padding: 0 1rem 3rem;
}

/* ---- Card ---- */

.card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 2rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--gray-light);
}

/* ---- Form ---- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-dark);
}

label .required {
  color: var(--red);
  margin-left: 2px;
}

label .optional {
  font-weight: 400;
  color: var(--gray-mid);
  font-size: 0.8rem;
  margin-left: 4px;
}

input[type="url"],
input[type="text"],
select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--gray-light);
  border-radius: var(--border-radius);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9b9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

input[type="url"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(206, 20, 50, 0.12);
}

input[type="url"].invalid,
input[type="text"].invalid,
select.invalid {
  border-color: var(--error);
}

.field-description {
  font-size: 0.8rem;
  color: var(--gray-mid);
  min-height: 1.1em;
  line-height: 1.3;
}

/* ---- Submit ---- */

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-primary {
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: var(--border-radius);
  padding: 0.65rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  background: var(--red-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: var(--gray-mid);
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: var(--gray-dark);
  border: 1.5px solid var(--gray-light);
  border-radius: var(--border-radius);
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-secondary:hover {
  border-color: var(--gray-mid);
  color: var(--text);
}

/* Spinner inside button */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

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

/* ---- Result Panel ---- */

#result-panel {
  display: none;
}

#result-panel.visible {
  display: block;
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.status-badge.success {
  background: var(--success-bg);
  color: var(--success);
}

.status-badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-badge.error {
  background: var(--error-bg);
  color: var(--error);
}

.status-icon {
  font-size: 1rem;
}

/* Summary */
.summary-section {
  margin-bottom: 1.25rem;
}

.summary-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-mid);
  margin-bottom: 0.35rem;
}

.summary-text {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.55;
}

/* Generated URL */
.url-box {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1.5px solid var(--gray-light);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.url-text {
  flex: 1;
  padding: 0.6rem 0.85rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
  color: var(--text);
  background: #fafafa;
  overflow-x: auto;
  white-space: nowrap;
  border: none;
  outline: none;
  cursor: text;
  user-select: all;
}

.btn-copy {
  flex-shrink: 0;
  background: var(--gray-light);
  border: none;
  border-left: 1.5px solid var(--gray-light);
  padding: 0 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-dark);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.btn-copy:hover {
  background: var(--gray-mid);
  color: var(--white);
}

.btn-copy.copied {
  background: var(--success);
  color: var(--white);
  border-left-color: var(--success);
}

/* Preview iframe */
.preview-section {
  margin-top: 1.5rem;
}

.preview-container {
  border: 1.5px solid var(--gray-light);
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--gray-light);
  height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preview-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.preview-blocked {
  text-align: center;
  padding: 2rem;
  color: var(--gray-mid);
}

.preview-blocked p {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.preview-blocked a {
  color: var(--red);
  font-weight: 600;
  text-decoration: none;
}

.preview-blocked a:hover {
  text-decoration: underline;
}

/* ---- Validation error ---- */

.validation-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.2rem;
  display: none;
}

.validation-error.visible {
  display: block;
}

/* ---- Custom value input ---- */

.custom-value-input {
  margin-top: 0.4rem;
}

.hidden {
  display: none !important;
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
  header {
    padding: 0 1rem;
  }

  .header-title {
    font-size: 1rem;
  }

  main {
    margin: 1rem auto;
    padding: 0 0.75rem 2rem;
  }

  .card {
    padding: 1.25rem 1rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-group.full-width {
    grid-column: 1;
  }
}
