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

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --success-hover: #059669;
    --secondary: #64748b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Header */
.header {
    padding: 30px 0 20px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-bottom: 20px;
}

.title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Settings Toolbar */
.settings-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    align-items: center;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.toolbar-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toolbar-select,
.toolbar-slider,
.toolbar-color {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    transition: border-color 0.3s;
}

.toolbar-select {
    min-width: 140px;
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--primary);
}

.toolbar-slider {
    width: 120px;
    height: 8px;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 5px;
    outline: none;
}

.toolbar-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.toolbar-color {
    width: 60px;
    height: 40px;
    padding: 4px;
    cursor: pointer;
}

.toolbar-actions {
    margin-left: auto;
}

/* Buttons */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

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

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Main Content */
.main-content {
    margin-bottom: 40px;
}

/* Paper Container */
.paper-container {
    max-width: 850px;
    margin: 0 auto;
}

.paper-sheet {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    min-height: 600px;
    padding: 20px;
    background-image: 
        linear-gradient(#e5e5e5 1px, transparent 1px);
    background-size: 100% 30px;
    background-position: 0 20px;
}

.paper-textarea {
    width: 100%;
    min-height: 550px;
    padding: 40px 60px;
    border: none;
    outline: none;
    font-size: 18px;
    line-height: 30px;
    font-family: inherit;
    background: transparent;
    resize: vertical;
    color: var(--text-primary);
}

.paper-textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.char-counter {
    position: absolute;
    bottom: 15px;
    right: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Output Section */
.output-section {
    max-width: 1000px;
    margin: 30px auto;
    animation: fadeIn 0.5s;
}

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

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

.output-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.output-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.page-count {
    background: var(--primary);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.page-item {
    background: white;
    border-radius: var(--radius);
    padding: 15px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

.page-number {
    font-weight: 700;
    color: var(--primary);
}

.page-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--text-primary);
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    max-width: 350px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: #ef4444;
}

/* Responsive */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    
    .settings-toolbar {
        flex-direction: column;
    }
    
    .toolbar-section {
        width: 100%;
    }
    
    .toolbar-select,
    .toolbar-slider {
        width: 100%;
    }
    
    .toolbar-actions {
        margin-left: 0;
        width: 100%;
    }
    
    .toolbar-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .paper-textarea {
        padding: 30px 20px;
        font-size: 16px;
    }
    
    .output-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .output-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .output-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .pages-grid {
        grid-template-columns: 1fr;
    }
}
