/* ========== GLOBAL VARIABLES ========== */
:root {
    --primaryLight_color: #3498db;
    --secondaryLight_color: #ff6b6b;
    --primaryDark_color: #3b82f6;
    --secondaryDark_color: #8b5cf6;
    --bg-body-light: #f8fafc;
    --bg-surface-light: #ffffff;
    --text-primary-light: #0f172a;
    --text-secondary-light: #475569;
    --border-light-light: #e2e8f0;
    --input-bg-light: #f1f5f9;
    
    --bg-body-dark: #121212;
    --bg-surface-dark: #1e293b;
    --text-primary-dark: #f1f5f9;
    --text-secondary-dark: #cbd5e1;
    --border-light-dark: #334155;
    --input-bg-dark: #334155;
}

/* Light Theme (default) */
body {
    --primary-color: var(--primaryLight_color);
    --secondary-color: var(--secondaryLight_color);
    --bg-body: var(--bg-body-light);
    --bg-surface: var(--bg-surface-light);
    --text-primary: var(--text-primary-light);
    --text-secondary: var(--text-secondary-light);
    --border-light: var(--border-light-light);
    --card-shadow: 0 2px 10px rgba(0,0,0,0.05);
    --navbar-bg: rgba(255,255,255,0.98);
    --navbar-border: rgba(0,0,0,0.05);
    --dropdown-bg: #ffffff;
    --input-bg: var(--input-bg-light);
    --transition: all 0.3s ease;
}

/* Dark Theme */
body.dark-mode {
    --primary-color: var(--primaryDark_color);
    --secondary-color: var(--secondaryDark_color);
    --bg-body: var(--bg-body-dark);
    --bg-surface: var(--bg-surface-dark);
    --text-primary: var(--text-primary-dark);
    --text-secondary: var(--text-secondary-dark);
    --border-light: var(--border-light-dark);
    --card-shadow: 0 2px 10px rgba(0,0,0,0.3);
    --navbar-bg: rgba(30,41,59,0.98);
    --navbar-border: rgba(255,255,255,0.05);
    --dropdown-bg: #1e293b;
    --input-bg: var(--input-bg-dark);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background 0.2s, color 0.2s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========== NAVBAR ========== */
.navbar {
    background: var(--navbar-bg);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--navbar-border);
}

.navbar-brand {
    color: var(--text-primary) !important;
}

/* Theme toggle */
.theme-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    padding: 0.3rem 0.8rem;
    border-radius: 40px;
    cursor: pointer;
}
.theme-switch i { 
    font-size: 1rem; 
    color: var(--text-secondary);
    pointer-events: none;
}
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    cursor: pointer;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--primary-color);
}
input:checked + .slider:before {
    transform: translateX(24px);
}

/* Stock badge */
.price-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}
.product-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}
.stock-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 600;
}
.bg-success { background: #22c55e !important; color: white; }
.bg-warning { background: #f59e0b !important; color: #1f2937; }
.bg-danger { background: #ef4444 !important; color: white; }

/* Product card */
.product-card {
    background: var(--bg-surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.25s, box-shadow 0.25s;
    cursor: pointer;
    height: 100%;
}
.product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 30px -12px rgba(0,0,0,0.15);
}
.card-img-top.product-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    background: var(--input-bg);
}
.card-body {
    background: var(--bg-surface);
}
.card-title {
    color: var(--text-primary);
}
.card-text {
    color: var(--text-secondary);
}

/* Dropdown styles */
.dropdown-menu {
    background: var(--dropdown-bg);
    border: 1px solid var(--border-light);
}
.dropdown-item {
    color: var(--text-secondary);
}
.dropdown-item:hover {
    background: var(--input-bg);
    color: var(--primary-color);
}
.dropdown-submenu {
    position: relative;
}
.dropdown-submenu .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -0.5rem;
    margin-left: 0.25rem;
}
.dropdown-submenu:hover .dropdown-menu {
    display: block;
}

/* Breadcrumb */
.breadcrumb {
    background: var(--bg-surface);
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}
.breadcrumb span, .breadcrumb .container {
    color: var(--text-secondary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0 3rem;
}
.pagination .page-link {
    padding: 0.5rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}
.pagination .page-link:hover {
    background: var(--primary-color);
    color: white;
}
.pagination .active .page-link {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.pagination .disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Offcanvas cart */
.offcanvas {
    background: var(--bg-surface);
}
.offcanvas-header, .offcanvas-body {
    background: var(--bg-surface);
    color: var(--text-primary);
}
.offcanvas-title {
    color: var(--text-primary);
}
.table {
    color: var(--text-primary);
}
.btn-close {
    filter: invert(1);
}

/* ========== CART OFF CANVAS WIDTH FIX ========== */
.offcanvas-end {
    width: 450px !important;
    max-width: 90vw !important;
}

@media (min-width: 768px) {
    .offcanvas-end {
        width: 500px !important;
    }
}

@media (min-width: 1200px) {
    .offcanvas-end {
        width: 550px !important;
    }
}

/* Cart table responsive fixes */
.offcanvas-body .table {
    min-width: 400px;
}

.offcanvas-body .table td,
.offcanvas-body .table th {
    white-space: nowrap;
    padding: 12px 8px;
}

.offcanvas-body .table td:first-child,
.offcanvas-body .table th:first-child {
    min-width: 180px;
    white-space: normal;
}

/* Delete button styling */
.offcanvas-body .btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Cart item image */
.cart-item-image {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: 8px;
}

/* Buttons */
.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}
.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}
.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}
.btn-primary:hover {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* Product Detail Page */
.product-detail-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    background: var(--bg-surface);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.product-detail-image {
    background: var(--input-bg);
    padding: 40px;
    text-align: center;
}
.product-detail-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}
.product-detail-info {
    padding: 40px 40px 40px 0;
}
.product-detail-title {
    font-size: 2em;
    margin-bottom: 15px;
    color: var(--text-primary);
}
.product-detail-price {
    font-size: 2em;
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 20px;
}
.product-detail-description {
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 30px;
}
.product-meta {
    background: var(--input-bg);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}
.product-meta p {
    margin: 10px 0;
    color: var(--text-secondary);
}
.stock-status-detail {
    display: inline-block;
    padding: 8px 15px;
    border-radius: 25px;
    font-weight: bold;
    margin-top: 10px;
}
.btn-buy-now {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.1em;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s;
}
.btn-buy-now:hover:not(:disabled) {
    background: var(--secondary-color);
    transform: scale(1.02);
}
.btn-buy-now:disabled {
    background: #ccc;
    cursor: not-allowed;
}
.back-to-shop {
    display: inline-block;
    margin-top: 20px;
    color: var(--primary-color);
    text-decoration: none;
}

/* Admin Panel Styles */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}
.admin-sidebar {
    width: 280px;
    background: #2c3e50;
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #34495e;
}
.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: background 0.3s;
}
.sidebar-nav li a:hover, .sidebar-nav li.active a {
    background: #34495e;
}
.logout-form {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    padding: 20px;
}
.logout-form button {
    width: 100%;
    padding: 10px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.admin-content {
    margin-left: 280px;
    flex: 1;
    padding: 20px;
    background: var(--bg-body);
}
.admin-header {
    background: var(--bg-surface);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.stat-card {
    background: var(--bg-surface);
    padding: 25px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.stat-card i {
    font-size: 48px;
    color: var(--primary-color);
}
.stat-info h3 {
    font-size: 32px;
    margin: 0;
    color: var(--text-primary);
}
.stat-info p {
    margin: 5px 0 0;
    color: var(--text-secondary);
}
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}
.action-btn {
    background: var(--bg-surface);
    padding: 15px;
    text-align: center;
    text-decoration: none;
    color: var(--primary-color);
    border-radius: 8px;
    transition: all 0.3s;
    border: 1px solid var(--border-light);
}
.action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-primary);
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: 5px;
    background: var(--bg-surface);
    color: var(--text-primary);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.success {
    background: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
}
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
}
.warning-box {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
}
.products-table {
    overflow-x: auto;
}
.products-table table {
    width: 100%;
    background: var(--bg-surface);
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
}
.products-table th, .products-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.products-table th {
    background: var(--input-bg);
    font-weight: bold;
}
.edit-product-btn, .delete-btn, .regenerate-btn, .view-page-btn {
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    margin: 2px;
    display: inline-block;
    text-decoration: none;
    border: none;
}
.edit-product-btn { background: #4CAF50; color: white; }
.delete-btn { background: #f44336; color: white; }
.regenerate-btn { background: #ff9800; color: white; }
.view-page-btn { background: #2196F3; color: white; text-decoration: none; }
.product-image-preview {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
}
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}
.modal-content {
    background-color: var(--bg-surface);
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.modal-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header .close {
    color: white;
    font-size: 28px;
    cursor: pointer;
}
.modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}
.modal-footer {
    padding: 15px 25px;
    background: var(--input-bg);
    border-radius: 0 0 10px 10px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.btn-cancel {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
}
.markup-badge {
    background: #ff9800;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    margin-left: 10px;
}
.price-preview {
    background: #e8f5e9;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    border-left: 4px solid #4caf50;
}
.empty-state {
    text-align: center;
    padding: 40px;
    background: var(--input-bg);
    border-radius: 8px;
}
.main-category-card {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
}
.category-header-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: var(--bg-surface);
}
.category-content {
    padding: 10px;
    background: var(--input-bg);
}
.sub-category {
    margin-left: 30px;
    margin-top: 10px;
    border-left: 2px solid var(--border-light);
    padding-left: 15px;
}
.product-group-card {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    background: var(--bg-surface);
}
.product-group-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.product-group-header h3 {
    margin: 0;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.product-group-header .toggle-icon {
    transition: transform 0.3s;
    margin-right: 10px;
}
.product-group-header .toggle-icon.collapsed {
    transform: rotate(-90deg);
}
.product-group-header .product-count {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85em;
}
.product-group-content {
    overflow-x: auto;
}
.product-group-content.collapsed {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }
    .admin-content {
        margin-left: 0;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .product-detail-container {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .product-detail-info {
        padding: 20px;
    }
}

/* Cart item image styling */
.cart-item-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--input-bg);
}

/* Cart table cell spacing */
.offcanvas-body .table td {
    vertical-align: middle;
    padding: 12px 8px;
}

/* Responsive cart adjustments */
@media (max-width: 576px) {
    .offcanvas-end {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .offcanvas-body .table td,
    .offcanvas-body .table th {
        padding: 8px 4px;
        font-size: 13px;
    }
    
    .cart-item-image {
        width: 40px;
        height: 40px;
    }
    
    .offcanvas-body .btn-sm {
        padding: 4px 8px;
    }
}

/* ========== SIMPLE CLEAN FOOTER ========== */
.footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
    padding: 10px 0 20px;
    margin-top: 60px;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-light);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-brand h3 {
    font-size: 1.2rem;
    margin: 0;
    color: var(--text-primary);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.footer-payment {
    display: flex;
    gap: 15px;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.footer-payment i {
    transition: transform 0.2s;
}

.footer-payment i:hover {
    transform: scale(1.1);
    color: var(--primary-color);
}

.footer-social {
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}

.footer-social a {
    
    width: 36px;
    height: 36px;
    background: var(--input-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.footer-social a:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    text-decoration: none;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding-top: 25px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.footer-bottom a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-bottom a:hover {
    color: var(--primary-color);
    text-decoration: none;
}
.footer a:where(:not(.btn)) {
    text-decoration: none !important;
}

.footer a:where(:not(.btn)):hover {
    text-decoration: none !important;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 999;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--secondary-color);
    transform: translateY(-3px);
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
    }
}