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

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.navbar { background: #1a1a2e; color: white; padding: 12px 0; }
.navbar .container { display: flex; justify-content: space-between; align-items: center; }
.navbar a { color: #a0aec0; text-decoration: none; margin-left: 20px; cursor: pointer; }
.navbar a:hover { color: white; }
.navbar .brand { font-size: 18px; font-weight: 600; color: white; }
.navbar .credits-badge { background: #f6ad55; color: #1a1a2e; padding: 2px 10px; border-radius: 12px; font-size: 13px; font-weight: 600; }

/* Cards */
.card { background: white; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); padding: 24px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; color: #4a5568; margin-bottom: 4px; }
.form-input { width: 100%; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 6px; font-size: 14px; outline: none; transition: border-color 0.2s; }
.form-input:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.1); }
textarea.form-input { resize: vertical; min-height: 80px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #667eea; color: white; }
.btn-primary:hover:not(:disabled) { background: #5a67d8; }
.btn-success { background: #48bb78; color: white; }
.btn-success:hover:not(:disabled) { background: #38a169; }
.btn-danger { background: #fc8181; color: white; }
.btn-danger:hover:not(:disabled) { background: #f56565; }
.btn-outline { background: transparent; border: 1px solid #e2e8f0; color: #4a5568; }
.btn-outline:hover:not(:disabled) { background: #f7fafc; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* Status badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.badge-draft { background: #edf2f7; color: #718096; }
.badge-generating { background: #fefcbf; color: #975a16; }
.badge-completed { background: #c6f6d5; color: #276749; }
.badge-failed { background: #fed7d7; color: #9b2c2c; }
.badge-pending { background: #e9d8fd; color: #553c9a; }
.badge-waiting { background: #e2e8f0; color: #718096; }

/* Progress bar */
.progress-bar { width: 100%; height: 6px; background: #edf2f7; border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: #667eea; border-radius: 3px; transition: width 0.3s; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab { padding: 10px 20px; cursor: pointer; color: #718096; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab.active { color: #667eea; border-bottom-color: #667eea; }
.tab:hover { color: #4a5568; }

/* Tree (outline editor) */
.tree-node { margin-left: 20px; padding: 4px 0; }
.tree-node-content { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; }
.tree-node-content:hover { background: #f7fafc; }
.tree-node-title { flex: 1; font-size: 14px; }
.tree-node-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.tree-node-content:hover .tree-node-actions { opacity: 1; }
.tree-toggle { cursor: pointer; width: 16px; text-align: center; color: #a0aec0; }

/* Login page */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-card { background: white; padding: 40px; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.15); width: 380px; }
.login-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 8px; color: #1a1a2e; }
.login-subtitle { text-align: center; color: #718096; margin-bottom: 24px; font-size: 14px; }

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

/* Generation log */
.gen-log { background: #1a1a2e; color: #a0f0a0; font-family: monospace; padding: 16px; border-radius: 8px; max-height: 400px; overflow-y: auto; font-size: 13px; line-height: 1.6; white-space: pre-wrap; }

/* File list */
.file-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 8px; }
.file-item .file-name { font-size: 14px; font-weight: 500; }
.file-item .file-meta { font-size: 12px; color: #a0aec0; }

/* Section list */
.section-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 8px; }
.section-item .section-title { flex: 1; font-size: 14px; }
.section-item .section-actions { display: flex; gap: 6px; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: white; border-radius: 12px; padding: 24px; max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

/* Toast */
.toast { position: fixed; top: 20px; right: 20px; padding: 12px 20px; border-radius: 8px; color: white; font-size: 14px; z-index: 2000; animation: slideIn 0.3s ease; }
.toast-success { background: #48bb78; }
.toast-error { background: #f56565; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Utility */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-gray { color: #718096; }
.font-bold { font-weight: 700; }
.hidden { display: none; }
