/* ==========================================================================
   Global Resets & Typography
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==========================================================================
   Common Layout Elements (Header, Footer, Helpers)
   ========================================================================== */
header {
    background-color: #223355;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.logo a {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
}

footer {
    text-align: center;
    padding: 20px;
    background-color: #333;
    color: #888;
    margin-top: 40px;
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
    display: flex;
    gap: 20px;
    flex-direction: column;
    flex: 1; /* Pushes the footer down */
    width: 100%;
}

.flex-center {
    display: flex;
    align-items: center;
}

/* ==========================================================================
   BUTTON
   ========================================================================== */
/* Base Button Style */
.admin-btn, .cart-btn, .add-btn, .checkout-btn, .submit-btn, .delete-btn, .login-btn, .btn-warning {
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    color: white;
    transition: background-color 0.2s, transform 0.1s;
    font-family: inherit;
    display: inline-block;
    text-align: center;
}

/* Button Active "Click" Effect for all */
.admin-btn:active, .cart-btn:active, .add-btn:active, .checkout-btn:active, .submit-btn:active, .delete-btn:active, .login-btn:active, .btn-warning:active {
    transform: translateY(2px);
}

/* --- Color Variants --- */
/* Primary Blue (Add to Cart, Login) */
.add-btn, .login-btn { background-color: #0077ff; }
.add-btn:hover, .login-btn:hover { background-color: #0055bb; }

/* Secondary Orange (Admin, Cart Header) */
.admin-btn, .cart-btn { background-color: #ee7722; }
.admin-btn:hover, .cart-btn:hover { background-color: #d66a1d; }

/* Success Green (Submit, Checkout) */
.submit-btn, .checkout-btn { background-color: #27ae60; }
.submit-btn:hover, .checkout-btn:hover { background-color: #219150; }

/* Danger Red (Delete) */
.delete-btn { background-color: #e74c3c; }
.delete-btn:hover { background-color: #c0392b; }

/* Warning Yellow (Edit) */
.btn-warning { background-color: #f39c12; color: #fff; }
.btn-warning:hover { background-color: #d68910; }

/* --- Specific Overrides (Layout & Sizing) --- */
.admin-btn, .cart-btn, .delete-btn, .btn-warning { margin-right: 10px; }
.add-btn { width: 100%; padding: 8px 15px; margin-top: auto; }
.checkout-btn, .login-btn { width: 100%; margin-top: 10px; padding: 12px; }
.submit-btn { margin-bottom: 20px; }

/* ==========================================================================
   1. INDEX PAGE (index.html)
   ========================================================================== */

/* Breadcrumbs for navigation trail */
.breadcrumbs {
    background-color: #e9ecef;
    padding: 0.8rem 2rem;
    font-size: 0.9rem;
    border-bottom: 1px solid #ddd;
}

.breadcrumbs a {
    text-decoration: none;
    color: #0077ff;
}

.breadcrumbs .current {
    color: #667777;
}

/* The horizontal category bar */
.category-nav {
    background-color: #e9ecef;
    width: 100%;
    border-bottom: 1px solid #ddd;
}

.category-list {
    display: flex;
    flex-wrap: nowrap;
    list-style: none;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.category-list li {
    flex: 1;
    text-align: center;
}

.category-list a {
    display: block;
    padding: 15px 0;
    text-decoration: none;
    color: #555;
    font-weight: bold;
    background-color: #e9ecef;
    transition: background-color 0.2s;
}

.category-list a:hover {
    background-color: #dfe6ed;
}

.category-list a.active {
    background-color: #ffffff;
    color: #0077ff;
    border-bottom: 3px solid #0077ff;
}

/* The actual product grid */
.product-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: flex-start;
}

.product-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: calc(33.333% - 14px);
    padding: 15px;
    text-align: center;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-link {
    text-decoration: none;
    color: inherit;
    display: block;
    width: 100%;
}

.thumbnail {
    max-width: 100%;
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: #f8f8f8;
    margin-bottom: 10px;
    border-radius: 3px;
    display: block;
}

.price {
    color: #ee4433;
    font-weight: bold;
    margin: 10px 0;
}

/* The hover shopping cart widget */
.cart-container {
    position: relative;
    z-index: 100;
}

.cart-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 300px;
    background-color: white;
    color: #333;
    border: 1px solid #ddd;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 3px;
    z-index: 1000;
}

.cart-container:hover .cart-dropdown { display: block; }

.cart-items {
    list-style: none;
    margin: 10px 0;
}

.cart-items li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.cart-items input {
    width: 40px;
    padding: 3px;
}

.cart-empty-msg {
    padding: 10px;
    color: #777;
}

.loading-text {
    padding: 20px;
}

/* ==========================================================================
   2. PRODUCT DETAIL PAGE (product.html)
   ========================================================================== */
.product-detail-container {
    background: white;
    padding: 30px;
    border-radius: 5px;
    flex-direction: row;
    display: flex;
}

.product-images {
    flex: 1;
    min-width: 0;
}

/* Image gallery and thumbnails */
.slider-main {
    width: 100%;
    height: 400px;
    background-color: #fff;
    border: 1px solid #eee;
    margin-bottom: 15px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.slider-main img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.slider-thumbs {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.thumb-item {
    width: 60px;
    height: 60px;
    border: 1px solid #ddd;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
    border-radius: 3px;
    overflow: hidden;
}

.thumb-item:hover, .thumb-item.active {
    opacity: 1;
    border-color: #ee7722;
    border-width: 2px;
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Product info area right next to the slider */
.product-info {
    flex: 1;
    padding-left: 30px;
}

.price-large {
    font-size: 2rem;
    color: #ee4433;
    margin: 15px 0;
}

.purchase-controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

#p-desc {
    white-space: pre-wrap; 
}

/* ==========================================================================
   3. ADMIN PANEL (admin.html)
   ========================================================================== */

/* Quick toggle buttons located in the header */
.admin-container {
    position: relative;
    z-index: 100;
}

/* Admin main dashboard wrapper */
body > .admin-container { 
    margin: 30px auto; 
    max-width: 1000px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: block; 
    width: 95%; /* Make it squeeze nicely on smaller screens */
}

/* Generic forms for adding products & categories */
.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; }
.form-group input, 
.form-group select, 
.form-group textarea { 
    width: 100%; 
    padding: 8px; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    font-family: inherit;
}

/* Admin data tables */
table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 30px; 
}

th, td { 
    border: 1px solid #ddd; 
    padding: 10px; 
    text-align: left; 
}

th { background: #f4f4f4; }

.admin-thumb-img {
    height: 50px;
}

.section-divider {
    margin: 40px 0;
    border: 0;
    border-top: 1px solid #ddd;
}

/* Modals for editing entries and changing passwords */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.5); 
}

.modal-content {
    background-color: white;
    margin: 15% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 400px;
    border-radius: 8px;
}

.close, .close-edit {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover, .close-edit:hover { color: black; }

/* Spacing overrides for specific admin areas */
#add-category-form { margin-bottom: 20px; }
#category-table { margin-bottom: 40px; }
#change-pwd-form { margin-top: 15px; }
#change-pwd-form .submit-btn { width: 100%; margin-bottom: 0; }

/* ==========================================================================
   4 & 5. AUTH PAGES (login.html & register.html)
   ========================================================================== */

/* We use the same container structure for both login and register screens */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.login-container h2 { 
    margin-bottom: 20px; 
    color: #2c3e50; 
}

/* Just a slight color variation for the register page to tell them apart visually */

.error-msg { 
    color: #e74c3c; 
    margin-top: 15px; 
    display: none; 
}

.links { 
    margin-top: 15px; 
    font-size: 0.9rem; 
}
