/* ============================================================
   style.css — WebForm Builder Premium Design
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:           #0f1117;
  --bg2:          #1a1d27;
  --bg3:          #22263a;
  --card:         #1e2235;
  --border:       #2e3350;
  --accent:       #6c63ff;
  --accent2:      #a78bfa;
  --success:      #22c55e;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --text:         #e2e8f0;
  --text2:        #94a3b8;
  --text3:        #64748b;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --transition:   0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, textarea, select, button { font-family: inherit; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Navbar ────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; height: 60px;
  background: rgba(15,17,23,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.1rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.navbar-brand svg { width: 28px; height: 28px; fill: var(--accent); flex-shrink: 0; }
.navbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--bg3); border: 1px solid var(--border);
  font-size: 0.85rem; color: var(--text2);
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: #fff;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  border: none; cursor: pointer;
  transition: all var(--transition);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  box-shadow: 0 2px 12px rgba(108,99,255,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(108,99,255,0.5); }
.btn-secondary {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), transform var(--transition);
}
.card:hover { border-color: rgba(108,99,255,0.4); }

/* ── Container ─────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 760px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Page ──────────────────────────────────────────────── */
.page { min-height: calc(100vh - 60px); padding: 2rem 0; }

/* ── Form Controls ─────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 0.875rem; font-weight: 500; color: var(--text2);
}
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}
.form-control::placeholder { color: var(--text3); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ── Badge ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-accent  { background: rgba(108,99,255,0.15); color: var(--accent2); }
.badge-neutral { background: var(--bg3); color: var(--text2); }

/* ── Toast / Alert ─────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
  box-shadow: var(--shadow); font-size: 0.875rem;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.info    { border-color: var(--accent); }
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ── Loading ───────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,17,23,0.8); backdrop-filter: blur(4px);
  z-index: 9000;
}
.hidden { display: none !important; }

/* ── Dashboard Cards ───────────────────────────────────── */
.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.form-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0; transition: opacity var(--transition);
}
.form-card:hover { border-color: rgba(108,99,255,0.5); transform: translateY(-2px); box-shadow: var(--shadow); }
.form-card:hover::before { opacity: 1; }
.form-card-title { font-weight: 600; font-size: 1rem; margin-bottom: 6px; }
.form-card-desc  { font-size: 0.82rem; color: var(--text2); margin-bottom: 12px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-card-meta  { display: flex; align-items: center; justify-content: space-between; }
.form-card-actions { display: flex; gap: 6px; margin-top: 12px; }

/* ── Builder ───────────────────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 1.25rem;
  align-items: start;
  padding: 1.5rem 0;
}
@media (max-width: 1024px) {
  .builder-layout { grid-template-columns: 1fr; }
}
.builder-sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky; top: 76px;
}
.builder-sidebar h3 {
  font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text3);
  margin-bottom: 0.75rem;
}
.qtype-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: transparent; border: none;
  color: var(--text2); font-size: 0.875rem;
  cursor: pointer; text-align: left;
  transition: all var(--transition);
}
.qtype-btn:hover { background: var(--bg3); color: var(--text); }
.qtype-btn .qtype-icon {
  width: 28px; height: 28px; border-radius: 6px;
  background: rgba(108,99,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; flex-shrink: 0;
}

/* ── Question Card ─────────────────────────────────────── */
.question-list { display: flex; flex-direction: column; gap: 1rem; }
.question-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all var(--transition);
  position: relative;
}
.question-card.active { border-color: var(--accent); }
.question-card-header {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 1rem;
}
.drag-handle {
  cursor: grab; color: var(--text3); padding: 4px;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }
.question-card-actions {
  display: flex; gap: 6px; margin-left: auto;
}
.question-title-input {
  width: 100%; background: transparent;
  border: none; border-bottom: 2px solid var(--border);
  color: var(--text); font-size: 0.95rem; font-weight: 500;
  padding: 4px 0; outline: none;
  transition: border-color var(--transition);
}
.question-title-input:focus { border-bottom-color: var(--accent); }
.question-type-tag {
  font-size: 0.72rem; padding: 2px 8px;
  background: rgba(108,99,255,0.15);
  color: var(--accent2); border-radius: 999px;
  white-space: nowrap;
}

/* Option list (choice, checkbox, dropdown) */
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option-item {
  display: flex; align-items: center; gap: 8px;
}
.option-item input[type="text"] {
  flex: 1; background: transparent;
  border: none; border-bottom: 1px solid var(--border);
  color: var(--text); padding: 4px 0; outline: none;
  font-size: 0.875rem;
}
.option-item input[type="text"]:focus { border-bottom-color: var(--accent); }
.remove-option-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text3); padding: 2px;
  transition: color var(--transition);
}
.remove-option-btn:hover { color: var(--danger); }
.add-option-btn {
  background: none; border: none; cursor: pointer;
  color: var(--accent2); font-size: 0.85rem;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0; margin-top: 4px;
  transition: opacity var(--transition);
}
.add-option-btn:hover { opacity: 0.7; }

/* Required toggle */
.required-toggle {
  display: flex; align-items: center; gap: 8px;
  margin-top: 1rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem; color: var(--text2);
}
.toggle-switch {
  position: relative; width: 36px; height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 999px;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; left: 3px; top: 3px;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Scale input */
.scale-preview {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 8px;
}
.scale-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; transition: all var(--transition);
}
.scale-btn:hover, .scale-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Star rating */
.star-rating {
  display: flex; gap: 4px; font-size: 1.5rem;
}
.star { cursor: pointer; color: var(--text3); transition: color var(--transition); }
.star.active, .star:hover ~ .star { color: var(--text3); }
.star-rating:hover .star { color: var(--warning); }
.star-rating .star:hover ~ .star { color: var(--text3); }

/* File Upload zone */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2rem; text-align: center; cursor: pointer;
  transition: all var(--transition);
  background: var(--bg2);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent); background: rgba(108,99,255,0.05);
}
.upload-zone-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-zone-text { font-size: 0.875rem; color: var(--text2); }

/* Section card */
.section-card {
  border-left: 4px solid var(--accent);
  background: rgba(108,99,255,0.05);
}

/* ── Form Fill Page ─────────────────────────────────────── */
.fill-header {
  background: linear-gradient(135deg, rgba(108,99,255,0.2), rgba(167,139,250,0.1));
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
}
.fill-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; }
.fill-header p { color: var(--text2); }
.fill-question {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.fill-question-title {
  font-weight: 600; margin-bottom: 0.75rem;
}
.fill-question-title .required-mark { color: var(--danger); margin-left: 4px; }

/* Radio/Checkbox options in fill */
.fill-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition);
  margin-bottom: 6px;
}
.fill-option:hover { background: var(--bg3); }
.fill-option input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(108,99,255,0.15) 0%, var(--bg) 70%);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2rem;
}
.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.login-sub { color: var(--text2); font-size: 0.9rem; margin-bottom: 2rem; }
.ms-signin-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 12px 20px;
  background: #2f2f2f; border: 1px solid #3d3d3d;
  border-radius: var(--radius-sm); color: #fff;
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition);
}
.ms-signin-btn:hover { background: #3a3a3a; border-color: var(--accent); }
.ms-logo { width: 20px; height: 20px; }

/* ── Empty State ───────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 4rem 2rem; color: var(--text2);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: 0.875rem; margin-bottom: 1.5rem; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem; width: 100%; max-width: 480px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.25s ease;
}
@keyframes fadeUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 1.5rem; }

/* ── Share Link ─────────────────────────────────────────── */
.share-link-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.share-link-box input {
  flex: 1; background: none; border: none; color: var(--text);
  font-size: 0.85rem; outline: none;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar { padding: 0 1rem; }
  .builder-layout { grid-template-columns: 1fr; }
  .forms-grid { grid-template-columns: 1fr; }
  .container, .container-sm { padding: 0 1rem; }
}
