/* ====================================================
   STORIES & STORY EDITOR & BOOK MODAL STYLES
   ==================================================== */

/* 1. MAIN STORIES PAGE */
.stories-page-body {
    background: linear-gradient(135deg, #fff0f5 0%, #e0f2fe 50%, #fef3c7 100%);
    min-height: 100vh;
}

.stories-main-card {
    max-width: 1050px !important;
    margin: 0 auto;
}

.btn-write-story {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%) !important;
    color: #ffffff !important;
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    padding: 13px 28px !important;
    border-radius: var(--radius-full) !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-write-story:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 30px rgba(139, 92, 246, 0.5);
    color: #ffffff !important;
}

/* Loading State */
.stories-loading {
    text-align: center;
    padding: 60px 20px;
}

.loading-cat {
    font-size: 3.5rem;
    animation: bounceCat 1.2s infinite alternate ease-in-out;
}

@keyframes bounceCat {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-15px) scale(1.1); }
}

.stories-loading p {
    font-size: 1.2rem;
    font-weight: 700;
    color: #64748b;
    margin-top: 12px;
}

/* 2. STORIES GRID & CARDS */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.story-card {
    background: #ffffff;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
    border: 3px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.story-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 36px rgba(139, 92, 246, 0.18);
    border-color: #ddd6fe;
}

.story-card-cover {
    position: relative;
    width: 100%;
    height: 190px;
    background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.story-card:hover .story-cover-img {
    transform: scale(1.05);
}

.story-admin-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #ff5e7e 0%, #ff9a76 100%);
    color: white;
    font-size: 0.82rem;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(255, 94, 126, 0.4);
}

.story-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.story-card-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0 0 6px 0;
    line-height: 1.35;
}

.story-card-author {
    font-size: 0.95rem;
    font-weight: 700;
    color: #8b5cf6;
    margin-bottom: 4px;
}

.story-card-date {
    font-size: 0.82rem;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 12px;
}

.story-card-preview {
    font-size: 0.95rem;
    color: #475569;
    line-height: 1.55;
    flex-grow: 1;
    margin: 0 0 16px 0;
}

.btn-read-story {
    background: linear-gradient(135deg, #06d6a0 0%, #118ab2 100%) !important;
    color: #ffffff !important;
    font-size: 0.98rem !important;
    font-weight: 800 !important;
    padding: 10px 18px !important;
    border-radius: var(--radius-full) !important;
    border: none !important;
    cursor: pointer;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 14px rgba(6, 214, 160, 0.3);
    transition: all 0.2s ease;
}

.btn-read-story:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(6, 214, 160, 0.45);
}

/* 3. BOOK MODAL (READER) */
.book-modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.book-modal-overlay[hidden] {
    display: none !important;
}

.book-modal-container {
    position: relative;
    max-width: 950px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: bookPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bookPop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.book-close-btn {
    position: absolute;
    top: -16px;
    right: -16px;
    width: 44px;
    height: 44px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    border: 3px solid white;
    font-size: 1.3rem;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: transform 0.2s;
}

.book-close-btn:hover {
    transform: scale(1.15) rotate(90deg);
}

.book {
    display: flex;
    width: 100%;
    height: 620px;
    min-height: 620px;
    max-height: 620px;
    background: #fdfbf7;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45), 0 0 0 10px #7c2d12, 0 0 0 14px #b45309;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

/* Book Spine shadow in middle */
.book::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 24px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0.02) 50%, rgba(0,0,0,0.12) 100%);
    pointer-events: none;
    z-index: 5;
}

.book-page {
    flex: 1 1 50%;
    width: 50%;
    height: 100%;
    padding: 30px 28px;
    position: relative;
    background: #fefcf9;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.book-page-left {
    border-right: 1px solid #f1ece4;
    background: linear-gradient(90deg, #faf6ee 0%, #fefcf9 100%);
}

.book-page-right {
    background: linear-gradient(90deg, #fefcf9 0%, #faf6ee 100%);
}

.book-page-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.book-left-illustration {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    width: 100%;
    padding: 10px 8px;
    box-sizing: border-box;
    margin: auto 0;
}

.book-left-img-wrapper {
    width: 100%;
    max-width: 320px;
    height: 270px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 0 0 4px #fed7aa;
    margin-bottom: 16px;
    background: #fdf2f8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-left-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.book-left-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.book-left-badge {
    background: #fef3c7;
    color: #92400e;
    font-family: 'Fredoka', cursive, sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 3px 12px;
    border-radius: 20px;
    border: 1px solid #fde68a;
}

.book-left-title {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    color: #831843;
    line-height: 1.25;
}

.book-left-author {
    font-size: 0.95rem;
    font-weight: 700;
    color: #b45309;
}

.book-story-header {
    margin-bottom: 16px;
    border-bottom: 2px dashed #e2e8f0;
    padding-bottom: 12px;
}

.book-title {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: #831843;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.book-author {
    font-size: 1rem;
    font-weight: 700;
    color: #b45309;
}

.book-content {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1.25rem;
    line-height: 1.7;
    color: #27272a;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    padding-right: 8px;
}

.book-content p {
    margin-bottom: 12px;
    text-indent: 1.2em;
}

.book-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 12px auto;
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.book-content blockquote {
    border-left: 4px solid #f59e0b;
    padding-left: 14px;
    margin: 14px 0;
    font-style: italic;
    color: #78350f;
    background: #fffbeb;
    padding: 10px 14px;
    border-radius: 0 10px 10px 0;
}

.book-page-number {
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #a1a1aa;
    margin-top: 10px;
}

.book-page-number.left {
    text-align: left;
}

.book-page-number.right {
    text-align: right;
}

.book-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-top: 18px;
}

.book-nav-btn {
    background: #ffffff;
    color: #7c2d12;
    border: 2px solid #fed7aa;
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 10px 22px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.book-nav-btn:hover:not(:disabled) {
    background: #fef3c7;
    border-color: #f59e0b;
    transform: translateY(-2px);
}

.book-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.book-page-indicator {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.05rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* 4. STORY EDITOR STYLES */
.editor-main-card {
    max-width: 850px !important;
    margin: 0 auto;
}

.editor-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 24px;
}

.editor-field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.editor-label {
    font-weight: 800;
    font-size: 1.05rem;
    color: #1e293b;
}

.editor-input {
    font-size: 1.05rem !important;
    padding: 12px 18px !important;
    border-radius: 16px !important;
    border: 2px solid #cbd5e1 !important;
}

.editor-input:focus {
    border-color: #8b5cf6 !important;
    outline: none;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2) !important;
}

/* Cover upload area */
.cover-upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 18px;
    padding: 24px;
    text-align: center;
    background: #f8fafc;
    transition: all 0.2s;
    position: relative;
}

.cover-upload-area.drag-over {
    border-color: #8b5cf6;
    background: #f5f3ff;
}

.cover-upload-placeholder span {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 6px;
}

.cover-upload-placeholder p {
    font-size: 0.95rem;
    color: #64748b;
    margin: 0;
    font-weight: 600;
}

.cover-preview-wrap {
    position: relative;
    max-width: 320px;
    margin: 0 auto;
}

.cover-preview-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 14px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.cover-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

/* Quill Editor custom styling */
.quill-toolbar-wrap {
    border: 2px solid #cbd5e1;
    border-radius: 18px;
    overflow: hidden;
    background: #ffffff;
}

#storyEditorToolbar {
    border: none !important;
    border-bottom: 2px solid #f1f5f9 !important;
    background: #f8fafc;
    padding: 10px !important;
}

.quill-editor-body {
    min-height: 280px;
    font-size: 1.12rem;
    font-family: inherit;
    border: none !important;
}

.ql-container.ql-snow {
    border: none !important;
}

.ql-editor {
    min-height: 280px;
    font-size: 1.15rem;
    line-height: 1.7;
    padding: 18px 22px !important;
}

.ql-editor p {
    margin-bottom: 12px;
}

/* Custom Page Break divider in Editor */
.story-page-break,
hr.story-page-break {
    border: none !important;
    border-top: 3px dashed #f59e0b !important;
    margin: 28px 0 !important;
    position: relative !important;
    text-align: center !important;
    height: 32px !important;
    overflow: visible !important;
    display: block !important;
    background: transparent !important;
    cursor: default !important;
    user-select: none !important;
}

.story-page-break::after,
hr.story-page-break::after {
    content: '📖 --- ΑΛΛΑΓΗ ΣΕΛΙΔΑΣ (ΝΕΑ ΣΕΛΙΔΑ) --- 📖';
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef3c7;
    color: #92400e;
    font-family: 'Fredoka', cursive, sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 18px;
    border-radius: 20px;
    border: 1.5px solid #fde68a;
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.2);
    white-space: nowrap;
}

.editor-error {
    background: #fef2f2;
    border: 2px solid #fca5a5;
    color: #b91c1c;
    padding: 12px 18px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.98rem;
}

.editor-actions {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

.editor-submit-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%) !important;
    font-size: 1.12rem !important;
    padding: 13px 28px !important;
}

/* Success Card */
.editor-success-card {
    max-width: 600px !important;
    margin: 40px auto;
    text-align: center;
    padding: 40px 30px !important;
}

/* COVER PAGE STYLES */
.book-cover-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    width: 100%;
    padding: 10px 8px;
    box-sizing: border-box;
    margin: auto 0;
}

.book-cover-badge {
    background: #fef3c7;
    color: #92400e;
    font-family: 'Fredoka', cursive, sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 8px;
    border: 1px solid #fde68a;
    display: inline-block;
}

.book-cover-title {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 1.45rem;
    font-weight: 800;
    color: #831843;
    margin: 0 0 6px 0;
    line-height: 1.25;
}

.book-cover-author {
    font-size: 0.95rem;
    font-weight: 700;
    color: #b45309;
    margin-bottom: 12px;
}

.book-cover-img-box {
    width: 100%;
    max-width: 280px;
    height: 220px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 0 0 4px #fed7aa;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fdf2f8;
}

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

.book-cover-hint {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    color: #059669;
    background: #ecfdf5;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid #a7f3d0;
    display: inline-block;
}

/* RESPONSIVE STYLES (MOBILE & TABLET VIEWPORT FIT) */
@media (max-width: 768px) {
    .book-modal-overlay {
        padding: 8px !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        box-sizing: border-box !important;
    }

    .book-modal-container {
        height: calc(100dvh - 16px) !important;
        max-height: calc(100dvh - 16px) !important;
        width: 100% !important;
        max-width: 480px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        position: relative !important;
        box-sizing: border-box !important;
    }

    .book-close-btn {
        top: -4px !important;
        right: -4px !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 1.1rem !important;
        border-width: 2px !important;
        z-index: 50 !important;
    }

    .book {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
        border: 4px solid #7c2d12 !important;
        overflow: hidden !important;
        background: #fefcf9 !important;
    }

    .book::after {
        display: none !important;
    }

    .book-page-left,
    #bookPageLeft {
        display: none !important;
    }

    .book-page-right,
    #bookPageRight {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 14px 14px 6px 14px !important;
        box-sizing: border-box !important;
    }

    .book-page-inner {
        width: 100% !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
    }

    .book-story-header {
        display: block !important;
        margin-bottom: 8px !important;
        padding-bottom: 6px !important;
        border-bottom: 2px dashed #fed7aa !important;
        text-align: center !important;
        flex-shrink: 0 !important;
    }

    .book-story-header .book-title {
        font-family: 'Fredoka', cursive, sans-serif !important;
        font-size: 1.22rem !important;
        font-weight: 800 !important;
        color: #701a75 !important;
        margin: 0 !important;
        line-height: 1.25 !important;
        text-align: center !important;
    }

    .book-story-header .book-author {
        display: none !important;
    }

    .book-content {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        font-size: 1.06rem !important;
        line-height: 1.6 !important;
        padding-right: 4px !important;
        margin-bottom: 4px !important;
    }

    .book-content p {
        margin-bottom: 10px !important;
    }

    .book-content img {
        max-height: 130px !important;
        width: auto !important;
        margin: 6px auto !important;
    }

    .book-page-number {
        margin-top: 2px !important;
        margin-bottom: 2px !important;
        font-size: 0.80rem !important;
        flex-shrink: 0 !important;
    }

    .book-controls {
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        margin-top: 6px !important;
        margin-bottom: 0 !important;
        width: 100% !important;
    }

    .book-page-indicator {
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        flex-shrink: 1 !important;
        min-width: 0 !important;
        text-align: center !important;
    }

    .book-nav-btn {
        padding: 7px 12px !important;
        font-size: 0.85rem !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    .book-cover-title {
        font-size: 1.25rem !important;
    }

    .book-cover-img-box {
        max-width: 180px !important;
        height: 120px !important;
        margin-bottom: 8px !important;
    }
}
