/* Сброс стилей */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Основные стили */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #fafbfc;
    color: #1f2937;
    line-height: 1.6;
    min-height: 100vh;
}

/* Sidebar Menu */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 2000;
    overflow-y: auto;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 30px 20px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 5px;
}

.sidebar-subtitle {
    font-size: 14px;
    opacity: 0.9;
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-item {
    display: block;
    padding: 15px 20px;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-item:hover {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
    color: #667eea;
}

.nav-item.active {
    background: rgba(102, 126, 234, 0.15);
    border-left-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

.nav-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.menu-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 12px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 2001;
    backdrop-filter: blur(10px);
}

.menu-toggle:hover {
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.menu-toggle svg {
    width: 20px;
    height: 20px;
    color: #6b7280;
    transition: transform 0.3s ease;
}

.menu-toggle.open svg {
    transform: rotate(90deg);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1999;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Кнопка в главное меню */
.home-button {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    backdrop-filter: blur(10px);
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
}

.home-button:hover {
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.home-button svg {
    width: 20px;
    height: 20px;
}

/* Баннер офлайн */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 200px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 12px;
    text-align: center;
    font-weight: 600;
    z-index: 1001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 12px 0;
}

.offline-banner.hidden {
    display: none;
}

/* Контейнер */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Заголовок */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 24px 0;
    border-bottom: 1px solid #e5e7eb;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.document-title {
    font-size: 32px;
    font-weight: 700;
    color: #111827;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-buttons {
    display: flex;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
}

/* Кнопки */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #4b5563;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Индикатор статуса */
.status-indicator {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
    position: relative;
    overflow: hidden;
}

.status-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 2s;
}

.status-indicator.saving {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    animation: pulse 2s infinite;
}

.status-indicator.saving::before {
    left: 100%;
}

.status-indicator.offline {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Панель инструментов */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.toolbar-btn {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.toolbar-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea, #764ba2);
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 8px;
}

.toolbar-btn:hover {
    color: #374151;
    background: #f3f4f6;
    transform: translateY(-1px);
}

.toolbar-btn.active {
    color: white;
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    position: relative;
    z-index: 1;
}

.toolbar-btn.active::before {
    opacity: 0;
}

.toolbar-separator {
    width: 1px;
    height: 28px;
    background: linear-gradient(to bottom, transparent, #e5e7eb, transparent);
    margin: 0 8px;
}

/* Редактор */
.editor-container {
    background: white;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    min-height: 70vh;
    position: relative;
    overflow: hidden;
}

.editor-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
}

.editor {
    padding: 40px;
    min-height: 70vh;
    outline: none;
    font-size: 16px;
    line-height: 1.7;
    color: #1f2937;
    caret-color: #667eea;
}

.editor:focus {
    box-shadow: inset 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* Стили содержимого редактора */
.editor p {
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.editor p:hover {
    background: rgba(102, 126, 234, 0.02);
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px 14px -4px;
}

.editor h1 {
    font-size: 36px;
    font-weight: 700;
    margin: 32px 0 20px 0;
    color: #111827;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.editor h2 {
    font-size: 28px;
    font-weight: 600;
    margin: 28px 0 16px 0;
    color: #374151;
    line-height: 1.3;
}

.editor ul, .editor ol {
    margin: 20px 0;
    padding-left: 32px;
}

.editor li {
    margin-bottom: 8px;
    position: relative;
}

.editor ul li::marker {
    color: #667eea;
}

.editor ol li::marker {
    color: #667eea;
    font-weight: 600;
}

.editor blockquote {
    margin: 24px 0;
    padding: 20px 24px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-left: 4px solid #667eea;
    font-style: italic;
    color: #4b5563;
    border-radius: 0 8px 8px 0;
    position: relative;
}

.editor blockquote::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 16px;
    font-size: 48px;
    color: #667eea;
    opacity: 0.3;
    font-family: serif;
}

.editor a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
    padding: 1px 2px;
    border-radius: 3px;
}

.editor a:hover {
    background: rgba(102, 126, 234, 0.1);
    border-bottom-color: #667eea;
}

.editor strong {
    font-weight: 700;
    color: #111827;
}

.editor em {
    font-style: italic;
    color: #4b5563;
}

.editor u {
    text-decoration: underline;
    text-decoration-color: #667eea;
    text-decoration-thickness: 2px;
}

/* Модальные окна */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.modal-overlay:not(.hidden) .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    color: #6b7280;
    margin-bottom: 16px;
    line-height: 1.6;
}

.modal-actions {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Поле ввода ссылки */
.link-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #fafbfc;
    font-family: inherit;
}

.link-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.link-input:hover {
    border-color: #d1d5db;
    background: white;
}

.error-message {
    color: #ef4444;
    font-size: 14px;
    margin-top: 8px;
    font-weight: 500;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 6px;
    border-left: 3px solid #ef4444;
}

.error-message.hidden {
    display: none;
}

/* Утилиты */
.hidden {
    display: none !important;
}

/* Адаптивность */
@media (max-width: 768px) {
    .offline-banner {
        right: 0;
        border-radius: 0;
    }
    
    .container {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }
    
    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        width: 100%;
    }
    
    .header-buttons {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .document-title {
        font-size: 28px;
    }
    
    .toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 16px;
    }
    
    .toolbar-separator {
        display: none;
    }
    
    .editor {
        padding: 24px;
        font-size: 16px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .back-button {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
    }
    
    .back-button svg {
        width: 18px;
        height: 18px;
    }
    
    .container {
        padding: 5px;
    }
    
    .editor {
        padding: 20px;
        min-height: 60vh;
    }
    
    .toolbar-btn {
        font-size: 12px;
        padding: 8px 10px;
        min-width: 36px;
        height: 36px;
    }
    
    .editor h1 {
        font-size: 28px;
    }
    
    .editor h2 {
        font-size: 22px;
    }
}