/* public/css/todo-lists-style.css */

/* ФИКС СКРОЛЛА - БЛОКИРОВКА СТРАНИЦЫ */
html, body {
    overflow: hidden;
    position: fixed;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: 'SF Pro', sans-serif;
    background-color: #f7f3ff;
    color: var(--tg-theme-text-color, #333333);
    overscroll-behavior: none !important;
    -webkit-overscroll-behavior: none !important;
    touch-action: pan-y !important;
}

.todo-lists-page-container {
    /* ФИКС СКРОЛЛА - ВКЛЮЧАЕМ СКРОЛЛ КОНТЕЙНЕРА */
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    
    /* СКРЫВАЕМ ПОЛОСУ ПРОКРУТКИ */
    scrollbar-width: none;
    -ms-overflow-style: none;
    
    max-width: 390px;
    margin: 0 auto;
    padding: var(--top-offset) 20px 95px; /* Добавил 95px для footer */
    box-sizing: border-box;
    background-color: inherit;
    padding-bottom: 110px;
    overscroll-behavior: none !important;
    -webkit-overscroll-behavior: none !important;
    touch-action: pan-y !important;
}

/* СКРЫВАЕМ СКРОЛЛБАР В WEBKIT */
.todo-lists-page-container::-webkit-scrollbar {
    display: none;
}

.todo-lists-header {
    text-align: center;
    margin-bottom: 25px;
}

.todo-lists-header h1 {
    font-family: 'Soyuz Grotesk', sans-serif;
    font-size: 32px;
    font-weight: 700;
    color: rgb(86, 76, 126);
    margin: 20px;
}

.todo-lists-main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.accordions-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.accordion-item {
    background-image: linear-gradient(to bottom right, #ffffff, #8c52ff3d);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 18px 20px;
    background-color: transparent;
    border: none;
    border-radius: 16px; /* For focus outline to match */
    font-family: 'TextFont', 'SF Pro', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: rgb(86, 76, 126);
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease;
}

.accordion-header .accordion-title {
    flex-grow: 1;
}

.accordion-icon {
    transition: transform 0.3s ease-in-out;
    color: var(--tg-theme-hint-color, #6c757d);
}

.accordion-header[aria-expanded="true"] .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0; /* Явно устанавливаем начальную высоту 0 */
    transition: max-height 0.35s ease-in-out, padding-top 0.35s ease-in-out, padding-bottom 0.35s ease-in-out, opacity 0.3s ease-in-out;
    overflow: hidden;
    opacity: 0; /* Start hidden for transition */
}

.accordion-content.open {
    opacity: 1;
    /* padding-top/bottom will be added by JS for smooth transition if needed,
       or simply rely on max-height and inner padding */
}

.accordion-content-inner {
    padding: 0px 20px 20px; /* Top padding is on header, bottom for content */
    margin-top: 5px; /* To overlap with bottom of header if header has bottom border */
}

.accordion-list-description {
    font-family: 'BaseFont', 'SF Pro', sans-serif;
    font-size: 14px;
    color: var(--tg-theme-hint-color, #666666);
    margin-top: 15px;
    margin-bottom: 15px;
    line-height: 1.4;
}

.todo-items-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.todo-item {
    display: flex;
    align-items: center;
    transition: opacity 0.3s ease;
}

.todo-item-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
    color: rgba(86, 76, 126, 0.92);
}

.todo-item-checkbox {
    display: none; /* Hide original checkbox */
}

.custom-checkbox-todo {
    width: 20px;
    height: 20px;
    border: 1px solid var(--tg-theme-hint-color, rgb(230, 223, 255));
    border-radius: 6px;
    margin-right: 12px;
    display: inline-block;
    position: relative;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

.todo-item-checkbox:checked + .custom-checkbox-todo {
    background-color: #8c52ff; /* Main purple */
    border-color: #8c52ff;
}

.custom-checkbox-todo::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.todo-item-checkbox:checked + .custom-checkbox-todo::after {
    opacity: 1;
}

.todo-item-text {
    line-height: 1.4;
    transition: color 0.3s ease, text-decoration 0.3s ease;
}

.todo-item.completed .todo-item-text {
    text-decoration: line-through;
    color: rgba(86, 76, 126, 0.49);
}

.empty-list-text {
    font-size: 15px;
    color: var(--tg-theme-hint-color, #777);
    text-align: center;
    padding: 10px 0;
}

/* --- No Content / Auth Required --- */
.no-content-container, .auth-required-container {
    text-align: center;
    padding: 30px 20px;
    background-color: var(--tg-theme-secondary-bg-color, #FFFFFF);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    margin-top: 20px;
}

.no-content-image, .auth-required-image {
    max-width: 180px;
    margin-bottom: 20px;
}

.no-content-text, .auth-required-text {
    font-size: 16px;
    color: var(--tg-theme-text-color, #555555);
    line-height: 1.5;
    margin-bottom: 0;
}

.auth-required-title {
    font-family: 'TextFont', 'SF Pro', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--tg-theme-text-color, #333333);
    margin-bottom: 10px;
}

/* --- Dark Theme --- */
body.dark-theme .todo-lists-header h1 {
    color: rgb(230, 223, 255);
}

body.dark-theme .accordion-item {
    background-color: rgb(36, 27, 67); /* From profile.php dark */
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

body.dark-theme .accordion-header {
    color: rgb(230, 223, 255);
}

body.dark-theme .accordion-header:hover {
    background-color: rgba(190, 160, 245, 0.1); /* Light purple hover for dark theme */
}

body.dark-theme .accordion-icon {
    color: rgb(230, 223, 255);
}

body.dark-theme .accordion-content-inner {
    border-top-color: rgba(57, 44, 99, 0);
}

body.dark-theme .accordion-list-description {
    color: #B0B0B0;
}

body.dark-theme .todo-item-label {
    color: rgb(230, 223, 255);
}

body.dark-theme .custom-checkbox-todo {
    border-color: rgb(230, 223, 255);
}

body.dark-theme .todo-item-checkbox:checked + .custom-checkbox-todo {
    background-color: #BEA0F5; /* Lighter purple for dark theme */
    border-color: #BEA0F5;
}

body.dark-theme .todo-item.completed .todo-item-text {
    color: rgba(230, 223, 255, 0.577);
}

body.dark-theme .empty-list-text {
    color: #A0A0A0;
}

body.dark-theme .no-content-container,
body.dark-theme .auth-required-container {
    background-color: rgb(36, 27, 67);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

body.dark-theme .no-content-text,
body.dark-theme .auth-required-text {
    color: #C0C0C0;
}

body.dark-theme .auth-required-title {
    color: #E0E0E0;
}

/* Fade in animation (re-used from style.css or other pages) */
.animate-fade-in {
    opacity: 0;
    animation: fadeInAnimation 0.5s ease-out forwards;
}

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

body {
    padding-bottom: 95px !important;
}

/* Масштабирование на длинных экранах */
@media (min-width: 430px) and (max-width: 500px) {
    .todo-lists-page-container {
        transform: scale(1.13) !important;
        transform-origin: top center !important; /* Масштабируем от верха */
        padding-top: calc(var(--top-offset) / 1.13) !important; /* Уменьшаем верхний отступ пропорционально */
        padding-bottom: calc(200px * 1.13) !important; /* Увеличиваем padding пропорционально */
    }
    body {
        padding-bottom: calc((95px * 1.13) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* КРИТИЧЕСКОЕ ИСПРАВЛЕНИЕ: Переопределяем calc() из footer-style.css */
    html body {
        padding-bottom: calc((95px * 1.13) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Дополнительная специфичность */
    body.has-footer {
        padding-bottom: calc((95px * 1.13) + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (min-width: 500px) and (max-width: 600px) {
    .todo-lists-page-container {
        transform: scale(1.2) !important;
        transform-origin: top center !important; /* Масштабируем от верха */
        padding-top: calc(var(--top-offset) / 1.2) !important; /* Уменьшаем верхний отступ пропорционально */
        padding-bottom: calc(200px * 1.2) !important; /* Увеличиваем padding пропорционально */
    }
    body {
        padding-bottom: calc((95px * 1.2) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* КРИТИЧЕСКОЕ ИСПРАВЛЕНИЕ: Переопределяем calc() из footer-style.css */
    html body {
        padding-bottom: calc((95px * 1.2) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Дополнительная специфичность */
    body.has-footer {
        padding-bottom: calc((95px * 1.2) + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (min-width: 600px) {
    .todo-lists-page-container {
        transform: scale(1.3) !important;
        transform-origin: top center !important; /* Масштабируем от верха */
        padding-top: calc(var(--top-offset) / 1.3) !important; /* Уменьшаем верхний отступ пропорционально */
        padding-bottom: calc(200px * 1.3) !important; /* Увеличиваем padding пропорционально */
    }
    body {
        padding-bottom: calc((95px * 1.3) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* КРИТИЧЕСКОЕ ИСПРАВЛЕНИЕ: Переопределяем calc() из footer-style.css */
    html body {
        padding-bottom: calc((95px * 1.3) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Дополнительная специфичность */
    body.has-footer {
        padding-bottom: calc((95px * 1.3) + env(safe-area-inset-bottom, 0px)) !important;
    }
}
