/* Quiform SaaS - Global Styles */

:root {
  --primary-color: #4F46E5;
  --primary-dark: #4338ca;
  --primary-light: #6366f1;
  --success-color: #10B981;
  --warning-color: #F59E0B;
  --danger-color: #EF4444;
  --neutral-dark: #1F2937;
  --neutral-medium: #6B7280;
  --neutral-light: #D1D5DB;
  --neutral-bg: #F3F4F6;
  --white: #FFFFFF;
  
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  
  --transition: all 0.2s ease;
}

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

html {
  font-size: 16px;
}

body {
  font-family: var(--font-base);
  color: var(--neutral-dark);
  background: var(--neutral-bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* Typography */
h1 { font-size: 2.5rem; font-weight: 800; line-height: 1.2; }
h2 { font-size: 2rem; font-weight: 700; line-height: 1.25; }
h3 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
h4 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
h5 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; }
h6 { font-size: 1rem; font-weight: 600; line-height: 1.5; }

p { margin-bottom: 1.5rem; }

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

a:hover { color: var(--primary-dark); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary-color);
  color: var(--white);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

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

.btn-secondary {
  background: var(--white);
  color: var(--neutral-dark);
  border: 1px solid var(--neutral-light);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover { background: var(--neutral-bg); }

.btn-ghost {
  background: transparent;
  color: var(--neutral-medium);
}

.btn-ghost:hover { color: var(--neutral-dark); }

.btn-danger {
  background: var(--danger-color);
  color: var(--white);
}

.btn-danger:hover { background: #DC2626; }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.75rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--neutral-bg);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.card-body { padding: 1.5rem; }

/* Inputs */
.input-group { margin-bottom: 1rem; }

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--neutral-dark);
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-family: var(--font-base);
  border: 1px solid var(--neutral-light);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  background: var(--white);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input:disabled { background: var(--neutral-bg); cursor: not-allowed; }

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: slideIn 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success-color); }
.toast-error { border-left: 4px solid var(--danger-color); }
.toast-info { border-left: 4px solid var(--primary-color); }

.toast-icon {
  width: 2rem;
  height: 2rem;
  margin-right: 1rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.toast-message { font-size: 0.875rem; font-weight: 500; }

.toast.hidden {
  opacity: 0;
  transform: translateX(100%);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* Loading Spinner */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(79, 70, 229, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-success { background: #ECFDF5; color: #059669; }
.status-warning { background: #FFFBEB; color: #D97706; }
.status-neutral { background: #F3F4F6; color: #6B7280; }

/* Sidebar Navigation */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--neutral-light);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--neutral-light);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary-color);
}

.sidebar-logo span { margin-left: 0.5rem; }

.sidebar-menu { flex: 1; padding: 1rem 0; overflow-y: auto; }

.sidebar-menu-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: var(--neutral-medium);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

.sidebar-menu-item:hover,
.sidebar-menu-item.active { background: var(--neutral-bg); color: var(--primary-color); }

.sidebar-menu-item .icon {
  width: 20px;
  height: 20px;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--neutral-light); }

.user-menu { display: flex; align-items: center; }
.user-avatar { width: 2rem; height: 2rem; border-radius: 50%; background: var(--primary-color); color: var(--white); }
.user-info { margin-left: 0.75rem; }
.user-name { font-size: 0.875rem; font-weight: 600; color: var(--neutral-dark); }
.user-email { font-size: 0.75rem; color: var(--neutral-medium); }

/* Main Content */
.main-content {
  margin-left: 260px;
  padding: 2rem;
  min-height: 100vh;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.main-title { font-size: 2rem; font-weight: 800; color: var(--neutral-dark); }

/* Dashboard Styles */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }

.kpi-card {
  padding: 1.5rem;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-bg);
  text-align: center;
}

.kpi-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--primary-color); margin-bottom: 0.25rem; }
.kpi-label { font-size: 0.875rem; color: var(--neutral-medium); }

.activity-list { display: flex; flex-direction: column; gap: 0.75rem; }

.activity-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.activity-icon { font-size: 1.5rem; margin-right: 1rem; }
.activity-info { flex: 1; }
.activity-info h4 { margin-bottom: 0.25rem; font-size: 0.875rem; }
.activity-time { font-size: 0.75rem; color: var(--neutral-medium); }
.activity-status { padding: 0.25rem 0.75rem; background: var(--neutral-bg); border-radius: 100px; font-size: 0.75rem; }

/* Forms List */
.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.form-card {
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

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

.form-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--neutral-dark); }
.form-summary { color: var(--neutral-medium); font-size: 0.875rem; margin-bottom: 1rem; }
.form-meta { display: flex; justify-content: space-between; font-size: 0.875rem; color: var(--neutral-medium); }

/* Form Builder */
.builder-layout { display: flex; gap: 1.5rem; min-height: calc(100vh - 100px); }
.builder-panel { flex: 1; background: var(--white); border-radius: var(--radius-md); overflow: hidden; }
.builder-canvas { padding: 2rem; overflow-y: auto; }
.builder-preview { padding: 2rem; overflow-y: auto; }

.field-library { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 1rem; border-bottom: 1px solid var(--neutral-bg); }

.library-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--neutral-bg);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: grab;
  transition: var(--transition);
}

.library-item:hover { background: var(--neutral-light); }

.field-item {
  background: var(--white);
  border: 1px solid var(--neutral-light);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  padding: 1rem;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.field-label { font-weight: 600; }
.field-controls { display: flex; gap: 0.5rem; }

/* Canvas Free form builder */
.canvas-free-container { display: flex; gap: 1.5rem; min-height: calc(100vh - 140px); }

.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.canvas-nav { display: flex; gap: 0.5rem; }

.canvas-nav-item {
  padding: 0.5rem 1rem;
  background: var(--neutral-bg);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--neutral-medium);
  cursor: pointer;
  transition: var(--transition);
}

.canvas-nav-item.active { background: var(--primary-color); color: var(--white); }

/* Settings Page */
.settings-section { margin-bottom: 2rem; }
.settings-section h3 { margin-bottom: 1rem; font-size: 1.25rem; }

.settings-form { max-width: 600px; }
.settings-field { margin-bottom: 1.5rem; }

/* Submissions Inbox */
.submissions-table-container { overflow-x: auto; }

.submissions-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-md);
  overflow-hidden;
  box-shadow: var(--shadow-sm);
}

.submissions-table th {
  padding: 1rem 1.5rem;
  background: var(--neutral-bg);
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neutral-medium);
}

.submissions-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--neutral-bg);
}

.submissions-table tr:last-child td { border-bottom: none; }

/* Analytics */
.analytics-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }

.filter-controls { display: flex; gap: 1rem; }

.filter-select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--neutral-light);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
}

.chart-container {
  background: var(--white);
  padding: 2rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

.simple-chart { display: flex; flex-direction: column; gap: 0.75rem; }

.chart-bar { display: flex; align-items: center; gap: 1rem; }

.chart-label { width: 80px; font-size: 0.875rem; color: var(--neutral-medium); flex-shrink: 0; }

.chart-bar-outer {
  flex: 1;
  height: 30px;
  background: var(--neutral-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.chart-bar-inner {
  height: 100%;
  background: var(--primary-color);
  border-radius: var(--radius-sm);
  transition: all 0.5s ease;
}

.chart-value { width: 60px; text-align: right; font-weight: 600; color: var(--neutral-dark); }

/* Empty States */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
}

.empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--neutral-dark); }
.empty-description { color: var(--neutral-medium); margin-bottom: 1.5rem; }

/* Action Buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--neutral-bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

.action-btn:hover { background: var(--neutral-light); }
.action-btn.btn-edit { background: #DBEAFE; color: #2563EB; }
.action-btn.btn-edit:hover { background: #BFDBFE; }
.action-btn.btn-delete { background: #FEE2E2; color: #DC2626; }
.action-btn.btn-delete:hover { background: #FECACA; }

/* Form Styles */
.form-preview { max-width: 600px; margin: 0 auto; }

.form-preview h2 { margin-bottom: 1.5rem; color: var(--neutral-dark); }
.form-preview p { color: var(--neutral-medium); margin-bottom: 2rem; }

.form-group { margin-bottom: 1.5rem; }
.form-group input, .form-group select, .form-group textarea { margin-bottom: 0.25rem; }
.form-group small { color: var(--neutral-medium); display: block; margin-top: 0.25rem; }

.form-header { text-align: center; margin-bottom: 2rem; }
.form-header h2 { color: var(--primary-color); }

.form-fields { background: var(--white); padding: 2rem; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }

.submit-button {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 1rem;
  font-size: 1rem;
  font-weight: 700;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar { width: 80px; }
  .sidebar-header, .sidebar-menu, .sidebar-footer { text-align: center; }
  .sidebar-logo span, .user-info { display: none; }
  .sidebar-logo, .sidebar-menu-item, .user-avatar { margin: 0 auto; }
  .sidebar-menu-item { justify-content: center; padding: 0.75rem; }
  .sidebar-menu-item .icon { margin-right: 0; }
}

@media (max-width: 768px) {
  .main-content { margin-left: 0; padding: 1rem; }
  
  .builder-layout { flex-direction: column; }
  .builder-panel { width: 100%; max-height: 50vh; }
  
  .sidebar { width: 100%; height: auto; position: relative; bottom: auto; border-right: none; border-bottom: 1px solid var(--neutral-light); }
  .sidebar-menu { max-height: 200px; }
  .sidebar-menu-item { padding: 1rem; }
  .sidebar-logo { font-size: 1rem; }
  .user-avatar { width: 1.5rem; height: 1.5rem; }
  .user-menu { flex-direction: column; align-items: center; }
  .user-info { margin: 0.25rem 0; text-align: center; }
  .sidebar-menu-item .icon { width: 16px; height: 16px; margin: 0; }
}

/* Utility Classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-md); }
.rounded-xl { border-radius: var(--radius-lg); }
.shadow { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.bg-white { background: var(--white); }
.bg-neutral { background: var(--neutral-bg); }
.text-primary { color: var(--primary-color); }
.text-neutral-dark { color: var(--neutral-dark); }
.text-neutral-medium { color: var(--neutral-medium); }

/* Icons SVG */
.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }