/* Main Styles - Colorful 3D Theme */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-attachment: fixed;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    perspective: 1000px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    transform: translateZ(20px);
    animation: float 6s ease-in-out infinite;
}

header h1 {
    color: #2c3e50;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    background: linear-gradient(45deg, #3498db, #9b59b6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
    letter-spacing: 1px;
}

header .subtitle {
    color: #7f8c8d;
    margin-bottom: 15px;
    font-size: 1.2rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.tool-icon {
    margin: 10px auto;
    display: flex;
    justify-content: center;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
    transform: scale(1.2);
    transition: transform 0.3s ease, filter 0.3s ease;
}

.tool-icon:hover {
    transform: scale(1.3) rotate(5deg);
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.3));
}

/* Button Styles - 3D Effect */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-right: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 10px rgba(0,0,0,0.1), 0 3px 6px rgba(0,0,0,0.1);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255,255,255,0.2), rgba(255,255,255,0));
    z-index: 1;
}

.btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 20px rgba(0,0,0,0.1), 0 6px 6px rgba(0,0,0,0.1);
}

.btn:active {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(0,0,0,0.1), 0 3px 3px rgba(0,0,0,0.1);
}

.primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.primary:hover {
    background: linear-gradient(135deg, #4aa3df, #3498db);
}

.secondary {
    background: linear-gradient(135deg, #7f8c8d, #6c7a7d);
    color: white;
}

.secondary:hover {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

.success {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
}

.success:hover {
    background: linear-gradient(135deg, #40d47e, #2ecc71);
}

.danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.danger:hover {
    background: linear-gradient(135deg, #e95e50, #e74c3c);
}

/* Controls Section */
.controls {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

/* Pages Container */
#pages-container {
    display: flex;
    flex-direction: column;
    gap: 40px;
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* Page Styles */

/* Image Manipulation Styles */
.quill-image-selected {
    border: 3px solid #3498db;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.6), 0 0 30px rgba(52, 152, 219, 0.3);
    transform: scale(1.02);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Draggable Element Styles */
.draggable-text {
    border: 1px dashed transparent;
    padding: 8px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: move;
    border-radius: 5px;
    transform-style: preserve-3d;
}

.draggable-text:hover {
    border-color: #3498db;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.2), 0 3px 8px rgba(0,0,0,0.1);
    transform: translateZ(10px) scale(1.02);
    background: rgba(255, 255, 255, 0.8);
}

.dragging {
    opacity: 0.9;
    z-index: 100;
    border: 2px dashed #3498db !important;
    box-shadow: 0 10px 20px rgba(52, 152, 219, 0.3), 0 6px 10px rgba(0,0,0,0.1);
    transform: scale(1.05) rotate(1deg);
    background: rgba(255, 255, 255, 0.9);
}

.image-controls {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 1px solid rgba(221, 221, 221, 0.7);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1), 0 3px 6px rgba(0,0,0,0.05);
    backdrop-filter: blur(5px);
    transform: translateZ(20px);
}

.image-control-buttons {
    display: flex;
    gap: 5px;
}

.image-control-buttons button,
.text-control-buttons button {
    padding: 5px 10px;
    font-size: 14px;
}

/* Text block controls */
.text-block-controls {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 1px solid rgba(221, 221, 221, 0.7);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1), 0 3px 6px rgba(0,0,0,0.05);
    backdrop-filter: blur(5px);
    transform: translateZ(20px);
}

.text-control-buttons {
    display: flex;
    gap: 5px;
}

/* Resize and rotation handles */
.resize-handles {
    position: absolute;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

.resize-handle {
    position: fixed;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: 2px solid white;
    border-radius: 50%;
    cursor: nwse-resize;
    z-index: 1001;
    pointer-events: auto;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, background 0.2s ease;
}

.resize-handle:hover {
    transform: scale(1.2);
    background: linear-gradient(135deg, #4aa3df, #3498db);
}

.resize-handle.top-left {
    cursor: nwse-resize;
}

.resize-handle.top-right {
    cursor: nesw-resize;
}

.resize-handle.bottom-left {
    cursor: nesw-resize;
}

.resize-handle.bottom-right {
    cursor: nwse-resize;
}

.rotation-handle {
    position: fixed;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    z-index: 1001;
    pointer-events: auto;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, background 0.2s ease;
}

.rotation-handle:hover {
    transform: scale(1.2);
    background: linear-gradient(135deg, #e95e50, #e74c3c);
}

.insert-image-btn {
    margin-top: 5px;
    display: block;
    width: 100%;
}

.page {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), 0 1px 8px rgba(0, 0, 0, 0.07);
    padding: 25px;
    margin-bottom: 40px;
    transform: perspective(1000px) rotateX(2deg);
    transition: transform 0.5s ease, box-shadow 0.5s ease;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.page:hover {
    transform: perspective(1000px) rotateX(0deg) translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15), 0 5px 15px rgba(0, 0, 0, 0.07);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(238, 238, 238, 0.5);
    background: linear-gradient(to right, rgba(255,255,255,0.8), rgba(255,255,255,0.2));
    border-radius: 8px 8px 0 0;
    padding: 15px;
    box-shadow: 0 3px 5px rgba(0,0,0,0.03);
}

.page-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .page-content {
        grid-template-columns: 3fr 1fr;
    }
}

/* Editor Styles */
.editor-container {
    min-height: 300px;
}

.ql-toolbar.ql-snow {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    background: linear-gradient(to bottom, #f8f9fa, #f1f3f5);
    border: 1px solid rgba(200, 200, 200, 0.5);
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.ql-container.ql-snow {
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    min-height: 250px;
    border: 1px solid rgba(200, 200, 200, 0.5);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    background: rgba(255, 255, 255, 0.9);
}

/* Image Upload Styles */
.image-upload {
    padding: 20px;
    background: linear-gradient(135deg, #f9f9f9, #f0f0f0);
    border-radius: 10px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid rgba(255,255,255,0.8);
    transform: translateZ(5px);
}

.image-upload h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.image-input {
    margin-bottom: 15px;
    width: 100%;
}

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.image-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1), 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid white;
}

.image-preview img:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15), 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* Preview Styles */
#preview-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 245, 255, 0.95));
    z-index: 1000;
    overflow-y: auto;
    padding: 30px;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

#preview-content {
    max-width: 800px;
    margin: 0 auto;
    background-color: white;
    padding: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    transform: perspective(1000px) rotateX(1deg);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.preview-page {
    margin-bottom: 50px;
    padding-bottom: 30px;
    border-bottom: 2px dashed rgba(204, 204, 204, 0.5);
    transform: perspective(1000px) rotateX(1deg);
    transition: transform 0.5s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.preview-page:hover {
    transform: perspective(1000px) rotateX(0deg) translateY(-5px);
}

.preview-page:last-child {
    border-bottom: none;
}

/* Utility Classes */
.hidden {
    display: none;
}

footer {
    text-align: center;
    margin-top: 50px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Loading Indicator */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.loading-spinner {
    border: 5px solid rgba(243, 243, 243, 0.3);
    border-top: 5px solid #3498db;
    border-right: 5px solid #9b59b6;
    border-bottom: 5px solid #2ecc71;
    border-left: 5px solid #f1c40f;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1.2s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}