/**
 * 📚 Book Constructor V3 - Main Styles
 * Главный файл стилей, импортирует все остальные
 * 
 * @version 3.0.0
 */

/* ==================== ИМПОРТЫ ==================== */

@import url('./variables.css');
@import url('./glassmorphism.css');
@import url('./animations.css');

/* ==================== ШРИФТЫ ==================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ==================== БАЗОВЫЕ СТИЛИ ==================== */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== SCROLLBAR ==================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color-strong);
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* ==================== SELECTION ==================== */

::selection {
    background: rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
}

/* ==================== LINKS ==================== */

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-400);
}

/* ==================== IMAGES ==================== */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==================== TYPOGRAPHY ==================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-md); }

p {
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
}

small {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

/* ==================== FORMS ==================== */

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: none;
}

/* Убираем autofill стили */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-input) inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* ==================== ОСНОВНОЙ КОНТЕЙНЕР ==================== */

.book-constructor-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-body);
}

/* ==================== КНОПКИ ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    height: var(--btn-height-md);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: none;
}

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

.btn-sm {
    height: var(--btn-height-sm);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    height: var(--btn-height-lg);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-md);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
    box-shadow: var(--shadow-md), var(--shadow-glow-sm);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--border-color-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.btn-danger {
    background: linear-gradient(135deg, var(--error-500), var(--error-600));
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--error-400), var(--error-500));
}

.btn-success {
    background: linear-gradient(135deg, var(--success-500), var(--success-600));
    color: white;
}

.btn-icon {
    width: var(--btn-height-md);
    padding: 0;
}

.btn-icon.btn-sm {
    width: var(--btn-height-sm);
}

/* ==================== ИНПУТЫ ==================== */

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    height: var(--input-height-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-base);
    transition: all var(--transition-fast);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:hover {
    border-color: var(--border-color-light);
}

.form-input:focus {
    border-color: var(--color-primary);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-input.error {
    border-color: var(--color-error);
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ==================== TEXTAREA ==================== */

.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    min-height: 120px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-base);
    font-family: inherit;
    resize: vertical;
    transition: all var(--transition-fast);
}

.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* ==================== SELECT ==================== */

.form-select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    padding-right: var(--space-10);
    height: var(--input-height-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-base);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='%23888'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: all var(--transition-fast);
}

.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* ==================== LABELS ==================== */

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

/* ==================== CHECKBOX / RADIO ==================== */

.form-checkbox,
.form-radio {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.form-checkbox input,
.form-radio input {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.form-radio input {
    border-radius: var(--radius-full);
}

.form-checkbox input:checked,
.form-radio input:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.form-checkbox input:checked::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    margin: 1px auto;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.form-radio input:checked::after {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    margin: 3px;
    background: white;
    border-radius: var(--radius-full);
}

/* ==================== CARDS ==================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-color);
    background: var(--glass-bg);
}

/* ==================== MODALS ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    width: 90vw;
    max-width: 600px;
    max-height: 90vh;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-normal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    padding: var(--space-6);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-color);
    background: var(--glass-bg);
}

.modal-btn {
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.modal-btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.modal-btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    box-shadow: var(--shadow-sm);
}

.modal-btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
    box-shadow: var(--shadow-glow-sm);
}

.modal-btn-danger {
    background: linear-gradient(135deg, var(--error-500), var(--error-600));
    color: white;
}

/* ==================== DIVIDER ==================== */

.divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-4) 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: var(--border-color);
    margin: 0 var(--space-4);
}

/* ==================== EMPTY STATE ==================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12);
    text-align: center;
}

.empty-state-icon {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    max-width: 300px;
}

/* ==================== LOADING ==================== */

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner.sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.loading-spinner.lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* ==================== SKELETON ==================== */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-3);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16/9;
}

/* ==================== TOOLTIPS ==================== */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-xs);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: var(--z-tooltip);
    pointer-events: none;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* ==================== BADGES ==================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    border-radius: var(--radius-full);
    line-height: 1;
}

.badge-default {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-primary {
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary-400);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success-400);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-400);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error-400);
}

/* ==================== AVATARS ==================== */

.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    overflow: hidden;
}

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

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: var(--text-xs);
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: var(--text-lg);
}

/* ==================== УТИЛИТЫ ==================== */

/* Display */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* Flex */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Spacing */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* Width/Height */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Text */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }
.capitalize { text-transform: capitalize; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Border */
.border { border: 1px solid var(--border-color); }
.border-t { border-top: 1px solid var(--border-color); }
.border-b { border-bottom: 1px solid var(--border-color); }
.border-none { border: none; }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Background */
.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }
.bg-card { background: var(--bg-card); }
.bg-transparent { background: transparent; }

/* Shadow */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-none { box-shadow: none; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }
.pointer-events-none { pointer-events: none; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* Z-index */
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-50 { z-index: 50; }

/* Opacity */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-100 { opacity: 1; }

/* Visibility */
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* ==================== BOOK CONSTRUCTOR SPECIFIC ==================== */

/* Основной контейнер приложения */
.book-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Верхняя панель инструментов */
.book-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-6);
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-bottom: 1px solid var(--border-color);
    gap: var(--space-5);
    flex-shrink: 0;
    min-height: var(--header-height);
}

.toolbar-left {
    flex: 1;
    max-width: 350px;
}

.toolbar-center {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Поле названия книги */
.book-name-field {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-md);
    font-weight: var(--font-medium);
    text-align: center;
    transition: all var(--transition-fast);
}

.book-name-field:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(139, 92, 246, 0.05);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.book-name-field::placeholder {
    color: var(--text-muted);
}

/* Переключатели режимов */
.mode-toggle {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-1);
    gap: var(--space-1);
    border: 1px solid var(--border-color);
}

.mode-btn {
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: var(--glass-bg);
}

.mode-btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.mode-btn i {
    font-size: var(--text-base);
}

/* Основной контент */
.book-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Левая панель (страницы) */
.book-pages-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: var(--space-4);
}

/* Правая панель (экспорт, история) */
.book-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-section {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section-title {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--space-3);
}

/* Слот обложки */
.cover-slot {
    position: relative;
    aspect-ratio: 16/9;
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
}

.cover-slot:hover {
    border-color: var(--color-primary);
    background: rgba(139, 92, 246, 0.05);
}

.cover-slot.has-cover {
    border-style: solid;
    border-color: var(--border-color-light);
}

.cover-slot i {
    font-size: 32px;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.cover-slot span {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

.cover-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Сетка страниц */
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
    padding: var(--space-2);
    overflow-y: auto;
}

/* Ячейка страницы */
.page-cell {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
}

.page-cell:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.page-cell.has-image {
    border-color: var(--success-500);
}

.page-cell.has-text {
    border-color: var(--info-500);
}

.page-cell.special {
    background: var(--bg-tertiary);
    cursor: default;
}

.page-cell.special:hover {
    transform: none;
    box-shadow: none;
}

.cell-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cell-icon {
    font-size: 24px;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.cell-hint {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-align: center;
}

.page-num {
    position: absolute;
    bottom: var(--space-2);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-1) var(--space-2);
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: white;
}

.edit-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition-fast);
}

.page-cell:hover .edit-btn {
    opacity: 1;
}

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

/* Текстовое превью на ячейке */
.text-preview {
    position: absolute;
    bottom: 30px;
    left: var(--space-2);
    right: var(--space-2);
    padding: var(--space-1);
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: white;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Сетка разворотов */
.spreads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
    padding: var(--space-2);
    overflow-y: auto;
}

/* Карточка разворота */
.spread-card {
    position: relative;
    aspect-ratio: 2/1;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
}

.spread-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.spread-card.has-content {
    border-color: var(--success-500);
}

.spread-card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spread-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.spread-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-muted);
}

.spread-empty i {
    font-size: 32px;
}

.spread-card-label {
    position: absolute;
    bottom: var(--space-2);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-1) var(--space-3);
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    color: white;
    white-space: nowrap;
}

/* Кнопки экспорта */
.export-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.export-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--color-primary);
}

.export-btn.primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    border-color: transparent;
    color: white;
}

.export-btn.primary:hover {
    background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
    box-shadow: var(--shadow-glow-sm);
}

/* Быстрые ссылки */
.quick-links {
    display: none;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius-lg);
}

.quick-links.visible {
    display: flex;
}

.quick-link-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--success-400);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-link-btn:hover {
    background: rgba(34, 197, 94, 0.1);
}

/* История экспортов */
.export-history {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2);
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    transition: all var(--transition-fast);
}

.history-item:hover {
    background: var(--bg-card-hover);
}

.history-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-right: var(--space-2);
}

.history-link {
    color: var(--color-primary);
    padding: var(--space-1);
}

.history-link:hover {
    color: var(--primary-400);
}

/* Прогресс заполнения */
.fill-progress {
    padding: var(--space-3);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
}

.fill-progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-2);
}

.fill-progress-value {
    height: 100%;
    background: linear-gradient(90deg, var(--success-500), var(--success-400));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.fill-progress-text {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-align: center;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 1200px) {
    .book-sidebar {
        width: 240px;
    }
}

@media (max-width: 992px) {
    .book-toolbar {
        flex-wrap: wrap;
        gap: var(--space-3);
    }
    
    .toolbar-left {
        order: 1;
        max-width: none;
        flex-basis: 100%;
    }
    
    .toolbar-center {
        order: 2;
    }
    
    .toolbar-right {
        order: 3;
        margin-left: auto;
    }
    
    .book-content {
        flex-direction: column;
    }
    
    .book-sidebar {
        width: 100%;
        max-height: 300px;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}

@media (max-width: 768px) {
    .pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: var(--space-3);
    }
    
    .spreads-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    
    .mode-btn span {
        display: none;
    }
    
    .mode-btn {
        padding: var(--space-2) var(--space-3);
    }
}

@media (max-width: 480px) {
    .book-toolbar {
        padding: var(--space-2) var(--space-3);
    }
    
    .pages-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2);
    }
    
    .modal-content {
        width: 95vw;
        max-height: 95vh;
        border-radius: var(--radius-xl);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-4);
    }
}
/* ============================================
   HISTORY TOGGLE SWITCHER
   ============================================ */

.history-toggle {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 12px;
}

.history-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary, #888);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #fff);
}

.history-toggle-btn.active {
    background: var(--primary-500, #667eea);
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.history-toggle-btn.active[data-history-type="tales"] {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.history-toggle-btn i {
    font-size: 14px;
}

/* Live Tale History Item */
.history-item.live-tale {
    border-left: 3px solid #fbbf24;
}

.history-item.live-tale .history-icon {
    color: #fbbf24;
}

.history-btn.tale-view {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.2));
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fbbf24;
}

.history-btn.tale-view:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #000;
}

.history-btn.tale-qr {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.history-btn.tale-qr:hover {
    background: rgba(255, 255, 255, 0.2);
}
