/* style.css */

/* === БАЗА === */
.pt-safe { padding-top: env(safe-area-inset-top); }
.pb-safe { padding-bottom: env(safe-area-inset-bottom); }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ВАЖНО: Блокируем нативный "пружинистый" эффект iOS, чтобы работал наш PTR */
html {
    transition: font-size 0.3s ease;
}
body {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    overscroll-behavior-y: none; 
    background-color: inherit;
}

/* === АНИМАЦИИ СТРАНИЦ === */
#app {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

section[data-page] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    /* ВАЖНО: Это позволяет нашему PTR работать внутри секции */
    overscroll-behavior-y: contain; 
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    z-index: 1;
    padding-bottom: 80px; 
}

section[data-page].active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    z-index: 10;
}

/* === UI КНОПКИ === */
.btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}
.btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.2);
}

.nav-btn {
    position: relative;
    transition: all 0.2s ease;
}
.nav-btn-active { color: #4F46E5 !important; }

/* === PULL TO REFRESH (Исправлено) === */
#ptr {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 15px;
    z-index: 50; /* Поверх контента */
    pointer-events: none;
    transform: translateY(-100%);
    /* Убираем opacity, управляем через JS */
}

.ptr-icon-box {
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    color: #4F46E5;
    margin-bottom: 5px;
    transition: transform 0.2s;
    z-index: 51;
}
html.dark .ptr-icon-box { background: #1E293B; color: #818CF8; border: 1px solid #334155; }

.ptr-text {
    font-size: 11px;
    font-weight: 700;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
html.dark .ptr-text { text-shadow: none; }

/* === МОДАЛКА И ТОСТЫ === */
.ios-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex; align-items: flex-end;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
}
.ios-modal-overlay.open { opacity: 1; pointer-events: auto; }

.ios-modal {
    background: white;
    width: 100%;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 30px 20px 40px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.ios-modal-overlay.open .ios-modal { transform: translateY(0); }
html.dark .ios-modal { background: #1E293B; color: white; }

.toast {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    color: white;
    padding: 14px 18px;
    border-radius: 14px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
    width: 90%;
    max-width: 350px;
    border: 1px solid rgba(255,255,255,0.1);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: rgba(220, 38, 38, 0.95); border-color: rgba(254, 202, 202, 0.2); }
.toast.success { background: rgba(22, 163, 74, 0.95); border-color: rgba(187, 247, 208, 0.2); }

/* === КОНСОЛЬ ОТЛАДКИ === */
.debug-console {
    background: #000;
    color: #0f0;
    font-family: monospace;
    font-size: 10px;
    padding: 10px;
    border-radius: 8px;
    margin-top: 20px;
    max-height: 200px;
    overflow-y: auto;
    word-break: break-all;
    border: 1px solid #333;
}
.debug-console div { margin-bottom: 4px; border-bottom: 1px solid #111; padding-bottom: 2px; }
.debug-console .error { color: #f55; }
.debug-console .warn { color: #fa0; }

/* === FLATPICKR === */
.flatpickr-calendar {
    font-family: inherit;
    border: none !important;
    border-radius: 20px !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2) !important;
    padding: 10px !important;
    width: 300px !important;
}
html.dark .flatpickr-calendar { background: #1E293B !important; box-shadow: 0 20px 40px rgba(0,0,0,0.5) !important; }
.flatpickr-day.selected { background: #4F46E5 !important; border-color: #4F46E5 !important; border-radius: 10px !important; }
.flatpickr-day.has-tasks { background: #E0E7FF; border: 1px solid #C7D2FE; color: #4338CA; font-weight: 800; }
html.dark .flatpickr-day { color: #E2E8F0; }
html.dark .flatpickr-day:hover { background: #334155; }
html.dark .flatpickr-day.has-tasks { background: #312E81; border-color: #4338CA; color: #C7D2FE; }

/* 2. Точка в календаре (если есть задачи) */
.flatpickr-day.has-task {
    position: relative;
    font-weight: bold;
    color: #4f46e5; /* Indigo-600 */
}
.flatpickr-day.has-task::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background-color: #4f46e5;
    border-radius: 50%;
}
.dark .flatpickr-day.has-task { color: #818cf8; }
.dark .flatpickr-day.has-task::after { background-color: #818cf8; }

/* При выборе даты точку делаем белой, чтобы было видно на синем фоне */
.flatpickr-day.selected.has-task::after {
    background-color: #fff;
}

@keyframes card-pulse-yellow {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.0); border-color: #fbbf24; }
    50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25); border-color: #f59e0b; }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.0); border-color: #fbbf24; }
}

.card-active-pulse {
    animation: card-pulse-yellow 2s infinite ease-in-out;
    border-width: 1px;
}

/* Для темной темы */
.dark .card-active-pulse {
    border-color: #b45309; 
    box-shadow: none; /* В темной теме можно без тени, или сделать тусклее */
}
/* === БАННЕРЫ УВЕДОМЛЕНИЙ (Action Banners) === */
.action-banner-container {
    position: fixed;
    top: 80px; /* Отступ от хедера */
    left: 0;
    width: 100%;
    z-index: 40;
    padding: 0 16px;
    pointer-events: none; /* Чтобы клики проходили сквозь пустое место */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-banner {
    pointer-events: auto; /* Сами баннеры кликабельны */
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
    transform: translateY(-20px);
    opacity: 0;
    animation: banner-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Баннер "Незакрытые задачи" (Красный) */
.action-banner.urgent {
    background: rgba(220, 38, 38, 0.95); /* Red-600 */
    backdrop-filter: blur(8px);
    color: white;
}

/* Баннер "Новая задача" (Синий) */
.action-banner.info {
    background: rgba(79, 70, 229, 0.95); /* Indigo-600 */
    backdrop-filter: blur(8px);
    color: white;
}

@keyframes banner-slide-in {
    to { transform: translateY(0); opacity: 1; }
}

/* Анимация пульсации для новой задачи в списке */
.highlight-task {
    animation: highlight-pulse 2s ease-in-out infinite;
    border-color: #6366f1 !important; /* Indigo-500 */
}
@keyframes highlight-pulse {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}