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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid #333;
    margin-bottom: 30px;
}

header h1 {
    color: #ff6b35;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-info .email {
    color: #888;
}

.hidden {
    display: none !important;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    background: #333;
    color: #fff;
    transition: background 0.2s;
}

.btn:hover {
    background: #444;
}

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

.btn.primary {
    background: #ff6b35;
}

.btn.primary:hover {
    background: #ff8555;
}

.btn.danger {
    background: #c0392b;
}

.btn.small {
    padding: 5px 10px;
    font-size: 12px;
}

section {
    margin-bottom: 40px;
}

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

.section-header .actions {
    display: flex;
    gap: 10px;
}

h2 {
    color: #ff6b35;
    margin-bottom: 20px;
}

/* Auth Section */
.auth-flow {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-step {
    display: flex;
    gap: 15px;
    padding: 20px;
    background: #16213e;
    border-radius: 8px;
}

.step-number {
    width: 32px;
    height: 32px;
    background: #ff6b35;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content p {
    margin-bottom: 10px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.auth-form select,
.auth-form input {
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #333;
    background: #1a1a2e;
    color: #fff;
    font-size: 14px;
}

.auth-screenshot {
    display: block;
    max-width: 100%;
    margin-top: 10px;
    border-radius: 5px;
    border: 1px solid #333;
}

#callback-url {
    width: 100%;
    margin-bottom: 10px;
}

/* Library Filter */
#library-filter {
    padding-left: 10px;
    border-radius: 5px;
    border: 1px solid #333;
    background: #16213e;
    color: #fff;
    font-size: 14px;
    width: 180px;
}

#library-filter:focus {
    outline: none;
    border-color: #ff6b35;
}

/* Book Grid */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.book-card {
    background: #16213e;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.book-card.selected {
    outline: 3px solid #ff6b35;
}

.book-card.downloaded {
    opacity: 0.7;
}

.book-card.downloaded::after {
    content: "Downloaded";
    position: absolute;
    top: 10px;
    right: 10px;
    background: #27ae60;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.book-cover {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #0f3460;
}

.book-info {
    padding: 12px;
}

.book-title {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 14px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    color: #888;
    font-size: 12px;
    margin-bottom: 5px;
}

.book-runtime {
    color: #666;
    font-size: 11px;
}

/* Jobs List */
#jobs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.job-item {
    background: #16213e;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-info {
    flex: 1;
}

.job-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.job-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #333;
}

.job-status.pending_download {
    background: #f39c12;
    color: #000;
}

.job-status.downloading {
    background: #3498db;
}

.job-status.pending_convert {
    background: #9b59b6;
}

.job-status.converting {
    background: #3498db;
}

.job-status.completed {
    background: #27ae60;
}

.job-status.failed {
    background: #c0392b;
}

.job-actions, .download-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.progress-bar {
    width: 200px;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #ff6b35;
    transition: width 0.3s;
}

.progress-detail {
    font-size: 11px;
    color: #888;
    min-width: 100px;
}

/* Downloads List */
#downloads-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.download-item {
    background: #16213e;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.download-info {
    flex: 1;
}

.download-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.download-author {
    color: #888;
    font-size: 12px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #333;
    border-top-color: #ff6b35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 600px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    header {
        flex-direction: column;
        gap: 15px;
    }

    .section-header {
        flex-direction: column;
        gap: 10px;
    }
}
