/* ============================================================================
   Polls - Apple-inspired minimal design
   ============================================================================ */

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

:root {
    --bg: #ffffff;
    --bg-secondary: #f5f5f7;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --border: #d2d2d7;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --success: #34c759;
    --error: #ff3b30;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1c1c1e;
        --bg-secondary: #2c2c2e;
        --text: #f5f5f7;
        --text-secondary: #98989d;
        --border: #38383a;
        --shadow: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
    }
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.logo span {
    color: var(--text-secondary);
    font-weight: 400;
}

/* Main */
main {
    flex: 1;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Hero */
.hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Form */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Inputs */
input[type="text"],
input[type="datetime-local"] {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    transition: all 0.2s;
}

input[type="text"]:focus,
input[type="datetime-local"]:focus {
    outline: none;
    background: var(--bg);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

input::placeholder {
    color: var(--text-secondary);
}

#poll-title {
    font-size: 1.125rem;
    font-weight: 500;
}

/* Options */
#options-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    text-align: left;
    font-family: inherit;
}

.btn-text:hover {
    color: var(--accent-hover);
}

/* Advanced options */
.advanced-options {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.advanced-options summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
    list-style: none;
}

.advanced-options summary::-webkit-details-marker {
    display: none;
}

.advanced-options summary::after {
    content: "+";
    float: right;
    font-weight: 300;
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.advanced-options[open] summary::after {
    content: "−";
}

.options-content {
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.option-row:last-child {
    border-bottom: none;
}

.option-row > span {
    font-size: 0.95rem;
}

.option-label-group {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.option-label-group span:first-child {
    font-size: 0.95rem;
}

.option-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Toggle switches */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 51px;
    height: 31px;
    background: var(--border);
    border-radius: 31px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

input[type="checkbox"]::before {
    content: "";
    position: absolute;
    width: 27px;
    height: 27px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input[type="checkbox"]:checked {
    background: var(--success);
}

input[type="checkbox"]:checked::before {
    transform: translateX(20px);
}

/* Date input */
input[type="datetime-local"] {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    width: auto;
    min-width: 180px;
}

/* Primary button */
.btn-primary {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.01);
}

.btn-primary:active {
    transform: scale(0.99);
}

/* Hint */
.hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 1.5rem;
}

/* Features section */
.features {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.features h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.features-intro {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.feature {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.feature-icon {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.feature h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.feature p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (min-width: 400px) {
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Poll view */
.poll-container {
    text-align: center;
}

.poll-container h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    line-height: 1.3;
}

/* Poll options */
.poll-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.poll-option {
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.poll-option:hover {
    border-color: var(--border);
}

.poll-option.selected {
    border-color: var(--accent);
    background: rgba(0, 113, 227, 0.08);
}

.poll-option .option-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--accent);
    opacity: 0.15;
    width: 0;
    transition: width 0.5s ease-out;
}

.poll-option .option-content {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.poll-option .option-label {
    font-weight: 500;
}

.poll-option .option-stats {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.poll-option .option-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.poll-option .option-percent {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 600;
}

/* Vote status */
.vote-status {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.vote-status.show {
    display: inline-flex;
}

.vote-status::before {
    content: "✓";
}

/* PoW progress */
.pow-progress {
    margin: 1rem 0;
}

.pow-bar {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.pow-fill {
    height: 100%;
    background: var(--accent);
    width: 0;
    transition: width 0.1s;
}

.pow-progress span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Verification required state */
.poll-options.requires-verification {
    opacity: 0.5;
    pointer-events: none;
}

.poll-options.requires-verification .poll-option {
    cursor: not-allowed;
}

/* Verification panel */
.verification-panel {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.verification-panel p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 500;
}

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-google:hover {
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
}

/* Verified badge */
.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.verified-badge::before {
    content: "✓";
}

/* Share panel */
.share-panel {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

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

.share-row input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
}

.btn-icon {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--border);
}

/* Viral panel */
.viral-panel {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.viral-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--accent);
}

.viral-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.invite-codes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.invite-code {
    padding: 0.625rem 1rem;
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-family: "SF Mono", Monaco, monospace;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--accent);
}

.invite-code:hover {
    background: var(--accent);
    color: white;
}

.invite-code.used {
    opacity: 0.5;
    border-color: var(--border);
    color: var(--text-secondary);
    cursor: default;
}

.invite-code-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.invite-code-row .invite-code {
    flex: 1;
    margin: 0;
    border: none;
    background: transparent;
}

.btn-copy {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.viral-stats {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
}

.stat-row .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-row .stat-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

/* Stats panel (anonymous aggregate stats) */
.stats-panel {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.stats-panel h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.5rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.stat-card .stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Footer */
footer {
    padding: 1rem 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border);
}

footer a {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
}

footer a:hover {
    color: var(--text);
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.toast {
    padding: 0.75rem 1.5rem;
    background: var(--text);
    color: var(--bg);
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: var(--error);
    color: white;
}

/* View switching */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Responsive */
@media (max-width: 500px) {
    main {
        padding: 1.5rem 1rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

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

    input[type="datetime-local"] {
        width: 100%;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* Hidden utility */
[hidden] {
    display: none !important;
}
