/* Chaprola Poll - Clean, Modern CSS */

:root {
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --accent-light: #a5b4fc;
  --success: #22c55e;
  --error: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--slate-100);
  color: var(--slate-800);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
header {
  background: var(--slate-900);
  color: white;
  padding: 1rem 0;
  margin-bottom: 2rem;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0;
  padding-bottom: 0;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  color: white;
}

.logo span {
  color: var(--accent-light);
}

nav a {
  color: var(--slate-300);
  text-decoration: none;
  margin-left: 1.5rem;
  font-size: 0.9rem;
  transition: color 0.2s;
}

nav a:hover {
  color: white;
}

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--slate-900);
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--slate-800);
}

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--slate-900);
  margin-bottom: 0.5rem;
}

.card-meta {
  font-size: 0.875rem;
  color: var(--slate-500);
  margin-bottom: 1rem;
}

.card-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.option-tag {
  background: var(--slate-100);
  color: var(--slate-600);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

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

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

.btn-secondary {
  background: var(--slate-200);
  color: var(--slate-700);
}

.btn-secondary:hover {
  background: var(--slate-300);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--slate-700);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--slate-200);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Radio buttons for voting */
.vote-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.vote-option {
  display: flex;
  align-items: center;
  padding: 1rem;
  background: var(--slate-50);
  border: 2px solid var(--slate-200);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.vote-option:hover {
  border-color: var(--accent-light);
  background: white;
}

.vote-option input[type="radio"] {
  width: 20px;
  height: 20px;
  margin-right: 1rem;
  accent-color: var(--accent);
}

.vote-option.selected {
  border-color: var(--accent);
  background: white;
}

/* Results bar chart */
.results-chart {
  margin-top: 1.5rem;
}

.result-row {
  margin-bottom: 1rem;
}

.result-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.result-option {
  font-weight: 500;
  color: var(--slate-800);
}

.result-count {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 600;
  color: var(--slate-600);
}

.result-bar-bg {
  height: 24px;
  background: var(--slate-200);
  border-radius: 4px;
  overflow: hidden;
}

.result-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s ease-out;
  min-width: 2px;
}

.result-bar.winner {
  background: var(--success);
}

/* Cross-tabulation table */
.crosstab-scroll {
  overflow-x: auto;
}

.crosstab {
  width: 100%;
  border-collapse: collapse;
  margin-top: 2rem;
  font-size: 0.9rem;
}

.crosstab th,
.crosstab td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--slate-200);
}

.crosstab th {
  background: var(--slate-100);
  font-weight: 600;
  color: var(--slate-700);
}

.crosstab td {
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.crosstab tr:hover td {
  background: var(--slate-50);
}

/* Option input list (for create page) */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-input-row {
  display: flex;
  gap: 0.5rem;
}

.option-input-row input {
  flex: 1;
}

.btn-remove {
  padding: 0.75rem;
  background: var(--slate-200);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--slate-600);
  transition: all 0.2s;
}

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

.btn-add-option {
  align-self: flex-start;
  padding: 0.5rem 1rem;
  background: var(--slate-100);
  border: 2px dashed var(--slate-300);
  border-radius: 8px;
  cursor: pointer;
  color: var(--slate-600);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-add-option:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Status indicators */
.status {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-open {
  background: #dcfce7;
  color: #166534;
}

.status-closed {
  background: var(--slate-200);
  color: var(--slate-600);
}

/* Messages */
.message {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.message-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.message-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Share box */
.share-box {
  background: var(--slate-100);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1.5rem;
}

.share-box label {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.share-url {
  display: flex;
  gap: 0.5rem;
}

.share-url input {
  flex: 1;
  background: white;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--slate-500);
}

/* Auto-refresh indicator */
.refresh-indicator {
  font-size: 0.8rem;
  color: var(--slate-500);
  text-align: right;
  margin-top: 1rem;
}

/* Total votes */
.total-votes {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 1rem;
  }

  header .container {
    flex-direction: column;
    gap: 1rem;
  }

  nav a {
    margin-left: 0;
    margin-right: 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 1rem;
  }
}

/* No-JS fallback styles */
noscript .results-data {
  display: block;
  background: var(--slate-100);
  padding: 1rem;
  border-radius: 8px;
  font-family: monospace;
  white-space: pre-wrap;
}
