/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #e2e8f0;
    --gray-dark: #94a3b8;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 15px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--dark);
    background: var(--light);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.main-content { flex: 1; padding: 30px 0; }

/* === Header === */
.site-header {
    background: white;
    border-bottom: 1px solid var(--gray);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 65px; }
.logo img { height: 40px; }
.logo-text { font-size: 1.5rem; font-weight: 700; color: var(--dark); }
.logo:hover { text-decoration: none; }
.main-nav { display: flex; gap: 25px; align-items: center; }
.main-nav a { color: var(--secondary); font-weight: 500; padding: 5px 0; border-bottom: 2px solid transparent; }
.main-nav a:hover, .main-nav a.active { color: var(--primary); border-bottom-color: var(--primary); text-decoration: none; }
.mobile-menu-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; }
.cart-badge { background: var(--danger); color: white; border-radius: 10px; padding: 1px 7px; font-size: 0.75rem; margin-left: 2px; vertical-align: top; }

/* === Footer === */
.site-footer { background: var(--dark); color: white; text-align: center; padding: 20px 0; margin-top: auto; }
.site-footer p { opacity: 0.8; font-size: 0.9rem; }

/* === Alerts === */
.alert { padding: 12px 16px; border-radius: var(--radius); margin: 15px 0; font-size: 0.95rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* === Buttons === */
.btn {
    display: inline-block; padding: 10px 20px; border-radius: var(--radius);
    font-size: 0.95rem; font-weight: 500; cursor: pointer; border: none;
    transition: background 0.2s, transform 0.1s; text-align: center;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }

/* === Forms === */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; color: var(--dark); }
.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid var(--gray);
    border-radius: var(--radius); font-size: 0.95rem; transition: border-color 0.2s;
    font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* === Cards === */
.card {
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden; transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-img { width: 100%; height: 200px; object-fit: cover; background: var(--gray); }
.card-body { padding: 16px; }
.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.card-price { color: var(--primary); font-weight: 700; font-size: 1.15rem; }
.card-vendor { color: var(--secondary); font-size: 0.85rem; margin-top: 5px; }
.card-delivery { color: var(--gray-dark); font-size: 0.85rem; }

/* === Products Grid === */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
.product-card a { color: inherit; }
.product-card a:hover { text-decoration: none; }
.no-photo { display: flex; align-items: center; justify-content: center; height: 200px; background: var(--gray); color: var(--gray-dark); font-size: 3rem; }

/* === Hero Banner === */
.hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; text-align: center; padding: 80px 20px; margin-bottom: 40px;
    background-size: cover; background-position: center; position: relative;
}
.hero.has-banner::before {
    content: ''; position: absolute; inset: 0;
    background: rgba(0,0,0,0.45);
}
.hero-content { position: relative; z-index: 1; }
.hero h1 { font-size: 2.5rem; margin-bottom: 12px; }
.hero p { font-size: 1.2rem; opacity: 0.9; }

/* === Vendors List === */
.vendors-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.vendor-card { text-align: center; padding: 30px 20px; }
.vendor-card:hover { text-decoration: none; }
.vendor-avatar {
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--primary); color: white; display: flex;
    align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700; margin: 0 auto 15px;
}
.vendor-avatar-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; margin: 0 auto 15px; display: block; }
.vendor-name { font-size: 1.1rem; font-weight: 600; color: var(--dark); }
.vendor-count { color: var(--secondary); font-size: 0.9rem; margin-top: 5px; }

/* === Product Detail === */
.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.product-gallery { display: flex; flex-direction: column; gap: 10px; }
.product-main-img { width: 100%; height: 400px; object-fit: cover; border-radius: var(--radius); background: var(--gray); }
.product-thumbs { display: flex; gap: 10px; }
.product-thumbs img { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 2px solid transparent; }
.product-thumbs img.active, .product-thumbs img:hover { border-color: var(--primary); }
.product-info h1 { font-size: 1.8rem; margin-bottom: 15px; }
.product-info .price { font-size: 1.5rem; color: var(--primary); font-weight: 700; margin-bottom: 15px; }
.product-info .delivery { color: var(--secondary); margin-bottom: 15px; }
.product-info .description { margin-bottom: 20px; line-height: 1.7; }
.product-vendor-link { display: inline-flex; align-items: center; gap: 10px; padding: 10px 15px; background: var(--light); border-radius: var(--radius); }

/* === Search & Filters === */
.filters-bar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    margin-bottom: 30px; padding: 20px; background: white;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.filters-bar .form-control { width: auto; flex: 0 1 200px; }
.filters-bar select.form-control { flex: 1 1 220px; }
.filters-bar .btn { flex: 0; white-space: nowrap; }

/* === Pagination === */
.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 30px; }
.pagination a, .pagination span {
    padding: 8px 14px; border-radius: var(--radius);
    border: 1px solid var(--gray); color: var(--dark); font-size: 0.9rem;
}
.pagination a:hover { background: var(--primary); color: white; border-color: var(--primary); text-decoration: none; }
.pagination .current { background: var(--primary); color: white; border-color: var(--primary); }

/* === Contact Form === */
.contact-page { max-width: 700px; margin: 0 auto; }
.contact-page h1 { margin-bottom: 10px; }
.contact-page .intro { color: var(--secondary); margin-bottom: 30px; }

/* === Login === */
.login-page { max-width: 420px; margin: 60px auto; }
.login-box { background: white; padding: 35px; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.login-box h1 { text-align: center; margin-bottom: 25px; }
.password-rules { background: var(--light); border: 1px solid var(--gray); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; font-size: 0.85rem; color: var(--secondary); }
.password-rules p { font-weight: 600; margin-bottom: 6px; color: var(--dark); }
.password-rules ul { margin: 0; padding-left: 20px; }
.password-rules li { margin-bottom: 2px; }

/* === Section Titles === */
.section-title { font-size: 1.6rem; margin-bottom: 25px; }
.section-subtitle { color: var(--secondary); margin-bottom: 30px; }

/* === Table === */
.table-responsive { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.table th, table.table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--gray); }
table.table th { background: var(--light); font-weight: 600; font-size: 0.9rem; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.5px; }
table.table tr:last-child td { border-bottom: none; }
table.table tr:hover td { background: #f8fafc; }

/* === Page Header === */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; flex-wrap: wrap; gap: 10px; }

/* === Reports === */
.report-filters { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 20px; }
.report-period-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.report-tab {
    padding: 7px 16px; border-radius: 20px; font-size: 0.88rem; font-weight: 500;
    background: var(--light); color: var(--secondary); border: 1px solid var(--gray);
    transition: all 0.2s;
}
.report-tab:hover { background: var(--primary); color: white; border-color: var(--primary); text-decoration: none; }
.report-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.report-custom-period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.report-custom-period label { font-size: 0.88rem; color: var(--secondary); }
.report-custom-period .form-control { width: auto; padding: 6px 10px; font-size: 0.88rem; }
.report-period-label { color: var(--secondary); margin-bottom: 20px; font-size: 0.95rem; }
.report-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 30px; }
.report-stat-card {
    display: flex; align-items: center; gap: 16px;
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; border-left: 4px solid var(--gray);
}
.report-stat-card--blue { border-left-color: #3b82f6; }
.report-stat-card--green { border-left-color: #22c55e; }
.report-stat-card--orange { border-left-color: #f59e0b; }
.report-stat-card--purple { border-left-color: #8b5cf6; }
.report-stat-card-icon { font-size: 1.8rem; flex: 0 0 auto; }
.report-stat-card-content { flex: 1; }
.report-stat-card-value { font-size: 1.6rem; font-weight: 700; color: var(--dark); line-height: 1.2; }
.report-stat-card-label { font-size: 0.82rem; color: var(--secondary); margin-top: 2px; }
.report-section { margin-top: 30px; }
.report-section h2 { font-size: 1.25rem; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--gray); }
.report-empty { color: var(--gray-dark); font-style: italic; }
.report-products { display: flex; flex-direction: column; gap: 10px; }
.report-product-card {
    display: flex; align-items: center; gap: 16px;
    background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px;
}
.report-product-photo { flex: 0 0 60px; }
.report-product-photo img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius); }
.report-product-nophoto {
    width: 60px; height: 60px; border-radius: var(--radius); background: var(--gray);
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--gray-dark);
}
.report-product-info { flex: 1; min-width: 0; }
.report-product-info h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-product-price { font-size: 0.85rem; color: var(--primary); font-weight: 600; }
.report-product-stats { display: flex; gap: 20px; flex: 0 0 auto; }
.report-stat { text-align: center; min-width: 65px; }
.report-stat-value { display: block; font-size: 1.15rem; font-weight: 700; color: var(--dark); }
.report-stat-label { display: block; font-size: 0.72rem; color: var(--gray-dark); text-transform: uppercase; letter-spacing: 0.3px; }
.report-requests { display: flex; flex-direction: column; gap: 10px; }
.report-request-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; }
.report-request-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.report-request-date { font-size: 0.82rem; color: var(--gray-dark); }
.report-request-body { display: flex; gap: 24px; flex-wrap: wrap; }
.report-request-detail { font-size: 0.9rem; }
.report-request-label { font-size: 0.75rem; color: var(--gray-dark); text-transform: uppercase; letter-spacing: 0.3px; display: block; }

/* === Vendor Panel Products === */
.vp-products { display: flex; flex-direction: column; gap: 10px; }
.vp-product {
    display: flex; align-items: center; gap: 16px;
    background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px;
}
.vp-product-photo { flex: 0 0 56px; }
.vp-product-photo img {
    width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius);
    cursor: pointer; transition: opacity 0.2s;
}
.vp-product-photo img:hover { opacity: 0.8; }
.vp-product-nophoto {
    width: 56px; height: 56px; border-radius: var(--radius); background: var(--gray);
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem; color: var(--gray-dark);
}
.vp-product-info { flex: 1; min-width: 0; }
.vp-product-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-product-meta { display: flex; gap: 16px; font-size: 0.82rem; color: var(--secondary); flex-wrap: wrap; }
.vp-product-price { color: var(--primary); font-weight: 600; }
.vp-product-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* Lightbox */
.lightbox {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.8); align-items: center; justify-content: center;
    cursor: pointer;
}
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); object-fit: contain; }

/* === Cart === */
.cart-items { display: flex; flex-direction: column; gap: 12px; }
.cart-item {
    display: flex; align-items: center; gap: 20px;
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px 20px;
}
.cart-item-photo { flex: 0 0 80px; }
.cart-item-photo img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius); }
.cart-item-nophoto {
    width: 80px; height: 80px; border-radius: var(--radius); background: var(--gray);
    display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: var(--gray-dark);
}
.cart-item-details { flex: 1; min-width: 0; }
.cart-item-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.cart-item-title a { color: var(--dark); }
.cart-item-title a:hover { color: var(--primary); text-decoration: none; }
.cart-item-vendor { font-size: 0.85rem; color: var(--secondary); }
.cart-label { display: block; font-size: 0.75rem; color: var(--gray-dark); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.cart-item-price { flex: 0 0 120px; text-align: center; font-size: 0.95rem; }
.cart-item-qty { flex: 0 0 90px; text-align: center; }
.cart-item-qty .form-control { width: 65px; text-align: center; margin: 0 auto; padding: 6px 8px; }
.cart-item-subtotal { flex: 0 0 120px; text-align: center; font-size: 1.05rem; color: var(--primary); }
.cart-item-remove { flex: 0 0 40px; text-align: center; }
.cart-item-remove .btn { padding: 6px 10px; font-size: 0.9rem; }
.cart-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 20px; padding: 20px 24px;
    background: white; border-radius: var(--radius); box-shadow: var(--shadow);
}
.cart-total { font-size: 1.2rem; }
.cart-total strong { color: var(--primary); font-size: 1.4rem; }

/* === Text overflow === */
.card-title, .report-product-info h3, .cart-item-title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.product-info h1 { word-break: break-word; }

/* === Responsive - Tablet === */
@media (max-width: 1024px) {
    .main-nav { gap: 15px; }
    .main-nav a { font-size: 0.9rem; }
    .cart-item-price { flex: 0 0 100px; }
    .cart-item-subtotal { flex: 0 0 100px; }
    .report-product-stats { gap: 14px; }
    .report-stat { min-width: 55px; }
}

/* === Responsive - Mobile === */
@media (max-width: 768px) {
    /* Nav */
    .main-nav { display: none; flex-direction: column; position: absolute; top: 65px; left: 0; right: 0; background: white; padding: 20px; box-shadow: var(--shadow-lg); gap: 15px; z-index: 200; }
    .main-nav.open { display: flex; }
    .mobile-menu-toggle { display: block; }

    /* Hero */
    .hero { padding: 50px 15px; }
    .hero h1 { font-size: 1.6rem; }
    .hero p { font-size: 1rem; }

    /* Grids */
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
    .vendors-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
    .product-detail { grid-template-columns: 1fr; gap: 20px; }
    .product-main-img { height: 280px; }
    .product-info h1 { font-size: 1.4rem; }

    /* Filters */
    .filters-bar { flex-direction: column; padding: 15px; }
    .filters-bar .form-control, .filters-bar select.form-control { width: 100%; min-width: auto; flex: 1 1 100%; }

    /* Cart */
    .cart-item { flex-wrap: wrap; gap: 12px; padding: 14px; }
    .cart-item-photo { flex: 0 0 60px; }
    .cart-item-photo img { width: 60px; height: 60px; }
    .cart-item-details { flex: 1 1 calc(100% - 76px); }
    .cart-item-price, .cart-item-qty, .cart-item-subtotal { flex: 1 1 auto; min-width: 0; }
    .cart-item-remove { flex: 0 0 auto; }
    .cart-footer { flex-direction: column; gap: 12px; text-align: center; }

    /* Reports */
    .report-stats-grid { grid-template-columns: 1fr 1fr; }
    .report-product-card { flex-wrap: wrap; padding: 12px; }
    .report-product-info { flex: 1 1 calc(100% - 76px); }
    .report-product-stats { width: 100%; justify-content: space-around; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--gray); }
    .report-request-body { flex-direction: column; gap: 6px; }
    .report-custom-period .form-control { flex: 1; min-width: 0; }

    /* Vendor panel */
    .vp-product { flex-wrap: wrap; }
    .vp-product-info { flex: 1 1 calc(100% - 76px); }
    .vp-product-actions { width: 100%; justify-content: flex-end; }

    /* Tables */
    table.table th, table.table td { padding: 10px 8px; font-size: 0.85rem; }
    .actions { flex-wrap: wrap; }

    /* Contact / Login */
    .login-page { margin: 30px auto; }
    .login-box { padding: 25px 20px; }

    /* Page header */
    .page-header { flex-direction: column; align-items: flex-start; }
}

/* === Responsive - Small Mobile === */
@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .hero h1 { font-size: 1.3rem; }
    .products-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .card-img { height: 140px; }
    .card-body { padding: 10px; }
    .card-title { font-size: 0.9rem; }
    .card-price { font-size: 1rem; }
    .vendors-grid { grid-template-columns: 1fr 1fr; }
    .report-stats-grid { grid-template-columns: 1fr; }
    .report-stat-card { padding: 14px; }
    .report-stat-card-value { font-size: 1.3rem; }
    .product-thumbs img { width: 60px; height: 60px; }
    .pagination a, .pagination span { padding: 6px 10px; font-size: 0.8rem; }
    .btn { padding: 8px 14px; font-size: 0.88rem; }
    .btn-sm { padding: 5px 10px; font-size: 0.8rem; }
}
