/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --secondary-hover: #db2777;
    --option-a-color: #3b82f6;
    --option-a-hover: #2563eb;
    --option-b-color: #f97316;
    --option-b-hover: #ea580c;
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #475569;
    --success-color: #22c55e;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

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

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 30px 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

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

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Section Styling */
section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
}

section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Category Section */
.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-btn {
    padding: 10px 18px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.category-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

/* Question Card */
.question-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
}

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

.category-tag {
    background: var(--primary-color);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.question-number {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.question-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 25px;
    color: var(--text-primary);
}

/* Options Container */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.option-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border: 3px solid transparent;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.option-btn:hover:not(.voted):not(.disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.option-btn.option-a {
    border-color: var(--option-a-color);
}

.option-btn.option-a:hover:not(.voted):not(.disabled) {
    background: rgba(59, 130, 246, 0.1);
}

.option-btn.option-b {
    border-color: var(--option-b-color);
}

.option-btn.option-b:hover:not(.voted):not(.disabled) {
    background: rgba(249, 115, 22, 0.1);
}

.option-label {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
}

.option-a .option-label {
    background: var(--option-a-color);
}

.option-b .option-label {
    background: var(--option-b-color);
}

.option-text {
    font-size: 1.1rem;
    text-align: center;
    z-index: 1;
}

/* Vote Bar */
.vote-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 0;
    transition: width 0.5s ease;
}

.option-a .vote-bar {
    background: var(--option-a-color);
}

.option-b .vote-bar {
    background: var(--option-b-color);
}

.vote-percent {
    position: absolute;
    top: 10px;
    right: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    opacity: 0;
    transition: var(--transition);
}

.option-btn.voted .vote-percent {
    opacity: 1;
}

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

.option-btn.selected::after {
    content: '✓';
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 1.2rem;
    color: var(--success-color);
}

.option-btn.disabled {
    cursor: default;
}

/* VS Divider */
.vs-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
}

.vs-divider span {
    background: var(--secondary-color);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
}

/* Results Section */
.results-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.results-section.hidden {
    display: none;
}

.results-stats {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

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

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary-color);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
}

.action-btn.secondary:hover {
    border-color: var(--primary-color);
    background: var(--bg-card);
}

.action-btn.primary {
    background: var(--secondary-color);
}

.action-btn.primary:hover {
    background: var(--secondary-hover);
}

/* Custom Section */
.custom-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

/* Custom Questions List */
.custom-questions-list {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.custom-questions-list.hidden {
    display: none;
}

.custom-questions-list h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.custom-question-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.custom-question-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    flex: 1;
}

.custom-question-actions {
    display: flex;
    gap: 8px;
}

.custom-question-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.delete-btn {
    background: #ef4444;
    color: white;
}

.delete-btn:hover {
    background: #dc2626;
}

/* Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Footer */
footer {
    text-align: center;
    padding: 25px 0;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

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

/* Mobile Responsive */
@media (max-width: 600px) {
    .app-container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    section {
        padding: 20px 15px;
    }

    section h2 {
        font-size: 1.15rem;
    }

    .category-buttons {
        justify-content: center;
    }

    .category-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

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

    .option-text {
        font-size: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-btn {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card {
        flex-direction: row;
        justify-content: flex-start;
        gap: 15px;
        padding: 15px;
    }

    .stat-icon {
        font-size: 1.5rem;
        margin-bottom: 0;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .results-stats {
        flex-direction: column;
        gap: 15px;
    }
}

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

.question-card {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.option-btn:active:not(.voted):not(.disabled) {
    animation: pulse 0.2s ease;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid #ef4444;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}
