/* Global Styles */
:root {
    --primary-color: #000000;
    --background-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #1a1a1a;
    --text-secondary: #6e6e73;
    --accent-blue: #e8f0fe;
    --accent-blue-text: #1967d2;
    --border-radius: 16px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --transition: all 0.2s ease;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
    padding: 0;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    transition: all 0.2s ease, transform 0.1s ease;
    /* Added transform transition */
}

.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-danger:active {
    transform: scale(0.96);
    /* Global Click Effect */
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background-color: #efefef;
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: #e0e0e0;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

/* Header */
header {
    background-color: var(--card-bg);
    padding: 15px 0;
    margin-bottom: 40px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0, 0.05);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.5px;
}

.logo-icon {
    width: 35px;
    height: 35px;
    background: linear-gradient(to right, #6a11cb 0%, #2575fc 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(37, 117, 252, 0.3);
}

.logo-icon::after {
    content: 'A';
    color: white;
    font-size: 20px;
    font-weight: bold;
}

.search-bar {
    flex-grow: 1;
    max-width: 480px;
    margin: 0 40px;
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px 12px 45px;
    border-radius: 50px;
    border: 1px solid #e5e5e5;
    font-size: 14px;
    transition: var(--transition);
    background-color: #f5f5f7;
    outline: none;
}

.search-bar input:focus {
    background-color: white;
    border-color: #d1d1d1;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-color);
    transition: var(--transition);
}

.icon-btn:hover {
    color: #000;
    background: #f0f0f0;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.balance {
    background-color: var(--accent-blue);
    color: var(--accent-blue-text);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    /* Added subtle border for definition */
    border: 1px solid rgba(25, 103, 210, 0.1);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: #4f46e5;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 40px;
    padding: 60px 20px;
    background: white;
    border-radius: 20px;
    /* Soft shadow for hero */
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
}

.hero h1 {
    font-size: 42px;
    margin-bottom: 20px;
    letter-spacing: -1px;
}

/* Categories */
.filters {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
    flex-wrap: wrap;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    padding: 12px 32px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.filter-pill:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    /* Soft lift shadow */
}

.filter-pill.active {
    background: #000;
    color: white;
    border-color: #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    font-weight: 600;
}

/* Sub-Category Card Grid */
.category-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.category-card {
    background: white;
    padding: 25px 20px;
    border-radius: 16px;
    border: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #4f46e5, #ec4899);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    border-color: transparent;
}

.category-card:hover::before {
    opacity: 1;
}

.category-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.category-card p {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding-bottom: 40px;
}

.product-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    transition: var(--transition);
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    position: relative;
    /* smooth render */
    backface-visibility: hidden;
    transform: translateZ(0);
}

.product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    border-color: #f0f0f0;
}

.card-image {
    height: 160px;
    background-color: #f1f3f5;
    border-radius: 12px;
    margin-bottom: 16px;
    background-size: cover;
    background-position: center;
}

.product-icon {
    height: 160px;
    background-color: #f8f9fa;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
}

.card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
    line-height: 1.4;
    color: #111;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: break-word;
    /* Fallback for wrapping if not claiming */
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.card-badges {
    display: flex;
    gap: 6px;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge.instant {
    background-color: #ecfdf5;
    color: #059669;
}

.badge.manual {
    background-color: #fffbeb;
    color: #d97706;
}

.badge.verified {
    background-color: #eff6ff;
    color: #2563eb;
}

.badge.stock {
    background-color: #dcfce7;
    color: #166534;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    margin-top: auto;
}

.seller-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.seller-avatar {
    width: 24px;
    height: 24px;
    background-color: #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #6b7280;
    position: relative;
}

.online-dot {
    width: 6px;
    height: 6px;
    background-color: #10b981;
    border: 1px solid white;
    border-radius: 50%;
    position: absolute;
    bottom: -1px;
    right: -1px;
}

.seller-details {
    display: flex;
    flex-direction: column;
}

.seller-name {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.seller-rating {
    font-size: 10px;
    color: #fbbf24;
}

.price-info {
    text-align: right;
}

.price-from {
    display: block;
    font-size: 10px;
    color: #9ca3af;
}

.price-val {
    font-size: 16px;
    font-weight: 700;
    color: #111;
}

/* Footer (Sticky/Bottom) */
footer {
    text-align: center;
    padding: 40px 0;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 60px;
    background: white;
    /* Clean white footer */
    border-top: 1px solid #eee;
}

.footer-icons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    font-size: 24px;
    opacity: 0.5;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.footer-link {
    padding: 8px 16px;
    border: 1px solid #eee;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
}

.footer-link:hover {
    background: #f8f9fa;
    color: var(--primary-color);
    border-color: #ddd;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: #10b981;
}

.toast.error {
    background: #ef4444;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Modals */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(4px);
    /* Frosted glass effect */
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    z-index: 950;
    width: 450px;
    max-width: 90%;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.active {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, -50%) scale(1);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

/* Auth Pages */
.auth-container {
    max-width: 400px;
    margin: 80px auto;
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.auth-title {
    font-size: 24px;
    margin-bottom: 30px;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: #4b5563;
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.btn-full {
    width: 100%;
    padding: 14px;
}

/* Mobile Responsive */
@media (max-width: 992px) {
    header {
        margin-bottom: 20px;
        padding: 15px 0;
        height: auto !important;
    }

    .navbar {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px;
        align-items: center !important;
        /* Center everything */
    }

    .logo {
        justify-content: center;
        margin-bottom: 5px;
        width: 100%;
    }

    .search-bar {
        margin: 10px 0 0 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        order: 3;
    }

    .search-bar input {
        width: 100% !important;
        box-sizing: border-box;
        /* Ensure padding doesn't overflow width */
    }

    .nav-links {
        justify-content: center;
        width: 100%;
        order: 2;
        /* Below search bar */
        gap: 25px;
        margin-bottom: 0px;
    }

    /* Ensure the auth links container inside nav-links handles small screens too */
    #authLinks {
        justify-content: center;
        width: 100%;
        flex-wrap: wrap;
        /* Allow icons to wrap if really needed */
    }

    /* Adjust specific icons */
    .icon-btn,
    .nav-icon-btn {
        font-size: 22px;
        padding: 8px;
    }

    .container {
        padding: 0 20px !important;
    }

    /* Fix table scrolling on mobile */
    .admin-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Wallet Page Overrides */
    #balanceGrid {
        grid-template-columns: 1fr !important;
    }

    .section-box {
        padding: 20px !important;
    }

    /* Profile Header tweaks */
    
    /* Loading Spinner */
    .spinner {
        border: 4px solid #f3f3f3;
        border-top: 4px solid var(--primary-color);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 20px !important;
    }
}


/* Seller Dashboard Styles */
.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
}

.admin-table th {
    text-align: left;
    padding: 16px;
    background: #f8f9fa;
    border-bottom: 2px solid #e5e7eb;
    color: #4b5563;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table td {
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    font-size: 14px;
    color: #1f2937;
    background: white;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: #fcfcfc;
}

/* Rounded corners for table */
.admin-table tr:first-child th:first-child {
    border-top-left-radius: 12px;
}

.admin-table tr:first-child th:last-child {
    border-top-right-radius: 12px;
}

.admin-table tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}

.admin-table tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
}

/* Form Styles Override for specificity */
.form-input,
select.form-input,
textarea.form-input {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    box-sizing: border-box;
}

.form-input:focus {
    background-color: white;
    border-color: #000;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
    outline: none;
}

.stock-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

/* =========================================
   MEGA MENU STYLES
   ========================================= */

.mega-menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    color: #111;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.03);
    margin: 0 auto; /* Center it */
}

.mega-menu-btn:hover, .mega-menu-btn.active {
    background: #000;
    color: white;
    border-color: #000;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.mega-menu-btn:hover .dot, .mega-menu-btn.active .dot {
    background-color: white;
}

/* Grid Icon (4 dots) */
.grid-icon {
    display: grid;
    grid-template-columns: repeat(2, 4px);
    gap: 3px;
}

.dot {
    width: 4px;
    height: 4px;
    background-color: #111;
    border-radius: 50%;
    transition: background-color 0.3s;
}

/* Dropdown Container */
.mega-menu-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 900px;
    max-width: 95vw;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.03);
    display: flex; /* Two columns */
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 1000;
}

.mega-menu-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Sidebar (Left) */
.mega-sidebar {
    width: 280px;
    background: #fafafa;
    border-right: 1px solid #eee;
    padding: 20px 0;
    flex-shrink: 0;
    max-height: 500px;
    overflow-y: auto;
}

.mega-sidebar-item {
    padding: 14px 25px;
    font-size: 15px;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.mega-sidebar-item:hover, .mega-sidebar-item.active {
    background: white;
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--primary-color); /* Left accent bar */
}

.mega-sidebar-item .arrow {
    font-size: 12px;
    opacity: 0;
    transform: translateX(-5px);
    transition: all 0.2s;
}

.mega-sidebar-item:hover .arrow, .mega-sidebar-item.active .arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Content Area (Right) */
.mega-content {
    flex-grow: 1;
    padding: 30px;
    background: white;
    max-height: 500px;
    overflow-y: auto;
}

.mega-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.mega-sub-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    text-decoration: none;
    color: #374151;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.mega-sub-item:hover {
    background: #f8f9fa;
    border-color: #e5e7eb;
    transform: translateY(-2px);
    color: #000;
}

.mega-sub-icon {
    width: 32px;
    height: 32px;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.mega-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    text-align: center;
}

/* Mobile Responsive for Mega Menu */
@media (max-width: 768px) {
    .mega-menu-dropdown {
        position: fixed;
        top: 0;
        left: 0;
        transform: none;
        width: 100%;
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
        flex-direction: column;
        z-index: 2000;
    }

    .mega-menu-dropdown.active {
        transform: none;
    }

    .mega-sidebar {
        width: 100%;
        height: 40%;
        border-right: none;
        border-bottom: 1px solid #eee;
    }

    .mega-content {
        height: 60%;
    }

    /* Add a close button for mobile */
    .mega-menu-dropdown::before {
        content: '×';
        position: absolute;
        top: 10px;
        right: 15px;
        font-size: 32px;
        color: #333;
        z-index: 2001;
        cursor: pointer;
    }
}