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

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f7;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
}

h2 {
    margin-bottom: 20px;
    color: #3498db;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

h3 {
    margin: 15px 0;
    color: #2c3e50;
}

/* Layout */
.input-section, .preview-section {
    padding: 20px;
    margin-bottom: 30px;
}

.input-section {
    border-bottom: 1px solid #eee;
}

/* Form Elements */
textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 20px;
    font-family: inherit;
    font-size: 16px;
    resize: vertical;
}

input[type="password"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    margin-bottom: 5px;
}

.ai-options, .styling-options {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.ai-description {
    margin-bottom: 15px;
    font-size: 14px;
    color: #555;
}

.api-key-section {
    margin: 15px 0;
}

.api-note {
    font-size: 12px;
    color: #888;
    margin-bottom: 15px;
}

.ai-status {
    padding: 15px;
    margin-bottom: 20px;
    background-color: #f0f8ff;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.ai-status.hidden {
    display: none;
}

.loading-spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 3px solid #3498db;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.option-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

label {
    width: 120px;
    font-weight: bold;
}

select {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
}

button {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

.secondary-btn {
    background-color: #34495e;
}

.secondary-btn:hover {
    background-color: #2c3e50;
}

/* Preview Tabs */
.preview-tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.tab-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: transparent;
    color: #555;
    font-weight: normal;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    cursor: pointer;
}

.tab-btn.active {
    color: #3498db;
    border-bottom: 3px solid #3498db;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.markup-code {
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    font-family: monospace;
    overflow-x: auto;
    white-space: pre-wrap;
    min-height: 500px;
    font-size: 14px;
    line-height: 1.5;
}

/* Preview Styles */
.preview-container {
    width: 100%;
    min-height: 500px;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 40px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    background-color: white;
}

.pdf-content {
    max-width: 700px;
    margin: 0 auto;
}

#previewTitle {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
}

#previewContent {
    font-size: 16px;
    line-height: 1.8;
    white-space: pre-wrap;
}

/* Template Styles */
.elegant {
    font-family: 'Georgia', serif;
}

.elegant #previewTitle {
    font-size: 28px;
    font-style: italic;
    border-bottom: 1px solid #ddd;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.modern {
    font-family: 'Helvetica Neue', sans-serif;
}

.modern #previewTitle {
    font-size: 32px;
    letter-spacing: -1px;
    margin-bottom: 30px;
    color: #333;
}

.minimal {
    font-family: 'Palatino Linotype', serif;
}

.minimal #previewTitle {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 20px;
    color: #555;
}

.academic {
    font-family: 'Times New Roman', Times, serif;
}

.academic #previewTitle {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 30px;
}

/* Color Themes */
.blue .preview-container {
    background-color: #f7f9fc;
}

.blue #previewTitle {
    color: #2c3e50;
}

.green .preview-container {
    background-color: #f5fbf6;
}

.green #previewTitle {
    color: #27ae60;
}

.purple .preview-container {
    background-color: #f9f5fc;
}

.purple #previewTitle {
    color: #8e44ad;
}

.dark .preview-container {
    background-color: #2c3e50;
    color: #ecf0f1;
}

.dark #previewTitle {
    color: #ecf0f1;
    border-bottom-color: #34495e;
}

/* Enhanced Document Elements */
.pull-quote {
    font-size: 1.4em;
    font-style: italic;
    margin: 20px 40px;
    padding: 15px;
    border-left: 4px solid #3498db;
    color: #555;
}

.illustration-suggestion {
    background-color: #f7f9fc;
    border: 1px dashed #3498db;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
}

.illustration-suggestion h4 {
    color: #3498db;
    margin-bottom: 10px;
}

.caption {
    font-size: 0.9em;
    color: #777;
    text-align: center;
    font-style: italic;
    margin: 5px 0 20px;
}

.section-header {
    font-size: 1.5em;
    font-weight: bold;
    margin: 30px 0 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.sidebar {
    background-color: #f9f9f9;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
    font-size: 0.9em;
}

.sidebar h4 {
    margin-bottom: 10px;
    color: #555;
}

/* PDF-specific styling for proper page breaks */
.pdf-break-hint {
    display: block;
    height: 1px;
    margin: 0;
    padding: 0;
    page-break-after: auto;
}

[data-pdf-pagebreak="before"] {
    page-break-before: always;
}

[data-pdf-pagebreak="after"] {
    page-break-after: always;
}

[data-pdf-keep-together="true"] {
    page-break-inside: avoid;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .preview-container {
        padding: 20px;
    }
}

/* Print media styles for better PDF output */
@media print {
    .section-header {
        page-break-before: always;
    }
    
    .pull-quote, .sidebar, .illustration-suggestion {
        page-break-inside: avoid;
    }
    
    h1, h2, h3, h4 {
        page-break-after: avoid;
    }
    
    .pdf-title {
        page-break-after: avoid;
    }
    
    ul, ol, table {
        page-break-inside: avoid;
    }
}