:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #059669;
    --success-light: #ecfdf5;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --side-a: #3b82f6;
    --side-a-light: #dbeafe;
    --side-b: #ef4444;
    --side-b-light: #fee2e2;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* Header */
header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gray-900);
    text-decoration: none;
}

.logo svg { color: var(--primary); }

nav { display: flex; align-items: center; gap: 20px; }
nav a { color: var(--gray-600); text-decoration: none; font-weight: 500; font-size: 0.95rem; }
nav a:hover { color: var(--primary); }

/* Footer */
footer {
    margin-top: auto;
    padding: 24px 0;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.875rem;
    border-top: 1px solid var(--gray-200);
    background: white;
}

/* Hero */
.hero {
    text-align: center;
    padding: 48px 0 32px;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.hero p {
    font-size: 1.15rem;
    color: var(--gray-500);
    max-width: 500px;
    margin: 0 auto;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

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

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-active { background: var(--success-light); color: var(--success); }
.status-closed { background: var(--gray-100); color: var(--gray-500); }

/* Flash messages */
.flash-messages { margin-bottom: 20px; }

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.flash-success { background: var(--success-light); color: var(--success); border: 1px solid #a7f3d0; }
.flash-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }

/* Topics Grid */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    padding-bottom: 48px;
}

.topic-card {
    display: block;
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    transition: all 0.2s ease;
}

.topic-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.topic-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.vote-count {
    font-size: 0.8rem;
    color: var(--gray-400);
    font-weight: 500;
}

.topic-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
    line-height: 1.3;
}

.topic-description {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Vote bar */
.vote-bar { margin-bottom: 12px; }

.vote-bar-fill {
    display: flex;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--gray-100);
}

.bar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    min-width: 0;
    overflow: hidden;
}

.bar-segment span { white-space: nowrap; }
.bar-a { background: var(--side-a); }
.bar-b { background: var(--side-b); }

.vote-bar-empty {
    text-align: center;
    padding: 10px;
    color: var(--gray-400);
    font-size: 0.85rem;
    background: var(--gray-50);
    border-radius: 6px;
    border: 1px dashed var(--gray-300);
}

.topic-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--gray-400);
}

.empty-state svg { margin-bottom: 16px; opacity: 0.5; }
.empty-state h2 { font-size: 1.3rem; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

/* Topic Detail */
.topic-detail { padding: 32px 0 64px; max-width: 800px; margin: 0 auto; }

.back-link {
    display: inline-block;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 20px;
    font-weight: 500;
}

.back-link:hover { color: var(--primary); }

.topic-header { margin-bottom: 32px; }
.topic-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    margin: 12px 0;
    letter-spacing: -0.02em;
}

.topic-full-description {
    color: var(--gray-600);
    font-size: 1.05rem;
    line-height: 1.7;
}

/* Vote Section */
.vote-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 32px;
}

.vote-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.vote-form { margin-top: 16px; }

.vote-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.vote-btn {
    padding: 24px 20px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    font-weight: 700;
}

.vote-btn-a:hover { border-color: var(--side-a); background: var(--side-a-light); color: var(--side-a); }
.vote-btn-b:hover { border-color: var(--side-b); background: var(--side-b-light); color: var(--side-b); }

.already-voted {
    text-align: center;
    padding: 20px;
    color: var(--success);
}

.already-voted svg { margin-bottom: 8px; }
.already-voted p { font-size: 1.05rem; }
.already-voted strong { color: var(--gray-900); }

/* Results */
.results-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 32px;
}

.results-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
}

.results-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.result-side {
    text-align: center;
    padding: 20px;
    border-radius: var(--radius);
    background: var(--gray-50);
}

.result-a { border: 2px solid var(--side-a-light); }
.result-b { border: 2px solid var(--side-b-light); }

.result-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.result-count {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--gray-900);
}

.result-pct {
    font-size: 1rem;
    color: var(--gray-500);
    font-weight: 500;
}

.results-bar {
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--gray-100);
    margin-bottom: 12px;
}

.results-bar-fill {
    display: flex;
    height: 100%;
}

.results-bar-fill .bar-a { background: var(--side-a); }
.results-bar-fill .bar-b { background: var(--side-b); }

.total-votes {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Debate / Comments */
.debate-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.debate-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.comment-count {
    font-weight: 400;
    color: var(--gray-400);
}

.comment-form {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gray-200);
}

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

.input, .select, .textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.textarea { resize: vertical; min-height: 100px; }

/* Comments list */
.comments-list { display: flex; flex-direction: column; gap: 16px; }

.comment {
    padding: 16px;
    border-radius: var(--radius);
    border-left: 3px solid var(--gray-300);
    background: var(--gray-50);
}

.comment-side-A { border-left-color: var(--side-a); background: var(--side-a-light); }
.comment-side-B { border-left-color: var(--side-b); background: var(--side-b-light); }

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.comment-author {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.9rem;
}

.comment-side-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.comment-side-badge.side-A { background: var(--side-a); color: white; }
.comment-side-badge.side-B { background: var(--side-b); color: white; }

.comment-date {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-left: auto;
}

.comment-content {
    color: var(--gray-700);
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.empty-comments {
    text-align: center;
    padding: 32px;
    color: var(--gray-400);
    font-style: italic;
}

/* Admin */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 32px 0 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.admin-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
}

.admin-actions { display: flex; gap: 12px; align-items: center; }

.inline-form { display: inline; }

.admin-topics { display: flex; flex-direction: column; gap: 12px; padding-bottom: 48px; }

.admin-topic-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 16px;
}

.admin-topic-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.admin-topic-title-row h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.admin-topic-meta {
    font-size: 0.85rem;
    color: var(--gray-500);
}

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

/* Admin form */
.admin-form-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 32px 0 64px;
}

.admin-form-container h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 24px;
}

.admin-form .form-group { margin-bottom: 20px; }

.admin-form label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

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

/* Auth */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px 20px;
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 24px;
    text-align: center;
}

.auth-form .form-group { margin-bottom: 16px; }

.auth-form label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 640px) {
    .hero h1 { font-size: 1.75rem; }
    .topics-grid { grid-template-columns: 1fr; }
    .vote-options { grid-template-columns: 1fr; }
    .results-display { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .admin-topic-card { flex-direction: column; align-items: flex-start; }
    .admin-topic-actions { width: 100%; }
    .admin-header { flex-direction: column; align-items: flex-start; }
}
