/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */

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

body {
  font-family: 'Amazon Ember', Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

header {
  background: #232f3e;
  color: #fff;
  padding: 0 24px;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
}

.identity-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  font-weight: 600;
}

.identity-link:hover {
  opacity: 0.9;
}

header nav a {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  opacity: 0.7;
  padding: 16px 16px;
  border-bottom: 3px solid transparent;
  transition:
    opacity 0.2s,
    border-color 0.2s;
}

header nav a:hover {
  opacity: 1;
}

header nav a.active {
  opacity: 1;
  border-bottom-color: #ff9900;
  font-weight: 600;
}

.nav-separator {
  color: rgba(255, 255, 255, 0.4);
  margin: 0 4px;
  user-select: none;
}

.dark-mode-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 8px;
}

.dark-mode-toggle input {
  display: none;
}

.toggle-label {
  font-size: 18px;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.dark-mode-toggle:hover .toggle-label {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   Main
   --------------------------------------------------------------------------- */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */

footer {
  text-align: center;
  padding: 24px;
  color: #888;
  font-size: 13px;
  margin-top: auto;
}

/* ---------------------------------------------------------------------------
   List header + filter
   --------------------------------------------------------------------------- */

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.list-header h2 {
  font-size: 20px;
}

.filter-bar {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.filter-bar select {
  padding: 6px 10px;
  border: 1px solid #d5d9d9;
  border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   Table
   --------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

thead th {
  background: #f0f0f0;
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  color: #555;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 14px;
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:hover {
  background: #fafafa;
}

.target-summary {
  color: #666;
}

.actions {
  white-space: nowrap;
}
.actions .btn {
  margin-right: 4px;
}

/* ---------------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-active {
  background: #e6f4ea;
  color: #1e7e34;
}
.badge-draft {
  background: #fff8e1;
  color: #f57f17;
}
.badge-inactive {
  background: #f5f5f5;
  color: #666;
}
.badge-expired {
  background: #fde7e7;
  color: #c62828;
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  font-size: 14px;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  background: #ff9900;
  color: #fff;
}
.btn-secondary {
  background: #e0e0e0;
  color: #333;
}
.btn-danger {
  background: #d32f2f;
  color: #fff;
}
.btn-cancel {
  background: transparent;
  color: #666;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

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

.form-container {
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.form-container h2 {
  margin-bottom: 20px;
}

fieldset {
  border: none;
  border-radius: 2rem 2rem 2rem 2rem;
  background-color: #fafafa;
  margin-top: 0;
  margin-bottom: 20px;
  padding-left: 2rem;
  padding-right: 2rem;
  padding-top: 1.2rem;
  padding-bottom: 1.6rem;
}

legend {
  font-weight: 600;
  font-size: 20px;
  padding-top: 50px;
  color: #232f3e;
}

label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  margin-top: 12px;
}

label:first-of-type {
  margin-top: 8px;
}

input[type='text'],
input[type='number'],
input[type='datetime-local'],
textarea,
select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d5d9d9;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

input:disabled {
  background: #f0f0f0;
  color: #999;
  cursor: not-allowed;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  margin-top: 12px;
  cursor: pointer;
}

.checkbox-label input[type='checkbox'] {
  width: auto;
}

.required {
  color: #d32f2f;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* ---------------------------------------------------------------------------
   Question blocks
   --------------------------------------------------------------------------- */

.question-block {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 12px;
  background: #fafafa;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------------------
   Stats bar
   --------------------------------------------------------------------------- */

.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  text-align: center;
  flex: 1;
  min-width: 0;
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: #232f3e;
}
.stat-label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-top: 4px;
}

/* ---------------------------------------------------------------------------
   Response breakdown
   --------------------------------------------------------------------------- */

.question-summary {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.question-summary h3 {
  font-size: 15px;
  margin-bottom: 4px;
}
.question-type {
  color: #888;
  font-size: 12px;
}

.avg-rating {
  margin: 12px 0 8px;
}

.rating-distribution,
.choice-distribution {
  margin-top: 8px;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.rating-row span:first-child {
  width: 100px;
  text-align: right;
}
.rating-row span:last-child {
  width: 60px;
}

.bar-bg {
  flex: 1;
  height: 16px;
  background: #f0f0f0;
  border-radius: 8px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: #ff9900;
  border-radius: 8px;
  transition: width 0.3s;
}

.open-text-responses {
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.open-text-count {
  font-weight: 600;
  margin-bottom: 8px;
}

.open-text-item {
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 8px;
  font-size: 14px;
  background: #fafafa;
}

/* ---------------------------------------------------------------------------
   States
   --------------------------------------------------------------------------- */

.loading {
  color: #888;
  padding: 40px 0;
  text-align: center;
}
.empty-state {
  color: #888;
  padding: 24px 0;
  text-align: center;
}
.error {
  color: #d32f2f;
  padding: 24px 0;
  text-align: center;
}

/* ---------------------------------------------------------------------------
   Toast
   --------------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  z-index: 10000;
  animation: slideIn 0.3s ease-out;
}

.toast-success {
  background: #1e7e34;
}
.toast-error {
  background: #d32f2f;
}

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

/* Multi-select dropdown */
.multi-select {
  position: relative;
  margin-bottom: 12px;
}

.multi-select-toggle {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d5d9d9;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  background: #fff;
  user-select: none;
}

.multi-select-toggle:hover {
  border-color: #ff9900;
}

.multi-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #d5d9d9;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}

.multi-select-option:hover {
  background: #f0f2f2;
}

.multi-select-option input[type='checkbox'] {
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Landing Page
   --------------------------------------------------------------------------- */

.landing {
  text-align: center;
  padding: 60px 20px;
}

.landing h2 {
  font-size: 28px;
  margin-bottom: 12px;
  color: #232f3e;
}

.landing-desc {
  font-size: 16px;
  color: #666;
  margin-bottom: 40px;
}

.landing-cards {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.landing-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 32px 24px;
  width: 300px;
  text-decoration: none;
  color: #333;
  transition:
    box-shadow 0.2s,
    border-color 0.2s;
}

.landing-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-color: #ff9900;
}

.landing-card h3 {
  font-size: 20px;
  color: #232f3e;
  margin-bottom: 8px;
}

.landing-card p {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

/* ---------------------------------------------------------------------------
   Dark Mode
   --------------------------------------------------------------------------- */

body.dark-mode {
  background: #1a1a2e;
  color: #e0e0e0;
}

body.dark-mode header {
  background: #16213e;
}

body.dark-mode main {
  color: #e0e0e0;
}

body.dark-mode .form-container,
body.dark-mode table,
body.dark-mode .landing-card {
  background: #1f2937;
  border-color: #374151;
  color: #e0e0e0;
}

body.dark-mode .landing-card:hover {
  border-color: #ff9900;
}

body.dark-mode .landing-card h3 {
  color: #fff;
}

body.dark-mode .landing-card p,
body.dark-mode .landing-desc {
  color: #9ca3af;
}

body.dark-mode .landing h2 {
  color: #fff;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
  background: #374151;
  border-color: #4b5563;
  color: #e0e0e0;
}

body.dark-mode fieldset {
  border-color: #374151;
}

body.dark-mode legend {
  color: #e0e0e0;
}

body.dark-mode th {
  background: #1f2937;
  color: #e0e0e0;
}

body.dark-mode td {
  border-color: #374151;
  color: #e0e0e0;
}

body.dark-mode .filter-bar select {
  background: #374151;
  color: #e0e0e0;
}

body.dark-mode footer {
  background: #16213e;
  color: #9ca3af;
}
