/* ================================
   SAFE AREA (iPhone 14/15 Pro/Max)
================================ */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-bg: #eef2ff;
    --border: #d1d5db;
    --text: #111827;
    --text-light: #6b7280;
    --bg: #f9fafb;
}


/* ================================
   GLOBAL
================================ */
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
    color: var(--text);
}

.app-container {
    padding-bottom: calc(60px + var(--safe-bottom));
    min-height: 100vh;
    position: relative;
}

/* Шапка */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding-top: calc(8px + var(--safe-top));
    padding-bottom: 8px;
    padding-left: 16px;
    padding-right: 16px;
    background: rgba(249, 250, 251, 0.94);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--primary);
}

.top-bar-left i {
    font-size: 22px;
}

.top-bar-title {
    font-size: 18px;
    color: var(--text);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e5e7eb;
    font-size: 13px;
    color: var(--text);
}

.link-button {
    border: none;
    background: none;
    color: var(--primary);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
}


/* ================================
   AUTH SCREEN (LOGIN / REGISTER)
================================ */
.auth-screen {
    min-height: calc(100vh - 56px);
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    padding-left: max(16px, var(--safe-left));
    padding-right: max(16px, var(--safe-right));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;

    background: radial-gradient(circle at top left, #818cf8 0, transparent 45%),
                radial-gradient(circle at bottom right, #4f46e5 0, transparent 55%),
                linear-gradient(135deg, #4f46e5, #6366f1);
    color: white;
    box-sizing: border-box;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
}

.auth-logo i {
    font-size: 30px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
}

.auth-subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin-top: 4px;
}

/* Карточка логина/регистрации */
.auth-card-wrapper {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: #ffffff;
    color: var(--text);
    border-radius: 24px;
    padding: 18px 18px 20px;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.35);
    box-sizing: border-box;
}

/* Табы Вход / Регистрация */
.auth-tabs {
    display: flex;
    padding: 4px;
    background: #f3f4f6;
    border-radius: 999px;
    margin-bottom: 16px;
}

.auth-tab {
    flex: 1;
    border-radius: 999px;
    border: none;
    background: transparent;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: #6b7280;
    transition: all .18s ease;
}

.auth-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 6px rgba(148, 163, 184, 0.5);
}

/* Форма */
.auth-form {
    margin-top: 8px;
}

.auth-form .input-group {
    margin-bottom: 14px;
}

.auth-form label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 4px;
    display: block;
}

.auth-error,
.auth-info {
    font-size: 13px;
    margin-top: 6px;
    margin-bottom: 2px;
    padding: 8px 10px;
    border-radius: 10px;
}

.auth-error {
    background: #fef2f2;
    color: #b91c1c;
}

.auth-info {
    background: #ecfdf5;
    color: #047857;
}

/* Доп. текст под карточкой */
.auth-helper-text {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 14px;
    max-width: 420px;
    text-align: center;
}

/* Анимация для карточки */
.fade-slide-enter-active,
.fade-slide-leave-active {
    transition: all 0.25s ease;
}
.fade-slide-enter-from,
.fade-slide-leave-to {
    opacity: 0;
    transform: translateY(16px);
}


/* ================================
   WELCOME SCREEN
================================ */
.welcome-screen {
    padding-top: calc(70px + var(--safe-top));
    padding-left: 20px;
    padding-right: 20px;
    text-align: center;
}

.app-logo {
    font-size: 56px;
    color: var(--primary);
}

.app-title {
    font-size: 28px;
    font-weight: 700;
    margin-top: 12px;
    color: var(--text);
}

.app-subtitle {
    font-size: 16px;
    color: var(--text-light);
    margin-top: 4px;
    margin-bottom: 30px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}


/* ================================
   INPUTS
================================ */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.input-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
}

.input-field {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #ffffff;
    font-size: 16px;
    transition: all .15s ease;
    outline: none;
    box-sizing: border-box;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

.input-field::placeholder {
    color: #9ca3af;
}


/* ================================
   BUTTONS
================================ */
.btn {
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    cursor: pointer;
    font-weight: 500;
    transition: .2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

/* Utility */
.w-full { width: 100% !important; }


/* ================================
   FORM SCREENS (create/join/lists)
================================ */
.form-screen {
    padding-top: calc(20px + var(--safe-top));
}

.form-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 12px;
}

.form-title {
    font-size: 20px;
    font-weight: 600;
}


/* Back button */
.back-btn {
    border: none;
    background: none;
    padding: 8px;
    font-size: 22px;
    cursor: pointer;
}

.form-content {
    padding: 16px;
}


/* ================================
   LIST OF USER’S LISTS
================================ */
.items-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.item-card {
    background: white;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    cursor: pointer;
    transition: .15s;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.item-card:hover {
    transform: translateY(-1px);
}

.item-content {}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-name {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    gap: 6px;
    align-items: center;
}

.item-name.clickable {
    cursor: pointer;
}

.item-meta {
    margin-top: 4px;
}

.time-badge {
    font-size: 12px;
    background: #eef2ff;
    padding: 3px 8px;
    border-radius: 6px;
    color: #4338ca;
}


/* ================================
   LIST VIEW (INSIDE A LIST)
================================ */
.list-screen {}

.list-header {
    padding-top: calc(16px + var(--safe-top));
    padding-bottom: 10px;
    background: white;
    position: sticky;
    top: 0;
    z-index: 100;
    padding-left: 16px;
    padding-right: 16px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-title {
    font-size: 20px;
    font-weight: 600;
}

.list-meta {
    display: flex;
    align-items: center;
    gap: 14px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    padding: 6px;
    cursor: pointer;
}

.list-content {
    padding: 12px 16px 90px;
}


/* ================================
   ITEMS INSIDE LIST
================================ */
.item-card.completed {
    opacity: .6;
}

.item-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--primary);
    margin-right: 4px;
    cursor: pointer;
    flex-shrink: 0;
    box-sizing: border-box;
}

.item-checkbox.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.item-name.completed {
    text-decoration: line-through;
    color: var(--text-light);
}

.item-actions .action-btn.delete {
    background: none;
    border: none;
    font-size: 18px;
    color: #ef4444;
    cursor: pointer;
}

.user-badge {
    margin-top: 6px;
    display: inline-block;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #374151;
}


/* ================================
   ADD ITEM SECTION
================================ */
.add-item-section {
    padding: 14px;
    background: white;
    position: sticky;
    bottom: 0;
    z-index: 20;
    padding-bottom: calc(14px + var(--safe-bottom));
}

.add-item-form {
    display: flex;
    gap: 10px;
}

.add-item-input {
    flex: 1;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 16px;
}

.quantity-input {
    width: 64px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
}

.add-item-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 20px;
}


/* ================================
   iOS TOOLBAR (bottom)
================================ */
.ios-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding-bottom: calc(12px + var(--safe-bottom));
    padding-top: 8px;

    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(16px);

    display: flex;
    justify-content: space-around;
    border-top: 1px solid rgba(0,0,0,.08);

    z-index: 999;
}

.toolbar-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 6px;
    font-size: 12px;
    color: var(--text-light);
    text-align: center;

    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
}

.toolbar-btn i {
    font-size: 22px;
}

.toolbar-btn.active {
    color: var(--primary);
    font-weight: 600;
}


/* ================================
   NOTIFICATIONS
================================ */
.notification {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 18px;
    border-radius: 10px;
    color: white;
    font-size: 15px;
    z-index: 9999;
}

.notification.success { background:#10b981; }
.notification.error   { background:#ef4444; }
.notification.info    { background:#3b82f6; }
.notification.warning { background:#f59e0b; }


/* ============================================
   SPACING — MARGIN / PADDING
============================================ */
/* Margin top */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-5 { margin-top: 20px !important; }
.mt-6 { margin-top: 24px !important; }

/* Margin bottom */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-5 { margin-bottom: 20px !important; }
.mb-6 { margin-bottom: 24px !important; }

/* Margin left / right */
.ml-1 { margin-left: 4px !important; }
.ml-2 { margin-left: 8px !important; }
.ml-3 { margin-left: 12px !important; }

.mr-1 { margin-right: 4px !important; }
.mr-2 { margin-right: 8px !important; }
.mr-3 { margin-right: 12px !important; }

/* Padding */
.p-0  { padding: 0 !important; }
.p-1  { padding: 4px !important; }
.p-2  { padding: 8px !important; }
.p-3  { padding: 12px !important; }
.p-4  { padding: 16px !important; }
.p-5  { padding: 20px !important; }

/* Padding X (left+right) */
.px-1 { padding-left: 4px !important; padding-right: 4px !important; }
.px-2 { padding-left: 8px !important; padding-right: 8px !important; }
.px-3 { padding-left: 12px !important; padding-right: 12px !important; }
.px-4 { padding-left: 16px !important; padding-right: 16px !important; }

/* Padding Y (top+bottom) */
.py-1 { padding-top: 4px !important; padding-bottom: 4px !important; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-3 { padding-top: 12px !important; padding-bottom: 12px !important; }
.py-4 { padding-top: 16px !important; padding-bottom: 16px !important; }


/* ============================================
   FLEX SYSTEM — аналог Tailwind
============================================ */
.flex        { display: flex !important; }
.inline-flex { display: inline-flex !important; }

.flex-row    { flex-direction: row !important; }
.flex-col    { flex-direction: column !important; }

.items-center { align-items: center !important; }
.items-start  { align-items: flex-start !important; }
.items-end    { align-items: flex-end !important; }

.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-around  { justify-content: space-around !important; }

/* Gaps */
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }

/* Доп. классы под ваш шаблон */
.d-flex { display: flex !important; }
.align-center { align-items: center !important; }


/* ============================================
   TEXT & FONT UTILITIES
============================================ */
.text-center { text-align: center !important; }
.text-left   { text-align: left !important; }
.text-right  { text-align: right !important; }

.text-sm  { font-size: 14px !important; }
.text-md  { font-size: 16px !important; }
.text-lg  { font-size: 20px !important; }
.text-xl  { font-size: 24px !important; }

.fw-400 { font-weight: 400 !important; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }


/* ============================================
   WIDTH / HEIGHT / DISPLAY
============================================ */
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-none { display: none !important; }


/* ============================================
   RADIUS / SHADOW / BORDERS
============================================ */
.rounded-sm { border-radius: 6px !important; }
.rounded   { border-radius: 12px !important; }
.rounded-lg { border-radius: 18px !important; }
.rounded-xl { border-radius: 24px !important; }

.shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important; }
.shadow-md { box-shadow: 0 2px 6px rgba(0,0,0,0.12) !important; }
.shadow-lg { box-shadow: 0 4px 12px rgba(0,0,0,0.14) !important; }


/* ============================================
   COLORS
============================================ */
.text-primary { color: var(--primary) !important; }
.bg-primary   { background: var(--primary) !important; color:white !important; }

.bg-white { background: white !important; }
.bg-light { background: #f3f4f6 !important; }

.border { border: 1px solid var(--border) !important; }
.border-primary { border: 1px solid var(--primary) !important; }


/* ============================================
   DESKTOP / TABLET RESPONSIVE ADAPTATION
============================================ */

@media (min-width: 360px) {

    .app-container,
    .welcome-screen,
    .form-screen,
    .list-screen {
        max-width: 360px;
        margin: 0 auto;
    }
}

@media (min-width: 640px) {
    .app-container,
    .welcome-screen,
    .form-screen,
    .list-screen {
        max-width: 480px;
        margin: 0 auto;
    }

    .btn {
        width: 100%;
        max-width: 360px;
        margin-left: auto;
        margin-right: auto;
        display: block;
    }

    .input-field,
    .input-group,
    .add-item-input,
    .quantity-input {
        max-width: 360px;
        margin-left: auto;
        margin-right: auto;
    }

    .add-item-section {
        max-width: 480px;
        margin: 0 auto;
        /*left: 50%;
        transform: translateX(-50%);*/
    }

    .ios-toolbar {
        max-width: 480px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 14px 14px 0 0;
    }

    .auth-screen {
        justify-content: center;
    }
}

/* Extra wide screens (desktop layout) */
@media (min-width: 1024px) {
    body {
        background: #eef2ff;
    }

    .app-container {
        margin-top: 40px;
        margin-bottom: 40px;
    }

    .ios-toolbar {
        position: fixed;
        bottom: 20px;
        border-radius: 20px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    }

    .item-card:hover {
        transform: translateY(-2px) scale(1.01);
    }
}


/* ============================================
   ANIMATION FOR SORTED LIST ITEMS
============================================ */
.item-move-enter-active {
    transition: all 0.25s ease;
}
.item-move-leave-active {
    transition: all 0.25s ease;
}

.item-move-enter-from {
    opacity: 0;
    transform: translateY(-6px);
}

.item-move-leave-to {
    opacity: 0;
    transform: translateY(6px);
}

.item-move-move {
    transition: transform 0.25s ease;
}

/* ================================
   NOTIFICATION ANIMATION
================================ */

.notification {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;

    padding: 14px 20px;
    border-radius: 14px;
    color: white;
    font-size: 15px;
    z-index: 9999;

    /* NEW — мягкая анимация */
    transition:
        opacity 0.35s ease,
        transform 0.35s cubic-bezier(.21,1.02,.73,1);
}

/* Показ */
.notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Типы сообщений */
.notification.success { background:#10b981; }
.notification.error   { background:#ef4444; }
.notification.info    { background:#3b82f6; }
.notification.warning { background:#f59e0b; }
