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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
}

/* Header - Orange banner */
.main-header {
    background: #FF6B35;
    color: white;
    padding: 30px 40px;
    text-align: center;
}

.main-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.main-header .subtitle {
    font-size: 1rem;
    opacity: 0.95;
    font-weight: 400;
}

/* Main Layout - Sidebar + Content */
.main-layout {
    display: flex;
    min-height: calc(100vh - 120px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    padding: 30px 20px;
    flex-shrink: 0;
}

.sidebar h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.worksheet-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.worksheet-item {
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.95rem;
    color: #555;
}

.worksheet-item:hover {
    background: #e9ecef;
}

.worksheet-item.active {
    background: #FF6B35;
    color: white;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px;
    background: white;
}

/* Chart Section */
.chart-section {
    margin-bottom: 50px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

.chart-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

/* Time Filters */
.time-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.time-filter-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    color: #555;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-weight: 500;
}

.time-filter-btn:hover {
    background: #f8f9fa;
    border-color: #FF6B35;
}

.time-filter-btn.active {
    background: #FF6B35;
    color: white;
    border-color: #FF6B35;
}

.chart-container {
    position: relative;
    height: 450px;
    background: #fafafa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e0e0e0;
}

/* Rankings Section */
.rankings-section {
    margin-top: 50px;
}

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

.rankings-section h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
    color: #333;
}

.update-bsr-btn {
    background: #FF6B35;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.update-bsr-btn:hover {
    background: #e55a2b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.update-bsr-btn:active {
    transform: translateY(0);
}

.update-bsr-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.update-bsr-btn .btn-icon {
    font-size: 1.1rem;
    animation: none;
}

.update-bsr-btn.loading .btn-icon {
    animation: spin 1s linear infinite;
}

.update-status {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.update-status.info {
    background: #e3f2fd;
    color: #1976d2;
    border-left: 4px solid #1976d2;
}

.update-status.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #2e7d32;
}

.update-status.error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #c62828;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.rankings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.ranking-card {
    background: white;
    border-radius: 12px;
    padding: 0;
    position: relative;
    border: 1px solid #e0e0e0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ranking-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: #FF6B35;
}

.rank-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    background: linear-gradient(135deg, #FF6B35 0%, #e55a2b 100%);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.book-cover-container {
    width: 100%;
    height: 280px;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-bottom: 2px solid #f0f0f0;
    padding: 10px;
}

.book-cover {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
    background: transparent;
}

.ranking-card:hover .book-cover {
    transform: scale(1.05);
}

.book-cover-placeholder {
    color: #999;
    font-size: 0.85rem;
    text-align: center;
    padding: 20px;
}

.book-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.book-title {
    font-weight: 600;
    font-size: 1rem;
    color: #333;
    line-height: 1.4;
    min-height: 2.8em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.9rem;
    color: #666;
}

.book-rank {
    font-size: 1rem;
    font-weight: 600;
    color: #FF6B35;
    margin-top: 8px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 1.1rem;
}

.error {
    background: #fee;
    color: #c33;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.reset-zoom-btn {
    padding: 8px 16px;
    background: #FF6B35;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.reset-zoom-btn:hover {
    background: #e55a2b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-instructions {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

@media (max-width: 1024px) {
    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .worksheet-list {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .main-content {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .main-header {
        padding: 20px;
    }

    .main-header h1 {
        font-size: 1.8rem;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .time-filters {
        width: 100%;
    }

    .time-filter-btn {
        flex: 1;
        min-width: 80px;
    }

    .rankings-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 350px;
        padding: 15px;
    }
}
