/* Custom styles for ProtDoc */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================
   FIXED HEADER
   ============================================ */

/* Header должен быть закреплен сверху на всех устройствах */
header {
    position: sticky !important;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Отступ для контента под header */
body {
    padding-top: 0;
}

/* На мобильных убираем sticky только если есть bottom nav */
@media (max-width: 767px) {
    body.logged-in header {
        /* Для залогиненных пользователей на мобильных - обычный header */
        position: relative !important;
    }

    /* Для не залогиненных пользователей - sticky header */
    body:not(.logged-in) header {
        position: sticky !important;
        top: 0;
    }
}

/* На десктопе всегда sticky */
@media (min-width: 768px) {
    header {
        position: sticky !important;
        top: 0;
    }
}

/* ============================================ */

/* Document preview styling */
#document-preview {
    line-height: 1.6;
    color: #333;
}

#document-preview p {
    margin-bottom: 1rem;
}

#document-preview h1,
#document-preview h2,
#document-preview h3 {
    font-weight: bold;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

#document-preview h1 {
    font-size: 1.875rem;
}

#document-preview h2 {
    font-size: 1.5rem;
}

#document-preview h3 {
    font-size: 1.25rem;
}

/* Loading animation */
.loading-text::after {
    content: '...';
    animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

/* Smooth transitions */
* {
    transition: opacity 0.2s ease-in-out;
}

.hidden {
    display: none !important;
}

/* Custom scrollbar for document preview */
#document-preview::-webkit-scrollbar {
    width: 8px;
}

#document-preview::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#document-preview::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#document-preview::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Анимация тряски при ошибке */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.animate-shake {
    animation: shake 0.3s ease-in-out;
}

/* Индикатор силы пароля */
.password-strength {
    margin-top: 0.5rem;
}

.strength-bar {
    transition: background-color 0.3s ease;
}

/* ============================================ */
/* АВТОЗАПОЛНЕННЫЕ ПОЛЯ */
/* ============================================ */

/* Визуальная индикация автозаполненного поля */
.autofilled {
    background-color: #f0f9ff !important; /* Очень светлый голубой */
    border-color: #93c5fd !important; /* Светло-синий */
}

/* При фокусе на автозаполненном поле */
.autofilled:focus {
    background-color: #ffffff !important;
    border-color: #3b82f6 !important;
}

/* Анимация при автозаполнении */
@keyframes autofill-pulse {
    0% {
        background-color: #dbeafe;
    }
    50% {
        background-color: #f0f9ff;
    }
    100% {
        background-color: #f0f9ff;
    }
}

.autofilled {
    animation: autofill-pulse 1s ease-in-out;
}

/* ============================================ */
/* ВОССТАНОВЛЕННЫЕ ИЗ КЭША ПОЛЯ */
/* ============================================ */

/* Визуальная индикация восстановленного поля */
.restored-from-cache {
    background-color: #fffbeb !important; /* Очень светлый янтарный */
    border-color: #fcd34d !important; /* Светло-желтый */
}

/* При фокусе на восстановленном поле */
.restored-from-cache:focus {
    background-color: #ffffff !important;
    border-color: #3b82f6 !important;
}

/* Анимация при восстановлении */
@keyframes restore-pulse {
    0% {
        background-color: #fef3c7;
    }
    50% {
        background-color: #fffbeb;
    }
    100% {
        background-color: #fffbeb;
    }
}

.restored-from-cache {
    animation: restore-pulse 1s ease-in-out;
}

/* Индикатор сохранения */
#save-indicator {
    z-index: 9999;
}

/* ============================================ */
/* ИНДИКАТОР ПРОГРЕССА ЗАПОЛНЕНИЯ */
/* ============================================ */

.progress-widget {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    transition: all 0.3s ease;
}

/* ============================================ */
/* КОМПАКТНЫЙ ВИД (по умолчанию) */
/* ============================================ */

.progress-widget-compact {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    position: relative;
    padding: 4px;
    background: linear-gradient(white, white), linear-gradient(135deg, #e5e7eb, #e5e7eb);
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    border: 3px solid transparent;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.progress-widget-compact:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.progress-icon {
    width: 28px;
    height: 28px;
    color: #3b82f6;
    transition: all 0.3s ease;
}

.progress-percentage-compact {
    font-size: 12px;
    font-weight: 700;
    color: #1f2937;
}

/* Анимация пульсации при обновлении */
@keyframes pulse-border {
    0%, 100% {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    50% {
        box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3), 0 2px 4px -1px rgba(59, 130, 246, 0.2);
    }
}

.progress-widget.updating .progress-widget-compact {
    animation: pulse-border 1s ease-in-out;
}

/* ============================================ */
/* РАЗВЕРНУТЫЙ ВИД */
/* ============================================ */

.progress-widget-expanded {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
}

.progress-widget.expanded .progress-widget-compact {
    display: none;
}

.progress-widget.expanded .progress-widget-expanded {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.progress-widget.collapsed .progress-widget-compact {
    display: flex;
}

.progress-widget.collapsed .progress-widget-expanded {
    display: none;
}

/* Заголовок развернутого виджета */
.progress-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.progress-widget-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
}

.progress-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
    padding: 4px;
    border-radius: 6px;
}

.progress-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Содержимое развернутого виджета */
.progress-widget-content {
    padding: 20px;
}

/* Общий прогресс */
.progress-overall {
    margin-bottom: 20px;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.progress-percentage {
    font-size: 24px;
    font-weight: 700;
    color: #3b82f6;
}

.progress-status {
    font-size: 14px;
    color: #6b7280;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 999px;
}

.progress-bar.half {
    background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
}

.progress-bar.complete {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

/* Список шагов */
.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    transition: all 0.2s;
}

.progress-step:hover {
    background: #f3f4f6;
}

.step-indicator {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.step-checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #10b981;
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    animation: checkmark-pop 0.3s ease;
}

@keyframes checkmark-pop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Состояния шага */
.progress-step.completed .step-number {
    display: none;
}

.progress-step.completed .step-checkmark {
    display: flex;
}

.progress-step.in-progress .step-number {
    background: #dbeafe;
    color: #3b82f6;
    border: 2px solid #3b82f6;
}

.step-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.step-title {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-icon {
    font-size: 16px;
}

.step-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-percentage {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
}

.progress-step.completed .step-percentage {
    color: #10b981;
}

.progress-step.in-progress .step-percentage {
    color: #3b82f6;
}

/* ============================================ */
/* АДАПТИВНОСТЬ */
/* ============================================ */

@media (max-width: 768px) {
    .progress-widget {
        top: 16px;
        right: 16px;
    }

    .progress-widget-compact {
        width: 56px;
        height: 56px;
        border-radius: 14px;
    }

    .progress-icon {
        width: 24px;
        height: 24px;
    }

    .progress-percentage-compact {
        font-size: 11px;
    }

    .progress-widget-expanded {
        width: calc(100vw - 32px);
        max-width: 380px;
    }
}

@media (max-width: 640px) {
    .progress-widget {
        top: 12px;
        right: 12px;
    }

    .progress-widget-compact {
        width: 52px;
        height: 52px;
    }

    .progress-widget-expanded {
        width: calc(100vw - 24px);
    }

    .progress-widget-header {
        padding: 16px;
    }

    .progress-widget-title {
        font-size: 16px;
    }

    .progress-widget-content {
        padding: 16px;
    }

    .progress-percentage {
        font-size: 20px;
    }

    .progress-status {
        font-size: 12px;
    }

    .progress-step {
        padding: 10px;
    }

    .step-title {
        font-size: 13px;
    }

    .step-percentage {
        font-size: 12px;
    }
}

/* ============================================ */
/* ВОССТАНОВЛЕННЫЕ ИЗ ЧЕРНОВИКА ПОЛЯ */
/* ============================================ */

.restored-from-draft {
    background-color: #fef3c7 !important; /* Светло-желтый */
    border-color: #fbbf24 !important; /* Желтый */
    animation: restore-pulse 1.5s ease-in-out;
}

@keyframes restore-pulse {
    0%, 100% {
        background-color: #fef3c7;
    }
    50% {
        background-color: #fde68a;
    }
}

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.5rem;
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

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