@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-color: #343a40;
    --light-gray: #e9ecef;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --shadow: 0 8px 25px rgba(0, 0, 0, 0.08); 
    --border-radius: 12px;
}

html {
    scroll-behavior: smooth; 
    font-size: 100%; 
}

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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 
                 Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- General Links --- */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 99%;
    margin: 20px auto;
    padding: 20px 15px; 
}

.auth-container {
    max-width: 450px; 
    margin: 40px auto;
    padding: 0 15px; 
}

.auth-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.card {
    background: var(--surface-color);
    border: 1px solid var(--light-gray);
    padding: 24px; 
    border-radius: var(--border-radius);
    margin: 16px 0;
    box-shadow: var(--shadow); 
}

#cart-section{
    background-color: #e3efee;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 16px;
    border: 1px solid #2209ff;
    border-radius: 8px;
    font-family: inherit; 
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}

.btn,
button {
    display: inline-block;
    padding: 12px 16px;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-family: inherit; /* MODIFIED: Inherit from body */
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(45deg, var(--primary-color), #0056b3);
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
    text-align: center;
    text-decoration: none; /* For <a> tags */
}

.btn:hover,
button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 123, 255, 0.35);
    text-decoration: none;
    color: #fff;
}

.btn:active,
button:active {
    transform: translateY(0);
}

#rmbtn{
    color: red;
    margin-right: 10px;
    width: 10%;
    background:transparent;
    border:none;
    cursor:pointer;
}

/* FIX: Makes form buttons full-width inside cards */
.card .btn {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
}

.card button {
    width: 20%;
    padding: 10px;
    font-size: 1.1rem;
}

#placeOrderBtn {
    width: 40%;
    padding: 10px;
    font-size: 1.1rem;
}

#cancelEditBtn{
    display: none;
    width:20%;
    margin-left: 10px;
    background-color: #6c7d6e;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px; 
    margin-bottom: 20px;
    border-bottom: 1px solid var(--light-gray);
    border-radius: 10px;
    flex-wrap: wrap; 
    gap: 15px;
}

.header h2 {
    font-size: 1.875rem; 
    font-weight: 600;
    color: var(--primary-color);
    flex-shrink: 0;
    margin: 0;
}

.header > div {
    display: flex;
    align-items: center;
    flex-wrap: wrap; 
    gap: 8px; 
    justify-content: flex-end;
    flex-grow: 1;
}

#user-links {
    display: inline-flex; 
    align-items: center;
    gap: 8px; 
}

.header a {
    text-decoration: none;
    color: var(--secondary-color);
    margin-left: 0; 
    font-weight: 500;
    transition: color 0.3s ease, background-color 0.3s ease;
    padding: 6px 10px; 
    border-radius: 6px;
}

.header a:hover {
    color: var(--primary-color);
    background-color: var(--light-gray);
    text-decoration: none;
}

#logout-btn {
    color: var(--danger-color);
    font-weight: bold;
}

#logout-btn:hover {
    color: var(--danger-color);
    background-color: rgba(220, 53, 69, 0.1); /* Faint red on hover */
}

.products {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.product-card {
    border: 1px solid var(--light-gray);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    background: #fff;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.product-card h3 {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.product-card p {
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.small {
    font-size: 0.9em;
    color: var(--secondary-color);
}

.rainbow {
    background: linear-gradient(
        90deg, 
        var(--primary-color), 
        #00ffc8, 
        var(--success-color), 
        var(--primary-color)
    );
    background-size: 200% auto; 
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradient-flow 8s linear infinite;
}

@keyframes gradient-flow {
  0% { background-position: 200% center; }
  100% { background-position: 0% center; }
}

.rainbow-header {
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--light-gray);
}
.rainbow-header h1 {
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}
.rainbow-header h2 {
    font-size: 1.5rem;
    font-weight: 500;
}

/* @media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #3498db;
        --primary-hover: #5dade2;
        --secondary-color: #95a5a6; 
        --background-color: #121212; 
        --surface-color: #1e1e1e; 
        --text-color: #ecf0f1; 
        --light-gray: #343a40; 
        --success-color: #2ecc71;
        --danger-color: #e74c3c;
        --shadow: 0 8px 25px rgba(0, 0, 0, 0.4); 
    }

    input,
    select,
    textarea {
        background-color: #2c2c2c;
        border-color: #444;
        color: var(--text-color);
    }
    
    .product-card {
        background-color: var(--surface-color);
        border-color: var(--light-gray);
    }

    .header a:hover {
        background-color: #2c2c2c;
    }

    #logout-btn:hover {
        background-color: rgba(231, 76, 60, 0.15); 
    }
} */

/* --- 2. Mobile Responsiveness for Header & Fonts --- */
@media (max-width: 600px) {
    
    .container {
    max-width: 98%;
    margin: 20px auto;
    padding: 20px 15px; 
    }

    .header {
        flex-direction: column; /* Stack title and links */
        align-items: flex-start; /* Align all to the left */
    }
    
    .header > div {
        justify-content: flex-start; /* Align links to the left */
        width: 100%; /* Make link container full width */
    }

    /* Ensure rainbow headers aren't too large */
    .rainbow-header h1 {
        font-size: 2.2rem;
    }
    .rainbow-header h2 {
        font-size: 1.2rem;
    }

    /* NEW: Scale down auth title on mobile */
    .auth-title {
        font-size: 1.75rem;
    }
    
    /* NEW: Reduce card padding on small screens */
    .card {
        padding: 20px 15px;
    }

    #placeOrderBtn {
    width: 60%;
    padding: 5px;
    font-size: 15px;
    }

    #cancelEditBtn{
       width:30%;
       font-size: 15px;
       padding: 5px;
    }
}

/* --- Loading Spinner Styles --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--light-gray);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-container {
    text-align: center;
}

.loading-container p {
    margin-top: 15px;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 1.1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

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