/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.setup-info {
    margin-top: 1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.setup-info details {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.setup-info summary {
    cursor: pointer;
    font-weight: 600;
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.setup-info summary:hover {
    background: rgba(255,255,255,0.1);
}

.setup-content {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255,255,255,0.95);
    border-radius: 6px;
    color: #333;
    text-align: left;
}

.setup-content h4 {
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.setup-content ol, .setup-content ul {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

.setup-content li {
    margin-bottom: 0.25rem;
}

.setup-content a {
    color: #667eea;
    text-decoration: none;
}

.setup-content a:hover {
    text-decoration: underline;
}

/* Sections and Cards */
.section {
    margin-bottom: 2rem;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.6s ease-out;
}

.card h2 {
    color: #4a5568;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.card h3 {
    color: #4a5568;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* API Setup Styles */
.api-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.input-group small {
    display: block;
    color: #718096;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.api-status {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: center;
}

.api-status.success {
    background: #f0fff4;
    color: #38a169;
    border: 1px solid #9ae6b4;
}

.api-status.error {
    background: #fed7d7;
    color: #e53e3e;
    border: 1px solid #feb2b2;
}

.api-status.info {
    background: #ebf8ff;
    color: #3182ce;
    border: 1px solid #90cdf4;
}

/* Form Elements */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #4a5568;
}

input, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin-right: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover:not(:disabled) {
    background: #edf2f7;
    border-color: #cbd5e0;
}

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

/* Options Container */
.options-container {
    margin: 1.5rem 0;
}

.option-item {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f7fafc;
}

.option-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.1);
}

.option-item.selected {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.option-title {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.option-style {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 0.75rem;
    font-style: italic;
}

.option-content {
    color: #2d3748;
    line-height: 1.7;
}

/* Novel Progress */
.novel-info {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.novel-info h3 {
    color: #4a5568;
    margin: 0;
}

.progress-info {
    display: flex;
    gap: 1rem;
    color: #718096;
    font-size: 0.9rem;
}

.content-display {
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    line-height: 1.7;
}

.chapter-content {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.chapter-content:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.chapter-content h4 {
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* Summary Card */
.summary-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.summary-card h3 {
    color: white;
    margin-bottom: 1rem;
}

.summary-item {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
}

.summary-item strong {
    display: inline-block;
    width: 80px;
    margin-right: 0.5rem;
}

/* Novels Grid */
.novels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.novel-card {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.novel-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.1);
}

.novel-card h4 {
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.novel-meta {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 0.75rem;
}

.novel-preview {
    color: #2d3748;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-left: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #4a5568;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1001;
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
    word-wrap: break-word;
}

.toast.success {
    background: #38a169;
}

.toast.error {
    background: #e53e3e;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

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

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

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .novel-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .novels-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-item strong {
        width: auto;
        display: block;
        margin-bottom: 0.25rem;
    }
    
    .api-actions {
        flex-direction: column;
    }
    
    .api-actions .btn {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .toast {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .option-item {
        padding: 1rem;
    }
    
    .setup-content {
        padding: 0.75rem;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .card {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .card h2, .card h3 {
        color: #e2e8f0;
    }
    
    input, textarea {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #718096;
    }
    
    .option-item {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #718096;
    }
    
    .novel-card {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #718096;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .header, .api-setup, .loading, .toast {
        display: none;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}