/* public/css/modern.css */

/* Global Resets & Fundamentals */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* View Transitions API (Cross-document) */
@view-transition {
    navigation: auto;
}

/* Base View Transition Animations */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.4s;
    animation-fill-mode: both;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--color-bg);
}
::-webkit-scrollbar-thumb {
    background: var(--color-text-muted);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Scroll-driven animations base class */
.fade-up-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.fade-up-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Custom Dialog (Modal) Styles */
dialog.modern-modal {
    padding: 0;
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    background: var(--color-surface);
    color: var(--color-text);
    max-width: 500px;
    width: 90%;
    margin: auto;
    overflow: hidden;
    transform: scale(0.95);
    opacity: 0;
    transition: transform var(--transition-bounce), opacity var(--transition-fast);
}

dialog.modern-modal[open] {
    transform: scale(1);
    opacity: 1;
}

dialog.modern-modal::backdrop {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

dialog.modern-modal[open]::backdrop {
    opacity: 1;
}

/* Modern Button Base */
.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}
.btn-modern:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.btn-modern:active {
    transform: translateY(0);
}

/* Overriding Bootstrap specifically for modern components */
.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

/* -------------------------------------
   Sidebar Cart Drawer (Mobile First)
---------------------------------------- */
dialog.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    margin-left: auto;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    transform: translateX(100%);
    opacity: 1; /* Override default opacity change to allow smooth slide */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    padding: 0;
    display: none; /* Hide when closed */
}

dialog.cart-drawer[open] {
    display: flex;
    flex-direction: column;
    transform: translateX(0);
}

/* Header, Body, Footer logic */
.drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface);
}

.drawer-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    background: var(--color-surface);
}

.drawer-footer {
    padding: 20px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

/* Cart Item Layout */
.cart-item-row {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--color-border);
    position: relative;
}
.cart-item-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.cart-item-image {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cart-item-details {
    flex-grow: 1;
    min-width: 0; /* Prevents blowout */
    padding-right: 25px; /* Space for trash icon */
}

.cart-item-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 5px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-price-unit {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap; /* Wraps cleanly on tiny screens */
}

.quantity-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: white;
    overflow: hidden;
    height: 32px;
}

.quantity-control button {
    background: none;
    border: none;
    width: 30px;
    height: 100%;
    font-weight: bold;
    cursor: pointer;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.quantity-control button:hover {
    background: var(--color-bg);
}

.quantity-control span {
    width: 30px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.cart-item-subtotal {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--color-accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.cart-item-remove {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 5px;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.cart-item-remove:hover {
    transform: scale(1.1);
}
