/* ----- Design Tokens & Variables ----- */
:root {
    --primary: #6366f1; /* Indigo */
    --primary-hover: #4f46e5;
    --secondary: #ec4899; /* Pink */
    
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-input: rgba(15, 23, 42, 0.6);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --border-color: rgba(255, 255, 255, 0.1);
    
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ----- Base Styles ----- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-dark);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ----- Animated Background Shapes ----- */
.background-shapes {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: drift 20s infinite alternate linear;
}

.shape-1 {
    top: -10%; left: -10%;
    width: 50vw; height: 50vw;
    background: var(--primary);
}

.shape-2 {
    bottom: -10%; right: -10%;
    width: 60vw; height: 60vw;
    background: var(--secondary);
    animation-delay: -5s;
}

.shape-3 {
    top: 40%; left: 50%;
    width: 40vw; height: 40vw;
    background: #8b5cf6; /* Violet */
    animation-delay: -10s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.1); }
}

/* ----- Layout ----- */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

/* ----- Header ----- */
.app-header {
    text-align: center;
    margin-bottom: 4rem;
    animation: slideDown 0.8s ease-out forwards;
}

.app-header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.app-header h1 span {
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
    background-image: linear-gradient(to right, var(--primary), var(--secondary));
}

.app-header p {
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* ----- Sections ----- */
.section {
    margin-bottom: 4rem;
    animation: fadeIn 1s ease-out forwards;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.section h2 {
    font-size: 1.8rem;
    font-weight: 600;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
    display: inline-block;
}

/* ----- Grid & Cards (Glassmorphism) ----- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 15px 40px 0 rgba(99, 102, 241, 0.3);
}

.product-id {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 1px;
}

.product-name {
    font-size: 1.4rem;
    font-weight: 600;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
    margin-top: auto;
    padding-top: 1rem;
}

/* ----- Forms & Inputs ----- */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    max-width: 500px;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: white;
    padding: 1rem 1.2rem;
    border-radius: 10px;
    font-size: 1rem;
    transition: var(--transition);
    font-family: inherit;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* ----- Buttons ----- */
.primary-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(1px);
}

.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ----- Loaders ----- */
.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

#products-loader {
    border-top-color: var(--primary);
}

.hidden {
    display: none !important;
}

/* ----- Toast Notification ----- */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #10b981; /* Emerald */
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3);
    font-weight: 600;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 100;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    background: #ef4444; /* Red */
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.3);
}

/* ----- Animations ----- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* ----- Cart & Product Images Additions ----- */
.product-image {
    width: 100%;
    height: 180px;
    background-color: rgba(255,255,255,0.05); /* fallback */
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
}

.qty-btn {
    background: var(--bg-input);
    color: white;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
}

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

.qty-value {
    font-weight: 600;
    width: 20px;
    text-align: center;
}

/* Floating Cart Icon */
.floating-cart {
    position: fixed;
    top: 30px;
    right: 30px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    box-shadow: var(--glass-shadow);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 50;
    transition: var(--transition);
}

.floating-cart:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--secondary);
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cart-badge.pop {
    transform: scale(1.4);
}

/* Cart Side Panel */
.cart-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.cart-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.cart-panel {
    position: fixed;
    top: 0; right: -450px;
    width: 100%; max-width: 400px;
    height: 100vh;
    z-index: 100;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    border-left: 1px solid var(--border-color);
}

.cart-panel.active {
    right: 0;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: white;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-right: 1rem;
}

.cart-items::-webkit-scrollbar {
    width: 6px;
}
.cart-items::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cart-item-img {
    width: 60px; height: 60px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
}

.cart-item-details h4 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.cart-item-price {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.cart-item-total {
    margin-left: auto;
    font-weight: 700;
}

.empty-cart-msg {
    color: var(--text-muted);
    text-align: center;
    margin-top: 2rem;
}

.cart-footer {
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

/* ----- Auth Form Additions ----- */
.auth-wrapper {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.auth-wrapper .glass-panel {
    width: 90%;
    max-width: 400px;
    padding: 2.5rem 2rem;
}

.auth-logo {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.auth-logo span {
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
    background-image: linear-gradient(to right, var(--primary), var(--secondary));
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.mt-4 { margin-top: 1.5rem; }

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-password:hover {
    color: white;
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
    transition: var(--transition);
}

.text-btn:hover {
    color: var(--primary);
}