/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

html, body {
    /* Kill the Android pull-to-refresh / iOS rubber-band reload so it feels like an app. */
    overscroll-behavior-y: none;
    overscroll-behavior-x: none;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000;
    color: #fff;
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 50px;
    animation: fadeIn 0.5s ease-out;
    /* Prevent double-tap zoom and text-selection in chrome-less app shell. */
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Inputs must keep selection / native touch behavior. */
input, textarea {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

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

.main-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin: 1.5rem auto 1rem;
    text-align: center;
    color: #fff;
    animation: fadeInScale 0.8s ease-out;
    max-width: 800px;
}

.main-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    animation: fadeInUp 0.7s ease-out;
}

.shopping-list {
    list-style: none;
    margin-top: 1rem;
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Input field */
.input {
    display: block;
    background: #000;
    border: 1px solid #fff;
    outline: none;
    flex: 1;
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 0;
    color: #fff;
    transition: all 0.3s ease;
    font-family: inherit;
}

.input::placeholder {
    color: #666;
}

.input:focus {
    background: #111;
}

.input-with-button {
    display: flex;
    align-items: stretch;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 2rem;
    gap: 0;
}

/* From Uiverse.io by OnCloud125252 - Plus Button */
.plusButton {
    --plus_sideLength: 46px;
    --plus_topRightTriangleSideLength: 0.9rem;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid white;
    border-left: none;
    width: var(--plus_sideLength);
    min-width: var(--plus_sideLength);
    height: auto;
    background-color: #000;
    overflow: hidden;
    cursor: pointer;
}

.plusButton::before {
    position: absolute;
    content: "";
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-width: 0 var(--plus_topRightTriangleSideLength) var(--plus_topRightTriangleSideLength) 0;
    border-style: solid;
    border-color: transparent white transparent transparent;
    transition: 0.2s ease-in-out;
}

.plusButton:hover::before {
    --plus_topRightTriangleSideLength: calc(var(--plus_sideLength) * 2);
}

.plusButton > .plusIcon {
    fill: white;
    width: calc(var(--plus_sideLength) * 0.5);
    height: calc(var(--plus_sideLength) * 0.5);
    z-index: 1;
    transition: 0.2s ease-in-out;
}

.plusButton:hover > .plusIcon {
    fill: black;
    transform: rotate(180deg);
}

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

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.hidden {
    display: none !important;
}

.list-item {
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.8rem 0.5rem;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    transition: var(--transition);
    transform: translateX(0);
    animation: slideInLeft 0.4s ease-out forwards;
    opacity: 0;
    will-change: transform, opacity;
}

.list-item:nth-child(1) { animation-delay: 0.05s; }
.list-item:nth-child(2) { animation-delay: 0.1s; }
.list-item:nth-child(3) { animation-delay: 0.15s; }
.list-item:nth-child(4) { animation-delay: 0.2s; }
.list-item:nth-child(5) { animation-delay: 0.25s; }

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOutSlideRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
        height: 0;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
}

.list-item.completed .item-text {
    text-decoration: line-through;
    color: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.list-item.completed {
    opacity: 0.6;
}

.fade-out {
    animation: fadeOutSlideRight 0.15s ease-out forwards !important;
}

/* Animated checkbox */
.checkbox-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    color: #fff;
    cursor: pointer;
}

.checkbox-svg {
    cursor: pointer;
    vertical-align: middle;
}

.checkbox-wrapper .path1 {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: 0.4s stroke-dashoffset ease;
    opacity: 0;
}

.checkbox-wrapper .path1.checked {
    stroke-dashoffset: 0;
    opacity: 1;
}

.item-text {
    flex-grow: 1;
    font-size: 1rem;
    word-break: break-word;
    transition: all 0.3s ease;
    font-weight: 400;
    margin: 0 0.8rem;
    color: #fff;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.list-item:hover .item-actions {
    opacity: 1;
    transform: translateX(0);
}

/* Show actions on mobile */
@media (max-width: 768px) {
    .item-actions {
        opacity: 1;
        transform: translateX(0);
    }
}

.item-actions button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-size: 0.8rem;
    width: 28px;
    height: 28px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #fff;
}

.item-actions button:hover {
    background: #fff;
    color: #000;
    border-color: #fff;
}

.actions-container {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-top: 2rem;
    animation: fadeIn 0.8s ease-out;
}

/* btn-17 style - black/white */
.btn-17,
.btn-17 *,
.btn-17 :after,
.btn-17 :before,
.btn-17:after,
.btn-17:before {
    border: 0 solid;
    box-sizing: border-box;
}

.btn-17 {
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: button;
    background-color: #000;
    background-image: none;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.5;
    margin: 0;
    -webkit-mask-image: -webkit-radial-gradient(#000, #fff);
    padding: 0;
    text-transform: uppercase;
    border: 1px solid #fff;
}

.btn-17 {
    border-radius: 0;
    padding: 0.5rem 1.2rem;
    z-index: 0;
}

.btn-17,
.btn-17 .text-container {
    overflow: hidden;
    position: relative;
}

.btn-17 .text-container {
    display: block;
    mix-blend-mode: difference;
}

.btn-17 .text {
    display: block;
    position: relative;
}

.btn-17:hover .text {
    animation: move-up-alternate 0.3s forwards;
}

@keyframes move-up-alternate {
    0% { transform: translateY(0); }
    50% { transform: translateY(80%); }
    51% { transform: translateY(-80%); }
    to { transform: translateY(0); }
}

.btn-17:after,
.btn-17:before {
    background: #fff;
    content: "";
    display: block;
    height: 102%;
    left: -60%;
    pointer-events: none;
    position: absolute;
    top: -104%;
    transform: skew(30deg) translateY(var(--progress, 0));
    transition: transform 0.2s ease;
    width: 100%;
}

.btn-17:after {
    --progress: 0%;
    left: 60%;
    top: 102%;
    z-index: -1;
}

.btn-17:hover:before {
    --progress: 100%;
}

.btn-17:hover:after {
    --progress: -102%;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: #000;
    border: 1px solid #fff;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #fff;
    text-align: center;
    font-weight: 600;
    font-family: 'Playfair Display', Georgia, serif;
}

#item-input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid #fff;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    background: #000;
    color: #fff;
}

#item-input:focus {
    outline: none;
    background: #111;
}

#item-input::placeholder {
    color: #666;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn {
    padding: 0.6rem 1.5rem;
    border: 1px solid #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    background: #000;
    color: #fff;
}

.btn:hover {
    background: #fff;
    color: #000;
}

.btn-primary {
    background: #fff;
    color: #000;
}

.btn-primary:hover {
    background: #000;
    color: #fff;
}

.btn-secondary {
    background: #000;
    color: #fff;
}

/* Confirm Dialog */
.confirm-content {
    background: #000;
    border: 1px solid #fff;
    padding: 2rem;
    width: 90%;
    max-width: 350px;
    text-align: center;
    animation: confirmPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes confirmPop {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.confirm-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    color: #fff;
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

.confirm-icon svg {
    width: 100%;
    height: 100%;
}

.confirm-content h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
}

.confirm-content p {
    font-size: 0.9rem;
    color: #999;
    margin-bottom: 1.5rem;
}

.confirm-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}

.confirm-actions .btn {
    min-width: 90px;
}

/* Toggle animation */
.list-item.completing {
    animation: completeItem 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes completeItem {
    0% { transform: scale(1); }
    50% { transform: scale(1.02) translateX(3px); }
    100% { transform: scale(1) translateX(0); }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 10000;
    animation: toastIn 0.3s ease forwards;
    font-size: 0.9rem;
    background: #fff;
    color: #000;
    border: none;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast-info,
.toast-success,
.toast-error {
    background: #fff;
    color: #000;
}

.toast-message {
    flex-grow: 1;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    opacity: 1;
}

/* Install PWA Popup */
.install-popup {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 9999;
    animation: slideUp 0.4s ease forwards;
}

.install-popup.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.install-card {
    background: #000;
    border: 1px solid #fff;
    display: flex;
    flex-direction: column;
    padding: 24px;
    min-width: 300px;
    max-width: 350px;
    position: relative;
}

.install-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}

.install-close:hover {
    color: #fff;
}

.install-icon {
    width: 50px;
    height: 50px;
    margin-bottom: 12px;
    color: #fff;
}

.install-icon svg {
    width: 100%;
    height: 100%;
}

.install-small-text {
    color: #666;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.install-title {
    color: #fff;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 24px;
    font-weight: 700;
    margin: 8px 0;
}

.install-desc {
    color: #888;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.install-buttons {
    display: flex;
    justify-content: center;
}

.install-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #fff;
    color: #000;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.install-button:hover {
    background: #000;
    color: #fff;
    border: 1px solid #fff;
}

.install-button-icon {
    width: 24px;
    height: 24px;
}

.install-button-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.install-button-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.install-button-text span:first-child {
    font-size: 11px;
    opacity: 0.7;
}

.install-button-text span:last-child {
    font-size: 14px;
    font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
    .main-title {
        font-size: 2rem;
    }

    .main-content {
        padding: 0.75rem;
    }

    .input-with-button {
        max-width: 100%;
    }

    .list-item {
        padding: 0.7rem 0.3rem;
    }

    .modal-content,
    .confirm-content {
        margin: 1rem;
        padding: 1.5rem;
    }
}
