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

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

h2 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #2980b9;
}

.btn-primary {
    background-color: #e74c3c;
}

.btn-primary:hover {
    background-color: #c0392b;
}

.btn-secondary {
    background-color: #27ae60;
}

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

.upload-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.drop-zone {
    border: 2px dashed #bdc3c7;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    margin-top: 15px;
    transition: border-color 0.3s;
}

.drop-zone.dragover {
    border-color: #3498db;
    background-color: #ecf0f1;
}

.frames-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.frames-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 100px;
    border: 1px solid #ecf0f1;
    border-radius: 5px;
    padding: 10px;
}

.frame {
    position: relative;
    width: 80px;
    height: 80px;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.frame:hover {
    transform: scale(1.05);
}

.frame.selected {
    border-color: #3498db;
}

.frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.frame-number {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
}

.frame-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #e74c3c;
    color: white;
    border: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

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

#flipbookCanvas {
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    background: white;
    margin-bottom: 15px;
}

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

.slider {
    width: 100px;
}

.export-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.export-section .btn {
    margin: 0 10px;
}

/* Mode Toggle Styles */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.mode-btn {
    background-color: #95a5a6;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background-color: #7f8c8d;
}

.mode-btn.active {
    background-color: #3498db;
}

.mode-btn.active:hover {
    background-color: #2980b9;
}

.mode-content {
    display: block;
}

/* Text Mode Styles */
.text-upload-section, .text-input-section, .text-pages-section, .text-preview-section, .text-export-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.upload-options {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.upload-info {
    color: #7f8c8d;
    font-size: 14px;
}

.text-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-control {
    padding: 8px 12px;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    font-size: 14px;
}

.form-control.small {
    width: 80px;
    padding: 4px 8px;
}

.image-preview-container {
    border: 1px solid #ecf0f1;
    border-radius: 5px;
    padding: 15px;
    margin: 15px 0;
    background: #f8f9fa;
}

.selected-image {
    max-width: 100%;
    max-height: 200px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 10px;
}

.image-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.image-controls label {
    font-size: 14px;
    font-weight: bold;
}

.page-input {
    width: 100%;
    height: 150px;
    padding: 15px;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
}

.page-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.text-pages-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 100px;
    border: 1px solid #ecf0f1;
    border-radius: 5px;
    padding: 10px;
}

.text-page-thumb {
    width: 100px;
    height: 120px;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
    padding: 8px;
    font-size: 10px;
    line-height: 1.2;
}

.text-page-thumb:hover {
    transform: scale(1.05);
}

.text-page-thumb.selected {
    border-color: #3498db;
}

.text-page-thumb .page-number {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 8px;
    padding: 2px 4px;
    border-radius: 3px;
}

.text-page-thumb .page-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #e74c3c;
    color: white;
    border: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.text-book {
    display: inline-flex;
    background: #8b4513;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    margin-bottom: 20px;
    perspective: 1000px;
}

.book-page {
    width: 300px;
    height: 400px;
    background: white;
    border: 1px solid #ddd;
    padding: 20px;
    margin: 0 2px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
    text-align: left;
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: transform 0.6s ease;
}

.book-page img {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
    margin: 10px 0;
    display: block;
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.left-page {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.right-page {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.book-page.turning {
    transform: rotateY(-180deg);
}

.book-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

#pageIndicator {
    font-weight: bold;
    margin: 0 10px;
}

/* Reading Mode */
.reading-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.reading-mode .text-book {
    margin: 0;
    background: #654321;
    transform: scale(1.2);
}

.reading-mode .book-controls {
    position: absolute;
    bottom: 30px;
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 10px;
}

.reading-mode .btn {
    background-color: rgba(52, 152, 219, 0.8);
}

.reading-mode .btn:hover {
    background-color: rgba(41, 128, 185, 0.9);
}

.close-reading {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 5px;
    }
    
    .frames-container {
        justify-content: center;
    }
    
    .text-controls {
        flex-direction: column;
    }
    
    .text-book {
        transform: scale(0.8);
    }
    
    .book-page {
        width: 250px;
        height: 350px;
        padding: 15px;
        font-size: 12px;
    }
    
    .reading-mode .text-book {
        transform: scale(1);
    }
    
    .text-pages-container {
        justify-content: center;
    }
}

/* Export Styles */
.export-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.embed-code-section {
    border: 1px solid #ecf0f1;
    border-radius: 5px;
    padding: 20px;
    background: #f8f9fa;
    margin-top: 15px;
}

.embed-textarea {
    width: 100%;
    height: 120px;
    padding: 15px;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    resize: vertical;
    margin-bottom: 15px;
    background: white;
}

.embed-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.embed-preview-container {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    background: white;
    min-height: 200px;
    max-height: 400px;
    overflow: auto;
}

.embed-preview h4 {
    margin-bottom: 10px;
    color: #34495e;
}

/* Standalone flipbook styles for iframe */
.standalone-flipbook {
    font-family: Arial, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f5f5;
}

.standalone-flipbook .text-book {
    display: inline-flex;
    background: #8b4513;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    margin-bottom: 15px;
}

.standalone-flipbook .book-page {
    width: 280px;
    height: 350px;
    background: white;
    border: 1px solid #ddd;
    padding: 15px;
    margin: 0 1px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
}

.standalone-flipbook .book-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.standalone-flipbook .btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.standalone-flipbook .btn:hover {
    background-color: #2980b9;
}

.standalone-flipbook .btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}