/* =====================================================
   HAIX Survey Manager - Styles
   ===================================================== */

:root {
  --haix-blue: #002B53;
  --haix-blue-light: #003d75;
  --haix-blue-dark: #001f3d;
  --bg-white: #ffffff;
  --bg-gray: #F5F5F5;
  --bg-gray-dark: #E8E8E8;
  --bg-gray-darker: #D0D0D0;
  --text-primary: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #888888;
  --border: #E0E0E0;
  --border-hover: #CCCCCC;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gray);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* =====================================================
   Login Page
   ===================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--haix-blue) 0%, var(--haix-blue-light) 100%);
}

.login-container {
  background: var(--bg-white);
  padding: 48px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  height: 48px;
  margin-bottom: 32px;
}

.login-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-gray);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-primary);
  transition: all 0.2s;
}

.login-input:focus {
  outline: none;
  border-color: var(--haix-blue);
  background: var(--bg-white);
  box-shadow: 0 0 0 3px rgba(0, 43, 83, 0.1);
}

.login-input::placeholder {
  color: var(--text-muted);
}

.login-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--haix-blue);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.login-btn:hover {
  background: var(--haix-blue-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: none;
}

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

/* =====================================================
   App Layout
   ===================================================== */

.app {
  display: none;
  min-height: 100vh;
}

.app.visible {
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  height: 36px;
  display: block;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--bg-gray);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--haix-blue);
  color: white;
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.logout-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.logout-btn svg {
  width: 16px;
  height: 16px;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px 40px;
  max-width: 1100px;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 14px;
}

/* =====================================================
   Buttons
   ===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--haix-blue);
  color: white;
}

.btn-primary:hover {
  background: var(--haix-blue-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-gray);
  border-color: var(--border-hover);
}

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* =====================================================
   Cards
   ===================================================== */

.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-body {
  padding: 24px;
}

/* =====================================================
   Survey List
   ===================================================== */

.survey-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.survey-item {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all 0.15s;
  cursor: pointer;
}

.survey-item:hover {
  border-color: var(--haix-blue);
  box-shadow: var(--shadow-sm);
  transform: translateX(4px);
}

.survey-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.survey-status.inactive {
  background: var(--text-muted);
}

.survey-info {
  flex: 1;
  min-width: 0;
}

.survey-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.survey-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 16px;
}

.survey-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.survey-meta svg {
  width: 14px;
  height: 14px;
}

.survey-actions {
  display: flex;
  gap: 8px;
}

/* =====================================================
   Forms
   ===================================================== */

.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--haix-blue);
  box-shadow: 0 0 0 3px rgba(0, 43, 83, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Answers Editor */
.answers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-item {
  display: flex;
  gap: 10px;
  align-items: center;
}

.answer-item .form-input {
  flex: 1;
}

.answer-number {
  width: 28px;
  height: 28px;
  background: var(--haix-blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.btn-remove-answer {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-remove-answer:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-add-answer {
  margin-top: 12px;
}

/* Color Picker */
.color-picker-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.color-preview {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
}

input[type="color"] {
  width: 0;
  height: 0;
  opacity: 0;
  position: absolute;
}

/* Toggle */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-gray-darker);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle.active {
  background: var(--success);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.toggle.active::after {
  transform: translateX(20px);
}

/* =====================================================
   Code Display
   ===================================================== */

.code-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-gray);
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.code-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.code-tab.active {
  background: var(--bg-white);
  color: var(--haix-blue);
  box-shadow: var(--shadow-sm);
}

.code-block {
  position: relative;
}

.code-content {
  background: var(--text-primary);
  color: #e0e0e0;
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 400px;
  white-space: pre-wrap;
}

.btn-copy {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* =====================================================
   Modal
   ===================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 43, 83, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.visible .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-gray);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--bg-gray-dark);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-gray);
}

/* =====================================================
   Stats
   ===================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-gray);
  border-radius: var(--radius-md);
  padding: 20px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--haix-blue);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-bar {
  height: 8px;
  background: var(--bg-gray-dark);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.stat-bar-fill {
  height: 100%;
  background: var(--haix-blue);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* =====================================================
   Badge
   ===================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

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

.badge-muted {
  background: var(--bg-gray);
  color: var(--text-muted);
}

/* =====================================================
   Empty State
   ===================================================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  margin-bottom: 24px;
}

/* =====================================================
   Toast
   ===================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

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

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast svg {
  width: 18px;
  height: 18px;
}

.toast-success svg {
  color: var(--success);
}

.toast-error svg {
  color: var(--danger);
}

/* =====================================================
   Animations
   ===================================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }

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

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

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .login-container {
    margin: 20px;
    padding: 32px 24px;
  }
}
