:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --light: #f8f9fa;
    --dark: #343a40;
    --gray: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --sidebar-width: 240px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: var(--dark);
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border);
    display: none; /* Controlled by JS and media query */
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-nav {
    padding: 10px;
}

.sidebar-item {
    width: 100%;
    text-align: left;
    padding: 12px 15px;
    margin-bottom: 5px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray);
}

.sidebar-item.active {
    background: var(--light);
    color: var(--primary);
    font-weight: 600;
}

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

header {
    background: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-only {
    display: block;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }
    .sidebar {
        display: flex !important;
    }
    .menubar {
        display: none !important;
    }
    body {
        padding-bottom: 0 !important;
    }
}

@media (max-width: 767px) {
    body {
        padding-bottom: 80px;
    }
    .sidebar {
        display: none !important;
    }
    header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
    #auth-status {
        flex-wrap: wrap;
        justify-content: center;
    }
    .header-actions {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    .search-box {
        width: 100%;
    }
}

.search-box {
    flex: 1;
    max-width: 400px;
    margin: 0 15px;
}

#product-search {
    background: white;
    padding: 8px 15px;
    border: 1px solid var(--border);
}

.checkbox-group {
    display: flex;
    align-items: center;
    background: var(--light);
    padding: 10px;
    border-radius: 8px;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.status-published {
    background-color: #e6ffed;
    color: #28a745;
    border: 1px solid #28a745;
}

.status-draft {
    background-color: #f6f8fa;
    color: #6a737d;
    border: 1px solid #d1d5da;
}

main {
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

h2 {
    margin-top: 0;
    font-size: 1.1rem;
    border-bottom: 2px solid var(--light);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

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

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

.product-card {
    background: white;
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 10px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.product-card img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
}

.product-info {
    flex: 1;
}

.product-info h3 {
    margin: 0 0 5px 0;
    font-size: 1rem;
}

.product-info p {
    margin: 0;
    color: var(--gray);
    font-size: 0.9rem;
}

.product-card .actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

input, textarea, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--light);
}

textarea {
    height: 100px;
    resize: vertical;
}

button {
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    background-color: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:active {
    transform: scale(0.98);
}

button.secondary {
    background-color: var(--secondary);
}

button.danger {
    background-color: var(--danger);
}

button.small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Category List */
#category-list {
    list-style: none;
    padding: 0;
}

#category-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

#category-list .actions {
    display: flex;
    gap: 5px;
}

/* Spec Rows */
.spec-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.spec-row input {
    flex: 1;
    padding: 8px;
    font-size: 0.9rem;
}

/* Menubar (Mobile Only) */
.menubar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
}

.menubar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gray);
    font-size: 0.75rem;
    border: none;
    background: none;
    padding: 5px;
    flex: 1;
}

.menubar-item.active {
    color: var(--primary);
}

.menubar-item i {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

/* Camera & Previews */
.flex {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.preview-img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border);
}

/* Auth */
#auth-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

#logout-btn {
    background-color: var(--danger);
    padding: 8px 12px;
    font-size: 0.8rem;
}

/* Image Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    border-radius: 8px;
}

.modal-content, .close {
    animation-name: zoom;
    animation-duration: 0.6s;
}

@keyframes zoom {
    from {transform:scale(0)}
    to {transform:scale(1)}
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

@media only screen and (max-width: 700px){
    .modal-content {
        width: 100%;
    }
}
