/* Переменные для легкой настройки цветов одной гаммы */
:root {
    /* Базовый тон (0-360) */
    --h: 283;
    
    /* Основной цвет: насыщенный лиловый */
    --primary-color: hsl(var(--h), 40%, 53%);
    
    /* Светлый лавандовый: высокая светлота, низкая насыщенность */
    --primary-light: hsl(var(--h), 100%, 93%);
    
    /* Темный фиолетовый: низкая светлота */
    --primary-dark: hsl(var(--h), 43%, 36%);

    /* Glassmorphism: используем hsla для прозрачности */
    --glass-bg: hsla(var(--h), 40%, 53%, 0.15);
    --glass-border: hsla(var(--h), 40%, 53%, 0.3);

    /* Текст */
    --text-main: hsl(var(--h), 40%, 17%);
    --text-secondary: hsl(var(--h), 30%, 50%);

    /* Попапы */
    --error-color: hsl(343, 70%, 50%);
    --success-color: hsl(143, 60%, 55%);

    /* Границы */
    --border-color: hsl(var(--h), 10%, 85%);

    /* Тень */
    --shadow-color: hsla(var(--h), 40%, 30%, 0.2);
    --shadow: 0 8px 32px 0 var(--shadow-color);

    /* Borders */
    --border-radius: 16px;
}

/* Общие сбросы */
body {
    font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Мягкий градиент на фоне для усиления эффекта стекла */
    background: radial-gradient(circle at top right, #e8f0fe, #ffffff);
    color: var(--text-main);
    line-height: 1.5;
}

/* Шапка */
.sl-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100vw;
    /* gap: 12px; */
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 8px;
    box-sizing: border-box;
    margin-bottom: 16px;
}

/* Контейнер с контентом */
.sl-main {
    width: 90%;
    max-width: 500px;
    margin: 0 auto 40px auto;
    padding: 12px 28px;
    
    /* Эффект стекла */
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

/* Форма */
.sl-form {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: stretch;
}
.sl-item-form {
    display: flex;
    /* flex-wrap: nowrap; */
    /* flex-flow: wrap; */
    flex-direction: row;
    /* justify-content: flex-end; */
    flex-wrap: wrap;
    flex-flow: column;
}

/* Кнопки */
.sl-button {
    font-family: inherit;
    font-weight: 500;
    margin-block: 4px;
    cursor: pointer;
    padding: 8px 16px;
    margin: 4px;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--primary-color);
    color: white;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px var(--shadow);;
    max-width: max-content;
    align-self: baseline;
    user-select: none;
}
.sl-button:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 4px 8px var(--shadow);;
}
/* Кнопка удаления */
.sl-button-delete {
    border: none;
    border-radius: var(--border-radius);
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid transparent;
    box-shadow: none;
    user-select: none;
}
.sl-button-delete:hover {
    background-color: rgba(217, 48, 37, 0.1);
    color: var(--error-color);
    box-shadow: none;
}

/* Заголовки */
.sl-h1 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--primary-dark);
    margin: 0 0 16px 0;
}
.sl-h2 {
    font-size: 1.25rem;
    font-weight: 500;
}
.sl-h3 {
    color: var(--primary-dark);
    font-size: 1rem;
}

.sl-paragraph {
    margin-block: 4px;
}

p {
    margin: 0;
    padding: 0;
}

ul {
    list-style-type: none;
    padding: 0; 
    margin: 0;
    display: flex;
    flex-direction: column;
}

li {
    list-style-type: none;
    padding: 0; 
    margin: 0;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.sl-li {
    align-items: flex-start;
    padding: 0;
    margin-block: 8px;
    display: flex;
    flex-direction: column;
}

.sl-simple-block {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px 16px;
    width: -webkit-fill-available;
}
.sl-beautiful-block {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    align-items: stretch;
    margin-block: 8px;
}

.sl-row {
    display: flex;
    flex-direction: row;
    /* margin-block-end: 8px; */
}

/* Инпуты */
.sl-input {
    display: flex;
    margin-block-start: 8px;
}
.sl-input-text {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s;
    outline: none;
}
.sl-input-text:focus {
    border-color: var(--primary-color);
    background: #fff;
}
input[type="email"], input[type="password"], input[type="text"] {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s;
    outline: none;
    display: flex;
    width: -webkit-fill-available;
    margin-block-end: 4px;
}

input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: #fff;
    cursor: pointer;
    display: inline-grid;
    place-content: center;
    transition: all 0.2s ease;
}
input[type="checkbox"]:hover {
    border-color: var(--primary-color);
}
input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
input[type="checkbox"]::before {
    content: "";
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    background-color: white;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
input[type="checkbox"]:checked::before {
    transform: scale(1);
}


/* ====================== ПРОСТРАНСТВА со списками ====================== */
/* Заголовок пространства */
.sl-space-header {
    display: flex;
    place-content: flex-end;
}

/* Пространство */
.sl-space, .sl-space-main {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--glass-border);;
    border-radius: var(--border-radius);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: -webkit-fill-available;
    margin-block: 16px 8px;
}

.sl-space {
    cursor: pointer;
}

.sl-space-main {
    align-items: flex-start;
    margin-block: 8px
}

.sl-space-main-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.sl-space:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}
.sl-space.done {
    text-decoration: line-through;
    color: var(--text-secondary);
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.02);
    order: 1;
}
.sl-space:not(.done) {
    order: 0;
}

.sl-space-info {
    display: flex;
    flex-direction: column;
    align-self: stretch;
}
/* пользователи пространства */
.sl-users {
    display: flex;
    flex-direction: column;
}
.sl-users-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}
.sl-user-badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 4px 8px 2px 0;
}


/* ====================== СПИСКИ внутри пространства ====================== */

.sl-lists {
    width: -webkit-fill-available;
}

.sl-list {
    display: flex;
    flex-direction: column;
}

.sl-list-in-space {
    padding: 0;
    /* margin-block: 8px; */
    /* display: flex; */
    width: 100%;
}

.sl-space-items {
    /* display: flex;
    flex-direction: column; */
    justify-content: space-between;
    width: 100%;
}

.sl-item {
    display: flex;
    flex-direction: row;
    /* width: 100%; */
    background-color: var(--primary-light);
    box-shadow: 0 2px 4px var(--shadow);;
    border-radius: var(--border-radius);
    padding: 2px;
    margin: 4px;
}

.sl-item-content {
    display: flex;
    flex: auto;
    align-self: center;
    align-items: center;
}
.sl-item-buttons {
    display: flex;
    align-self: center;
}

/* Зачёркивание и перемещение вниз */
.sl-item.done {
    background-color: var(--glass-bg);
    opacity: 0.8;
}

.sl-item-text.done {
    text-decoration: line-through;
    color: var(--primary-color);
}

li.done {
    order: 1;
}

li:not(.done) {
    order: 0;
}

/* Попапы */
#popup-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px; /* Расстояние между уведомлениями */
    pointer-events: none; /* Чтобы контейнер не мешал кликам, если он пустой */
}

.sl-popup-message {
    position: relative; /* no fixed! */
    width: fit-content;
    margin-left: auto; /* к правому краю */
    pointer-events: auto; /* кликабельность самим плашкам */
    padding: 16px 24px;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    z-index: 1000;
    box-shadow: var(--shadow);;
    backdrop-filter: blur(8px);
    animation: slideIn 0.3s ease-out, fadeout 0.5s ease-out 3s forwards;
}
.sl-popup-error { background: var(--error-color); }
.sl-popup-success { background: var(--success-color); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeout {
    from { opacity: 1; }
    to { opacity: 0; visibility: hidden; }
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 600px) {
    .sl-header {
        width: 95%;
        margin: 16px auto 8px auto;
        justify-content: center;
    }

    .sl-main {
        width: 100%;
        box-sizing: border-box;
        padding: 16px 20px;
        margin-bottom: 20px;
        margin-left: 0;
        margin-right: 0;
        border-radius: 0;
        min-height: 100vh;
    }

    .sl-h1 {
        font-size: 1.25rem;
        text-align: center;
    }

    .sl-h2 {
        font-size: 1.1rem;
    }

    .sl-item {
        flex-direction: column;
        padding: 8px;
    }

    .sl-item-content {
        width: 100%;
        margin-bottom: 8px;
    }

    .sl-item-buttons {
        width: 100%;
        justify-content: flex-end;
    }

    .sl-button {
        padding: 10px 14px; /* Увеличиваем область нажатия */
        font-size: 0.9rem;
    }

    .sl-user-badge {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    input[type="email"], 
    input[type="password"], 
    input[type="text"] {
        font-size: 16px; /* Предотвращает зум на iOS при фокусе */
        padding: 10px;
    }

    .sl-popup-message {
        left: 20px;
        right: 20px;
        top: 10px;
        text-align: center;
    }
}