/* ============================== CSS-переменные ============================== */
:root {
	--body-bg: #f1f3f6;
	--top-card-bg: #d1def0;
	--bottom-card-bg: #c7cfd9;
	--li-bg: #ffffff;
	--li-shadow: rgba(0, 0, 0, 0.05);
	--duplicate-bg: #fffa8d;
	--highlight-color: #ffb84d;
 	--bottom-sheet-bg: var(--bottom-card-bg);
	--bottom-sheet-border: #ddd;
	--text-default: #000;
	--text-meta: #666;
	--border-radius: 6px;
	--card-radius: 8px;
	--sheet-radius: 16px;
	--frequent-button-color: #e8dcb7;
	--gap: 8px;
}

/* ============================== Базовые стили ============================== */
* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	font-family: "Pangolin", cursive;
	font-weight: 400;
	background-color: var(--body-bg);
	color: var(--text-default);
}

html, body {
    height: 100%;
}

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

input::placeholder,
textarea::placeholder {
	color: #888;
}

/* Контейнер приложения */
#app {
	display: flex;
	min-height: 0;
	flex-direction: column;
	height: 100dvh
}

.lists-wrapper {
	flex: 1;
	overflow-y: auto;
	min-height: 0;
	padding: 0 16px 90px;
}

.shopping-title {
	font-size: 0.8rem;
	text-align: right;
	margin: 4px 0 4px;
	color: #9f9f9f;              /* тёмно-серый текст */
}

.date-active {
    width: fit-content;
    margin: 10px auto;
    padding: 6px 14px;           /* внутренние отступы */
    font-size: 0.8rem;
    font-weight: 500;
    color: #333;
    background-color: #f5f5f5;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    text-align: center;
    user-select: none;
}

/* ============================== Добавление покупки / фиксированный блок ============================== */
.add-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1001;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background-color: color-mix(in srgb, var(--bottom-card-bg) 80%, black 20%);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
    display: flex;
}

.add-form {
    display: flex;
    align-items: center;
    gap: var(--gap);
    flex: 1;
}

.add-form input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 12px;
    font-size: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid #bbb;
    background-color: #fff;
}

.add-form input:focus {
    border-color: var(--highlight-color);
    box-shadow: 0 0 6px rgba(255, 184, 77, 0.3);
    outline: none;
}

.add-form .frequent-btn,
.add-form .add-btn {
    flex: 0 0 auto;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.4rem;
    line-height: 1;
    border-radius: 50%;
    border: 1px solid #d4af37;
    background-color: var(--frequent-button-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s;
}

.add-form .frequent-btn:hover {
    background-color: var(--frequent-button-color);
}

.add-form .frequent-btn:active {
    transform: scale(0.95);
}

.add-form .frequent-btn:focus-visible {
    outline: 2px solid var(--highlight-color);
    outline-offset: 2px;
}

.add-container::before {
	content: "";
	position: absolute;
	top: -40px;
	left: 0;
	width: 100%;
	height: 40px;
	background: linear-gradient(to bottom, rgba(241, 243, 246, 0), var(--body-bg));
	pointer-events: none;
}

/* ============================== Блоки списков ============================== */
.list-block {
	margin-bottom: 20px;
	border-radius: var(--card-radius);
	overflow: hidden;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.list-title {
    position: relative;
    text-align: center;      /* 🔑 центрируем текст */
	margin: 0;
	padding: 16px 12px;
	font-size: 1.3rem;
	background-color: var(--top-card-bg);
	text-align: center;
}

.list-content {
	list-style: none;
	padding: 4px 12px 10px;
	margin: 0;
}

#bought-list li {
	text-decoration: line-through;
	opacity: 0.5;
}

/* Цвета блоков */
.to-buy-block .list-title,
.to-buy-block .list-content {
	background-color: var(--top-card-bg);
}

.bought-block .list-title,
.bought-block .list-content {
    background-color: color-mix(in srgb, var(--bottom-card-bg) 85%, black 15%);
}

/* ============================== Элементы списка ============================== */
.list-content li {
	display: flex;
	line-height: 1.6;
	justify-content: space-between;
	align-items: center;
	padding: 8px 10px;
	border-radius: var(--border-radius);
	margin-bottom: 5px;
	background-color: var(--li-bg);
	box-shadow: 0 1px 2px var(--li-shadow);
	word-break: break-word;
	transition: background-color 0.2s ease;
	border: 1px solid #aaa;
}

.list-pressable {
	background-color: var(--li-bg);
	box-shadow: 0 1px 2px var(--li-shadow);
	transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease, inset-shadow 0.1s ease;
}

.list-pressable.is-pressed {
	transform: translateY(2px);
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0.5px 1px var(--li-shadow);
	background-color: #e0e0e0;
}

/* Для select внутри кнопок/шиттонов Bottom Sheet */
.sheet-buttons select {
	padding: 4px 16px;
	border-radius: var(--border-radius);
	border: 1px solid #ccc;
	cursor: pointer;
	background-color: #fff;
}

/* Дубликаты и выделения */
.highlight-duplicate {
	animation: blink-bg 0.7s ease-in-out 2;
}

@keyframes blink-bg {
    0%,100% { background-color: transparent; }
    50% { background-color: yellow; }
}

.highlight-added {
	animation: blink-added 0.5s ease-in-out 1;
}

@keyframes blink-added {
	0%, 100% {
		box-shadow: none;
	}
	50% {
		box-shadow: inset 0 0 0 9999px rgba(120, 255, 120, 0.45), 0 0 0 2px #4caf50;
	}
}

.list-content li.highlighted {
	box-shadow: 0 0 0 3px var(--highlight-color);
}

.side-sheet ul.list-content li:first-child {
	margin-top: 3px;
}

/* ============================== Overlay ============================== */
#sheet-overlay,
.side-sheet-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.25);
	z-index: 1100;
	display: none;
}

.side-sheet-overlay {
	z-index: 1050;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.side-sheet-overlay.show {
	opacity: 1;
}

/* ============================== Bottom Sheet ============================== */
#bottom-sheet {
	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	bottom: 0;
	max-width: 800px;
    min-height: 100px;
	width: 95%;
	background: var(--bottom-sheet-bg);
	border-top: 1px solid var(--bottom-sheet-border);
	box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
	border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
	padding: 12px;
	display: none;
	z-index: 1101;
	opacity: 0;
	transition: bottom 0.25s ease, opacity 0.25s ease;
}

#bottom-sheet.open {
	opacity: 1;
	bottom: 0;
}

.sheet-buttons button:hover,
.sheet-comment-btn:hover {
	background-color: #e0e0e0;
	transform: translateY(-1px);
}

.sheet-buttons {
	display: flex;
	justify-content: center;
	/* центрирование кнопок */
	gap: var(--gap);
	margin-top: 8px;
}

.sheet-buttons button:hover {
	background-color: #e0e0e0;
	transform: translateY(-1px);
}

.sheet-meta {
	margin-top: 10px;
	font-size: 0.85rem;
	/* мелкий шрифт */
	color: var(--text-meta);
	text-align: center;
	/* по центру */
}

/* Комментарии */
.sheet-comment-row {
	display: flex;
	justify-content: center;
	gap: var(--gap);
	margin-top: 8px;
}

.sheet-comment-input {
    flex: 1;                  /* растягивается по ширине контейнера */
    max-width: 350px;         /* ограничение для больших экранов */
    min-width: 0;             /* обязательно для корректного flex */
    height: 40px;
    padding: 8px 12px;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid #888;
    background-color: #f0f0f0;
    outline: none;
    transition: background-color 0.2s, transform 0.15s;
}

.sheet-comment-input:focus {
	background-color: #e0e0e0;
}

/* ============================== Side Sheet ============================== */
.side-sheet {
	position: fixed;
	top: 0;
	right: 0;
	width: 70%;
	max-width: 400px;
	height: 100%;
	background: var(--bottom-sheet-bg);
	box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
	padding: 12px;
	display: flex;
	flex-direction: column;
	z-index: 1051;
	overflow: hidden;
	transform: translateX(100%);
	transition: transform 0.2s ease, opacity 0.2s ease;
	opacity: 0;
}

.side-sheet.open {
	transform: translateX(0);
	opacity: 1;
}

#side-frequent-list {
	flex: 1;
	overflow-y: auto;
	padding-bottom: 80px;
}

.side-sheet-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	position: sticky;
	top: 0;
	background: var(--bottom-sheet-bg);
	padding: 8px 0;
	z-index: 10;
}

.side-sheet-header span {
	font-size: 1.5rem;
	font-weight: 600;
	text-align: center;
	flex: 1;
	margin: 10px 0 0;
}

.side-sheet-footer {
	position: absolute;
	bottom: 12px;
	left: 12px;
	right: 12px;
}

.side-sheet-footer::before {
	content: "";
	position: absolute;
	top: -40px;
	left: 0;
	width: 100%;
	height: 40px;
	background: linear-gradient(to bottom, rgba(241, 243, 246, 0), var(--bottom-sheet-bg));
	pointer-events: none;
}

.side-sheet-hide-btn {
	width: 100%;
	padding: 14px 0;
	border-radius: 10px;
	font-size: 20px;
	background-color: #ffd966;
	color: #000;
	font-weight: bold;
	cursor: pointer;
	text-align: center;
	transition: background-color 0.2s, transform 0.15s;
}

.side-sheet-hide-btn:active {
	transform: scale(0.98);
}

.frequent-category-header {
    margin: 14px 8px 6px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    opacity: 0.8;
}

/* ============================== Анимации ============================== */
.global-star {
	position: fixed;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%) scale(0.9);
	font-size: 192px;
	opacity: 0;
	pointer-events: none;
	z-index: 3000;
	transition: opacity 0.5s ease, transform 0.5s ease;
}

.global-star.show {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1.2);
}

.fly-to-bought {
	position: absolute;
	pointer-events: none;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	margin: 0;
	transition: top 0.6s ease, left 0.6s ease;
	z-index: 1000;
}

/* ============================== Bottom Sheet: кнопки специальные ============================== */

/* Кнопка метки */
.sheet-question-btn {
    height: 50px;
    color: #333;
    border-radius: 12px; /* слегка скругленные углы */
    font-size: 1rem; /* оставляем только эмодзи */
    padding: 0 10px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.15s, background-color 0.2s;
}
.sheet-question-btn:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
}
.sheet-question-btn:active {
    transform: scale(0.95);
}

/* Кнопка "В частое" (⭐) */
.sheet-frequent-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;           /* круглая */
    font-size: 1.5rem;            /* эмодзи */
    display: flex;
    align-items: center;          /* центрируем вертикально */
    justify-content: center;      /* центрируем горизонтально */
    text-align: center;
    padding: 0;
    border: 1px solid #d4af37;
    background-color: var(--frequent-button-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: transform 0.15s, background-color 0.2s;

    /* Дополнительная корректировка для мобильных эмодзи */
    line-height: 1;
}

/* Hover и активное состояние */
.sheet-frequent-btn:hover {
    background-color: var(--frequent-button-color);
    transform: translateY(-2px);
}
.sheet-frequent-btn:active {
    transform: scale(0.95);
}

/* Кнопка "Удалить" (❌) */
.sheet-delete-btn {
    width: 50px;
    height: 50px;
    border-radius: 12px; /* квадратная со скругленными углами */
    font-size: 1.5rem; /* оставляем только эмодзи */
    padding: 0;
    border: 1px solid #d33;
    background-color: #fdd;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.15s, background-color 0.2s;
}
.sheet-delete-btn:hover {
    background-color: #fbb;
    transform: translateY(-2px);
}
.sheet-delete-btn:active {
    transform: scale(0.95);
}

.notify-telegram-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    padding: 4px 12px;
    cursor: pointer;
    background: #9bbae3;
    color: white;
    border: 2px solid #7aa0d2;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.notify-telegram-btn:hover {
    background: #508fe5;
    box-shadow: 0 6px 8px rgba(0,0,0,0.3); /* увеличиваем тень при hover */
}

@media (min-width: 1024px) {
    #app {
        width: 45%;
        max-width: 800px;
        margin: 24px auto;          /* центрирование по горизонтали */
        border-radius: 12px;
        box-shadow: 0 10px 40px rgba(0,0,0,0.08);
        background-color: var(--body-bg);
    }

    .add-container {
        width: 45%;
        max-width: 800px;

        left: 50%;
        transform: translateX(-50%);

        padding-left: 16px;
        padding-right: 16px;
    }

    body {
        background: #d9d9d9;
    }
}