/* =============================================
   Pollar - Minimalist Design System
   ============================================= */

:root {
    /* Colors */
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #1a1a1d;
    --bg-hover: #222225;

    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --accent: #8b5cf6;
    --accent-hover: #a78bfa;
    --accent-subtle: rgba(139, 92, 246, 0.1);

    --border: #27272a;
    --border-light: #3f3f46;

    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.3);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

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

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
}

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-sm {
    max-width: 480px;
}

.container-md {
    max-width: 640px;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 10, 11, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

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

.nav {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav-link {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

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

/* Main Content */
.main {
    padding-top: 96px;
    padding-bottom: var(--space-3xl);
    min-height: 100vh;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: var(--space-3xl) 0;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: var(--space-lg);
}

.hero-title span {
    background: linear-gradient(135deg, var(--accent), #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto var(--space-xl);
}

.hero-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: inherit;
    width: 1em;
    height: 1em;
}

.btn i::before {
    vertical-align: 0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border-color: var(--error);
}

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

.btn-sm {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.8125rem;
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: 1rem;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
}

.card-header {
    margin-bottom: var(--space-lg);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

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

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.form-error {
    color: var(--error);
}

/* Alerts */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: var(--space-lg);
    border: 1px solid;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

/* Poll List */
.poll-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.poll-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.poll-item:hover {
    border-color: var(--border-light);
    background: var(--bg-tertiary);
}

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

.poll-title {
    font-weight: 600;
    margin-bottom: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.poll-meta {
    display: flex;
    gap: var(--space-md);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.poll-actions {
    display: flex;
    gap: var(--space-sm);
    margin-left: var(--space-lg);
}

/* Copy Link */
.copy-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    padding-left: var(--space-md);
}

.copy-link input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-family: var(--font-mono);
    min-width: 0;
}

.copy-link input:focus {
    outline: none;
}

/* Poll Options (Voting) */
.poll-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.poll-option {
    display: flex;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.poll-option.selected {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.poll-option input {
    display: none;
}

.poll-option-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    margin-right: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.poll-option.selected .poll-option-radio {
    border-color: var(--accent);
}

.poll-option.selected .poll-option-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
}

.poll-option-text {
    flex: 1;
}

/* Results */
.result-item {
    margin-bottom: var(--space-md);
}

.result-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-xs);
    font-size: 0.875rem;
}

.result-text {
    color: var(--text-primary);
}

.result-count {
    color: var(--text-muted);
}

.result-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.result-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #c084fc);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* Dynamic Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.option-row {
    display: flex;
    gap: var(--space-sm);
}

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

.btn-remove-option {
    width: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-remove-option:hover {
    border-color: var(--error);
    color: var(--error);
}

.btn-add-option {
    margin-top: var(--space-sm);
    width: 100%;
    padding: var(--space-sm);
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Status Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-active {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.badge-inactive {
    background: rgba(113, 113, 122, 0.1);
    color: var(--text-muted);
}

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 64px);
    padding: var(--space-lg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Thank You / Confirmation */
.confirmation {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
}

.confirmation-icon {
    width: 80px;
    height: 80px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-xl);
    font-size: 2rem;
}

.confirmation-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
}

.confirmation-text {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

/* Footer */
.footer {
    padding: var(--space-xl) 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Utilities */
.text-center {
    text-align: center;
}

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

.mt-lg {
    margin-top: var(--space-lg);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.w-full {
    width: 100%;
}

/* =============================================
   RESPONSIVE - Mobile First
   ============================================= */

/* Small phones (320px - 480px) */
@media (max-width: 480px) {
    :root {
        --space-lg: 1rem;
        --space-xl: 1.5rem;
        --space-2xl: 2rem;
        --space-3xl: 2.5rem;
    }

    .container {
        padding: 0 var(--space-md);
    }

    .header-inner {
        height: 56px;
    }

    .logo {
        font-size: 1.25rem;
    }

    .nav {
        gap: var(--space-sm);
    }

    .nav-link {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.8rem;
    }

    .main {
        padding-top: 72px;
        padding-bottom: var(--space-xl);
    }

    .hero {
        padding: var(--space-xl) 0;
    }

    .hero-title {
        font-size: 1.75rem;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 0.9rem;
        padding: 0 var(--space-sm);
    }

    .hero-actions {
        flex-direction: column;
        padding: 0 var(--space-sm);
    }

    .hero-actions .btn {
        width: 100%;
    }

    .btn {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.875rem;
    }

    .btn-lg {
        padding: var(--space-md) var(--space-lg);
    }

    .card {
        padding: var(--space-lg);
        border-radius: var(--radius-md);
    }

    .card-title {
        font-size: 1.125rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .page-title {
        font-size: 1.5rem;
    }

    .poll-item {
        flex-direction: column;
        align-items: stretch;
        padding: var(--space-md);
    }

    .poll-title {
        font-size: 0.9rem;
        white-space: normal;
    }

    .poll-meta {
        flex-wrap: wrap;
        gap: var(--space-sm);
        font-size: 0.75rem;
    }

    .poll-actions {
        margin-left: 0;
        width: 100%;
        flex-wrap: wrap;
    }

    .poll-actions .btn {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 0;
        font-size: 0.75rem;
        padding: var(--space-sm);
    }

    .copy-link {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .copy-link input {
        width: 100%;
        font-size: 0.75rem;
        text-align: center;
    }

    .copy-link .btn {
        width: 100%;
    }

    .option-row {
        flex-wrap: wrap;
    }

    .option-row .form-input {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .option-row .form-input:first-child {
        margin-bottom: var(--space-xs);
    }

    .btn-remove-option {
        width: 100%;
        margin-top: var(--space-xs);
    }

    .poll-option {
        padding: var(--space-sm) var(--space-md);
    }

    .poll-option-text {
        font-size: 0.9rem;
    }

    .confirmation {
        padding: var(--space-xl) var(--space-md);
    }

    .confirmation-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .confirmation-title {
        font-size: 1.25rem;
    }

    .auth-card {
        padding: var(--space-lg);
    }

    .auth-title {
        font-size: 1.25rem;
    }

    .form-input {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }

    .empty-state {
        padding: var(--space-xl);
    }

    .empty-state-icon {
        font-size: 2.5rem;
    }

    .empty-state-title {
        font-size: 1.1rem;
    }
}

/* Tablets and larger phones (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .hero-title {
        font-size: 2.25rem;
    }

    .hero-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .poll-item {
        flex-direction: column;
        align-items: stretch;
    }

    .poll-actions {
        margin-left: 0;
        margin-top: var(--space-md);
        width: 100%;
    }

    .poll-actions .btn {
        flex: 1;
    }

    .page-header {
        flex-direction: row;
        align-items: center;
    }
}

/* Desktop adjustments */
@media (min-width: 769px) {
    .poll-item {
        flex-direction: row;
        align-items: center;
    }

    .poll-actions {
        margin-left: var(--space-lg);
        flex-shrink: 0;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .poll-option {
        min-height: 48px;
    }

    .btn-remove-option {
        min-width: 44px;
        min-height: 44px;
    }

    .form-input {
        min-height: 48px;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(var(--space-md), env(safe-area-inset-left));
        padding-right: max(var(--space-md), env(safe-area-inset-right));
    }

    .main {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .footer {
        padding-bottom: max(var(--space-xl), env(safe-area-inset-bottom));
    }
}

/* Dark mode adjustments for OLED screens */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #000000;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-slow) ease-out;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.tooltip:hover::after {
    opacity: 1;
}