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

:root {
    /* Color Palette - Vibrant UI */
    --bg-main: #0f172a;      /* Deep dark slate */
    --bg-card: #1e293b;      /* Slightly lighter card background */
    --bg-card-hover: #334155;
    
    --text-main: #f8fafc;    /* Very light grey/white */
    --text-muted: #94a3b8;   /* Muted text color */
    
    --accent-primary: #8b5cf6; /* Vibrant Purple */
    --accent-primary-hover: #7c3aed; /* Darker Purple for hover */
    --accent-secondary: #0ea5e9; /* Cyan */
    
    --gradient-primary: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    
    /* Layout styling */
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    
    --shadow-soft: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.4);
    
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.highlight {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

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

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

/* Layout */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    flex-grow: 1;
    padding: 2rem 0;
}

/* Header */
.app-header {
    background-color: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    text-decoration: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.6));
}

.logo h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--text-main);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 3rem;
    font-size: 0.9rem;
}

/* Page Headers */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.page-header h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition-smooth);
    font-family: 'Outfit', sans-serif;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--accent-secondary);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(14, 165, 233, 0.1);
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.3);
}

/* Book Grid (Index) */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.book-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-smooth);
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeInUp 0.6s ease-out backwards;
}

/* Stagger animation for grid items */
.book-card:nth-child(n) { animation-delay: calc(n * 0.05s); }

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-soft);
    border-color: rgba(139, 92, 246, 0.4);
    background: var(--bg-card-hover);
}

.book-checkbox {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: 24px;
    height: 24px;
    cursor: pointer;
    opacity: 0; /* Hide default checkbox */
}

/* Custom Checkbox Design container */
.checkbox-custom {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 28px;
    height: 28px;
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    z-index: 5;
    pointer-events: none;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.book-checkbox:checked + .checkbox-custom {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.book-checkbox:checked + .checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.book-card:has(.book-checkbox:checked) {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.book-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.book-cover-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    background: linear-gradient(135deg, #1e293b, #334155);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-muted);
}

.book-info {
    padding: 1.25rem;
}

.book-title {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-author {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--accent-secondary);
}

/* Floating Action Bar */
.action-bar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(12px);
    padding: 1rem 2rem;
    border-radius: 50px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    z-index: 100;
    animation: slideUp 0.5s ease-out;
}

.selection-count {
    font-weight: 600;
    color: var(--text-main);
}

.action-bar .btn {
    padding: 0.6rem 1.5rem;
}

/* Poll Voting / Results Shared */
.poll-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.poll-option {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--border-radius-md);
    margin-bottom: 1rem;
    padding: 1rem;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.poll-option:hover {
    border-color: var(--accent-primary);
    background: rgba(15, 23, 42, 0.8);
}

.option-checkbox {
    margin-right: 1.5rem;
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.option-cover {
    width: 60px;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.option-details {
    flex-grow: 1;
    z-index: 2; /* Keep above progress bar in results */
}

.option-title {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

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

/* Results Progress Bars */
.progress-bg {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.2), rgba(14, 165, 233, 0.2));
    z-index: 1;
    border-radius: var(--border-radius-md);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.vote-stats {
    text-align: right;
    z-index: 2;
    min-width: 80px;
}

.vote-percentage {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

.vote-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.share-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.share-url {
    background: #0f172a;
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    font-family: monospace;
    color: var(--accent-secondary);
    margin: 1rem 0;
    border: 1px solid rgba(14, 165, 233, 0.3);
    word-break: break-all;
}

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

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Responsive */
@media (max-width: 768px) {
    .page-header h2 { font-size: 2rem; }
    .book-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .poll-container { padding: 1.5rem; }
    .option-cover { width: 50px; height: 75px; }
    .action-bar { width: 90%; flex-direction: column; gap: 0.5rem; text-align: center;}
}
