/* =========================================================
   Product List - base styles
   Mobile-first, no external framework dependency.
   ========================================================= */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-danger: #dc2626;
    --color-success: #16a34a;
    --color-info: #0891b2;
    --color-warning: #d97706;

    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;

    --sidebar-width: 260px;
    --navbar-height: 64px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- App shell / layout ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-content {
    flex: 1;
    padding: 1.25rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border);
}

/* ---------- Sidebar (off-canvas on mobile, static on desktop) ---------- */

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    min-height: var(--navbar-height);
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 1;
    padding: 0.25rem 0.5rem;
}

.sidebar-nav {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 0.75rem 0.75rem 0.25rem;
    font-weight: 600;
}

.sidebar-link {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--color-text);
    font-size: 0.95rem;
}

.sidebar-link:hover { background: var(--color-bg); }
.sidebar-link.active {
    background: #eff6ff;
    color: var(--color-primary);
    font-weight: 600;
}

.sidebar-link-icon { width: 1.25em; text-align: center; }

.sidebar-empty {
    padding: 0.5rem 0.75rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.sidebar-divider {
    height: 1px;
    background: var(--color-border);
    margin: 0.75rem 0.25rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 999;
}

.sidebar-overlay.visible { display: block; }

/* ---------- Navbar ---------- */

.navbar {
    height: var(--navbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 500;
}

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
}

.navbar-brand-mobile {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}

.navbar-search {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.75rem;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.search-icon { color: var(--color-text-muted); flex-shrink: 0; }

.navbar-search input[type="search"] {
    border: none;
    background: none;
    outline: none;
    flex: 1;
    font-size: 0.95rem;
    min-width: 0;
    color: var(--color-text);
}

.search-submit {
    display: none;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-icon {
    font-size: 1.2rem;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.btn-icon:hover { background: var(--color-bg); }

/* ---------- Flash messages ---------- */

.flash-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.flash-success { background: #dcfce7; color: #166534; }
.flash-danger  { background: #fee2e2; color: #991b1b; }
.flash-info    { background: #e0f2fe; color: #075985; }
.flash-warning { background: #fef3c7; color: #92400e; }

.flash-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

/* ---------- Content header ---------- */

.content-header { margin-bottom: 1.25rem; }
.content-header h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.content-subtitle { margin: 0; color: var(--color-text-muted); font-size: 0.9rem; }

.content-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* ---------- Product grid ---------- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.product-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
}

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

.product-image-wrap {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--color-bg);
    overflow: hidden;
}

.product-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.badge-out-of-stock {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(220, 38, 38, 0.9);
    color: #fff;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}

.product-info { padding: 0.75rem; flex: 1; display: flex; flex-direction: column; }

.product-title {
    font-size: 0.95rem;
    margin: 0 0 0.3rem;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-description {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin: 0 0 0.5rem;
    flex: 1;
}

.product-price {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1rem;
    margin-top: auto;
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0 1rem;
}

.pagination-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.pagination-link.disabled { opacity: 0.4; pointer-events: none; }
.pagination-current { color: var(--color-text-muted); font-size: 0.9rem; }

/* ---------- Empty state ---------- */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.empty-state h1 { font-size: 3rem; margin: 0; color: var(--color-text); }

/* ---------- Product detail ---------- */

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--color-primary);
    font-size: 0.9rem;
}

.product-detail {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.product-detail-image {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-bg);
    aspect-ratio: 1 / 1;
}

.product-detail-image img { width: 100%; height: 100%; /*object-fit: cover;*/ }

.product-detail-info h1 { margin: 0 0 0.5rem; font-size: 1.5rem; }

.category-tag {
    display: inline-block;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.product-detail-price {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0.25rem 0;
}

.stock-badge {
    /*display: inline-block;*/
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    margin-bottom: 0.75rem;
}
.stock-badge.in-stock { background: #dcfce7; color: #166534; }
.stock-badge.out-of-stock { background: #fee2e2; color: #991b1b; }

.product-detail-description {
    color: var(--color-text);
    line-height: 1.7;
    white-space: pre-wrap;
}

.product-detail-actions { margin-top: 1rem; }

/* ---------- Buttons ---------- */

.btn-primary, .btn-secondary, .btn-danger, .btn-small {
    display: inline-block;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.btn-block { width: 100%; }

.inline-form { display: inline-block; }

/* ---------- Forms ---------- */

.form-card, .auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 640px;
}

.auth-container {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.auth-subtitle { color: var(--color-text-muted); margin-top: -0.5rem; margin-bottom: 1.25rem; }

.form-group { margin-bottom: 1.1rem; }

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.form-input, .form-textarea, .form-input-file {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.form-checkbox label { margin: 0; font-weight: 500; }
.form-checkbox input { width: auto; }

.form-error {
    color: var(--color-danger);
    font-size: 0.8rem;
    display: block;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.current-image-preview { margin-top: 0.75rem; }
.current-image-preview img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    margin-top: 0.35rem;
}

/* ---------- Admin table ---------- */

.table-responsive { overflow-x: auto; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    min-width: 600px;
}

.admin-table th, .admin-table td {
    text-align: left;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.admin-table th {
    background: var(--color-bg);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.admin-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.admin-table-actions { /*display: flex;*/ gap: 0.4rem; }

/* =========================================================
   Responsive breakpoints
   ========================================================= */

/* Small phones: single-column grid */
@media (max-width: 420px) {
    .product-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .navbar-brand-mobile { display: none; }
}

/* Tablet and up: static sidebar, wider grid */
@media (min-width: 768px) {
    .sidebar {
        position: sticky;
        transform: none;
        flex-shrink: 0;
    }

    .sidebar-overlay { display: none !important; }
    .hamburger-btn { display: none; }
    .sidebar-close { display: none; }

    .navbar-brand-mobile { display: none; }

    .search-submit { display: inline-block; }

    .page-content { padding: 1.5rem 2rem; }

    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }

    .product-detail {
        grid-template-columns: 380px 1fr;
        padding: 2rem;
    }

    .form-row { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1100px) {
    .product-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1400px) {
    .product-grid { grid-template-columns: repeat(5, 1fr); }
}
