/* ========================================
   eBook Agent — Premium Dark Mode Styles
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(139, 92, 246, 0.5);
    --text-primary: #f0f0f5;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-glow: rgba(139, 92, 246, 0.15);
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.1);
    --warning: #fbbf24;
    --gradient-1: linear-gradient(135deg, #8b5cf6 0%, #6366f1 50%, #3b82f6 100%);
    --gradient-2: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(99, 102, 241, 0.05) 100%);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Effects */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(139, 92, 246, 0.04) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ========= LAYOUT ========= */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px;
    min-height: 100vh;
}

/* ========= HEADER ========= */
.header {
    text-align: center;
    margin-bottom: 48px;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--accent-glow);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 20px;
}

.header-badge .dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.header h1 {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1.1;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ========= INPUT CARD ========= */
.input-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    margin-bottom: 32px;
    backdrop-filter: blur(20px);
    transition: border-color 0.3s ease;
}

.input-card:hover {
    border-color: rgba(139, 92, 246, 0.15);
}

.form-group {
    margin-bottom: 24px;
}

.form-group:last-of-type {
    margin-bottom: 28px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.form-label .icon {
    font-size: 16px;
}

.form-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    transition: all 0.3s ease;
    outline: none;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Select / Dropdown */
.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

/* Side-by-side row */
.form-row {
    display: flex;
    gap: 16px;
}

.form-group-half {
    flex: 1;
    min-width: 0;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    padding-left: 2px;
}

/* ========= GENERATE BUTTON ========= */
.generate-btn {
    width: 100%;
    padding: 16px 24px;
    background: var(--gradient-1);
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.3);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.generate-btn .btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.generate-btn .spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.generate-btn.loading .spinner {
    display: block;
}

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

/* ========= PROGRESS PANEL ========= */
.progress-panel {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    margin-bottom: 32px;
    backdrop-filter: blur(20px);
}

.progress-panel.active {
    display: block;
    animation: slideIn 0.4s ease;
}

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

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

.progress-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-counter {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
    background: var(--accent-glow);
    padding: 4px 12px;
    border-radius: 100px;
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 100px;
    margin-bottom: 24px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 100px;
    width: 0%;
    transition: width 0.5s ease;
}

/* Step Items */
.step-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.step-list::-webkit-scrollbar {
    width: 4px;
}

.step-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 100px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border-radius: 10px;
    transition: background 0.3s ease;
}

.step-item.active {
    background: var(--accent-glow);
}

.step-item.done {
    opacity: 0.7;
}

.step-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.step-icon.pending {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.step-icon.active {
    background: var(--accent-glow);
    color: var(--accent-light);
    animation: pulse-icon 1.5s ease-in-out infinite;
}

@keyframes pulse-icon {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}

.step-icon.done {
    background: var(--success-bg);
    color: var(--success);
}

.step-icon.error {
    background: var(--error-bg);
    color: var(--error);
}

.step-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.step-item.done .step-text {
    color: var(--text-secondary);
}

/* ========= RESULT CARD ========= */
.result-card {
    display: none;
    background: var(--bg-card);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: 20px;
    padding: 32px;
    text-align: center;
    backdrop-filter: blur(20px);
}

.result-card.active {
    display: block;
    animation: slideIn 0.4s ease;
}

.result-icon {
    width: 64px;
    height: 64px;
    background: var(--success-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 20px;
}

.result-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: linear-gradient(135deg, #34d399 0%, #059669 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(52, 211, 153, 0.3);
}

.new-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    margin-top: 16px;
    transition: all 0.3s ease;
}

.new-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: var(--accent-glow);
}

/* ========= ERROR ========= */
.error-card {
    display: none;
    background: var(--error-bg);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.error-card.active {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

.error-card .error-icon {
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1.4;
}

.error-card .error-message {
    font-size: 14px;
    color: var(--error);
    line-height: 1.5;
}

/* ========= FOOTER ========= */
.footer {
    text-align: center;
    padding: 32px 0 16px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ========= RESPONSIVE ========= */
@media (max-width: 600px) {
    .app-container {
        padding: 24px 16px;
    }
    .header h1 {
        font-size: 30px;
    }
    .input-card, .progress-panel, .result-card {
        padding: 24px 20px;
    }
}
