:root {
    --primary-pink: #d955e0;
    --primary-pink-dark: #b83ebd;
    --bg: #f2f2f2;
    --panel: #efefef;
    --card: #f7f7f7;
    --text: #3f3f3f;
    --muted: #7d7d7d;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: var(--bg);
}

body {
    overflow: hidden;
}

body.page-preload {
    opacity: 0;
}

body.page-ready {
    opacity: 1;
    transition: opacity 0.2s ease;
}

body.menu-open {
    overflow: hidden;
}

.overlay {
    display: none;
}

.mobile-menu-btn {
    display: none;
}

.app-container {
    position: fixed;
    inset: 0;
    display: flex;
    width: 100vw;
    height: 100dvh;
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 250, 252, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    padding: 18px 25px 24px;
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), padding 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.28s ease;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed {
    width: 70px;
    padding: 25px 15px;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--primary-pink);
    font-size: 1.8rem;
    cursor: pointer;
    margin-bottom: 20px;
    align-self: flex-end;
    transition: transform 0.3s ease;
}

.toggle-btn:hover {
    transform: scale(1.05);
}

.sidebar.collapsed .toggle-btn {
    align-self: center;
}

.brand-logo {
    font-family: "Didot", "Bodoni MT", "Noto Serif Display", serif;
    font-size: 2.2rem;
    color: var(--primary-pink);
    font-weight: 700;
    font-style: italic;
    text-align: center;
    margin-bottom: 40px;
    cursor: pointer;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease, height 0.3s ease, margin 0.3s ease;
    position: relative;
    padding-bottom: 20px;
}

.brand-logo::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 40px;
    height: 3px;
    transform: translateX(-50%);
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-pink), transparent);
}

.sidebar.collapsed .brand-logo {
    opacity: 0;
    height: 0;
    margin-bottom: 0;
    overflow: hidden;
}

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.nav-item {
    margin-bottom: 10px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid transparent;
    text-decoration: none;
    color: #666;
    font-weight: 600;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
    color: var(--primary-pink);
    background-color: rgba(255, 255, 255, 0.6);
    border-color: rgba(217, 85, 224, 0.2);
    transform: translateX(5px);
}

.sidebar .nav-link.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-pink-dark));
    box-shadow: 0 8px 20px rgba(217, 85, 224, 0.3);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .nav-link .link-text {
    display: none;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.4);
    padding-top: 20px;
}

.logout-form {
    margin: 0;
}

.logout-footer-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 15px;
    border: 1px solid var(--primary-pink);
    border-radius: 12px;
    background: transparent;
    color: var(--primary-pink);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-footer-btn:hover {
    color: #fff;
    background: var(--primary-pink);
    box-shadow: 0 4px 10px rgba(217, 85, 224, 0.3);
}

.login-footer-btn {
    margin-top: 10px;
}

.sidebar.collapsed .logout-footer-btn .link-text {
    display: none;
}

.cart-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100dvh;
    overflow-y: auto;
    padding: 18px 26px 26px;
    background:
        radial-gradient(circle at 90% 14%, rgba(217, 85, 224, 0.07), transparent 36%),
        radial-gradient(circle at 8% 16%, rgba(255, 185, 220, 0.09), transparent 32%),
        linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}

.cart-card {
    max-width: 1400px;
    min-height: calc(100dvh - 44px);
    margin: 0 auto;
    border-radius: 34px;
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 20px 40px rgba(27, 22, 31, 0.08);
    padding: 34px 48px 26px;
    display: flex;
    flex-direction: column;
}

.cart-header {
    padding-bottom: 18px;
    border-bottom: 1px solid #d8d8d8;
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-back {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid rgba(217, 85, 224, 0.9);
    background: #fff;
    color: var(--primary-pink);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(217, 85, 224, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.btn-back:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(217, 85, 224, 0.25);
    color: var(--primary-pink);
}

.btn-back svg {
    width: 22px;
    height: 22px;
}

.cart-header h1 {
    margin: 0;
    font-size: 1.8rem;
    line-height: 1.05;
    color: #3f3f3f;
    font-weight: 800;
}

.cart-items-container {
    flex: 1;
    min-height: 260px;
    padding-top: 18px;
    display: flex;
    flex-direction: column;
}

.cart-item {
    display: grid;
    grid-template-columns: 102px minmax(0, 1fr) auto auto;
    gap: 20px;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #dfdfdf;
}

.cart-item-image {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: #e1e1e1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9a9a9a;
    font-size: 0.9rem;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cart-item-name {
    margin: 0 0 4px;
    font-size: 1.1rem;
    color: #3f3f3f;
    line-height: 1.2;
    font-weight: 700;
}

.cart-item-meta {
    margin: 0;
    color: #7a7a7a;
    font-size: 0.9rem;
    line-height: 1.25;
}

.cart-item-qty {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #d7d7d7;
    background: transparent;
    color: #666;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    border-color: var(--primary-pink);
    color: var(--primary-pink);
}

.qty-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.qty-value {
    min-width: 24px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: #4a4a4a;
}

.cart-item-price {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-pink);
    white-space: nowrap;
}

.cart-footer {
    margin-top: 22px;
    border-top: 1px solid #dddddd;
    padding-top: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.cart-total {
    font-size: 1.5rem;
    line-height: 1.1;
    color: #3e3e3e;
}

.cart-checkout-btn {
    min-height: 48px;
    min-width: 220px;
    border: none;
    border-radius: 12px;
    padding: 0 24px;
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-pink-dark));
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(217, 85, 224, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.cart-checkout-btn:hover {
    transform: translateY(-1px);
    filter: saturate(1.03);
    box-shadow: 0 18px 30px rgba(217, 85, 224, 0.42);
}

.cart-checkout-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

.cart-empty {
    margin-top: 8px;
    border: 1px dashed #d3cdd6;
    border-radius: 18px;
    background: linear-gradient(180deg, #fdfbfd 0%, #f6f3f8 100%);
    padding: 26px;
    text-align: center;
    color: #6f6574;
}

.cart-empty strong {
    display: block;
    color: #4a4450;
    font-size: 1.15rem;
    margin-bottom: 6px;
}

.cart-empty a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    margin-top: 14px;
    padding: 0 18px;
    border-radius: 12px;
    border: 1px solid var(--primary-pink);
    color: var(--primary-pink);
    text-decoration: none;
    font-weight: 700;
}

.cart-empty a:hover {
    background: rgba(217, 85, 224, 0.08);
}

.cart-warning {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(217, 85, 224, 0.25);
    background: rgba(217, 85, 224, 0.1);
    color: #8a2b90;
    font-size: 0.92rem;
    font-weight: 600;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translate(-50%, 120px);
    background: #2ecc71;
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 12px 20px rgba(46, 204, 113, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 1005;
    max-width: min(90vw, 580px);
    word-break: break-word;
}

.toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

@media (max-width: 1280px) {
    .cart-card {
        padding: 26px 30px 20px;
    }

    .cart-header h1 {
        font-size: 1.6rem;
    }

    .cart-item-name {
        font-size: 1rem;
    }

    .cart-item-meta {
        font-size: 0.85rem;
    }

    .cart-item-price {
        font-size: 1.05rem;
    }

    .cart-total {
        font-size: 1.35rem;
    }

    .cart-checkout-btn {
        font-size: 1rem;
        min-height: 44px;
        min-width: 200px;
    }
}

@media (max-width: 992px) {
    .mobile-menu-btn {
        position: fixed;
        top: 14px;
        left: 14px;
        z-index: 1002;
        width: 44px;
        height: 44px;
        border: none;
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #fff;
        color: var(--primary-pink);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
        font-size: 1.2rem;
    }

    .overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s ease, visibility 0.25s ease;
        z-index: 1000;
    }

    body.menu-open .overlay {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(82vw, 290px);
        padding: 22px 16px;
        transform: translateX(-105%);
        transition: transform 0.28s ease;
        z-index: 1001;
        overflow-y: auto;
        white-space: normal;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar .toggle-btn {
        display: none;
    }

    .cart-content {
        width: 100%;
        height: 100dvh;
        padding: 68px 12px 12px;
    }

    .cart-card {
        min-height: unset;
        border-radius: 22px;
        padding: 18px 14px 16px;
    }

    .cart-header {
        padding-bottom: 12px;
        gap: 12px;
    }

    .btn-back {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        border-width: 1.5px;
    }
    
    .btn-back svg {
        width: 20px;
        height: 20px;
    }

    .cart-header h1 {
        font-size: 1.9rem;
    }

    .cart-items-container {
        min-height: 160px;
        padding-top: 8px;
    }

    .cart-item {
        grid-template-columns: 62px minmax(0, 1fr);
        grid-template-areas:
            "image info"
            "image controls"
            "price price";
        gap: 8px 12px;
        padding: 12px 0;
    }

    .cart-item-image {
        grid-area: image;
        width: 62px;
        height: 62px;
        border-radius: 10px;
    }

    .cart-item-info {
        grid-area: info;
    }

    .cart-item-name {
        font-size: 1.12rem;
        margin-bottom: 2px;
    }

    .cart-item-meta {
        font-size: 0.92rem;
    }

    .cart-item-qty {
        grid-area: controls;
    }

    .qty-btn {
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
    }

    .qty-value {
        font-size: 0.95rem;
        min-width: 20px;
    }

    .cart-item-price {
        grid-area: price;
        font-size: 1.05rem;
        justify-self: flex-end;
    }

    .cart-footer {
        margin-top: 14px;
        padding-top: 12px;
        flex-direction: column;
        align-items: stretch;
    }

    .cart-total {
        font-size: 1.3rem;
    }

    .cart-checkout-btn {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        border-radius: 12px;
        font-size: 1rem;
    }
}
