*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== THEME VARIABLES ===== */
:root, [data-theme="light"] {
    --bg: #f5f6f8;
    --bg2: #ffffff;
    --surface: #ffffff;
    --surface2: #f0f2f5;
    --border: #e0e3ea;
    --border2: #c8cdd8;
    --text: #1a1d2e;
    --text2: #4a5068;
    --muted: #8890a8;
    --primary: #e63946;
    --primary-hover: #c1121f;
    --primary-light: rgba(230,57,70,.1);
    --primary-glow: rgba(230,57,70,.25);
    --success: #2d9e6b;
    --danger: #e63946;
    --danger-light: rgba(230,57,70,.1);
    --warning: #f4a261;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow: 0 2px 8px rgba(0,0,0,.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
    --navbar-bg: #ffffff;
    --new-bg: rgba(230,57,70,.05);
}

[data-theme="dark"] {
    --bg: #0f1117;
    --bg2: #1a1d27;
    --surface: #1a1d27;
    --surface2: #22263a;
    --border: #2d3148;
    --border2: #3d4260;
    --text: #e8eaf0;
    --text2: #a0a8c0;
    --muted: #6b7290;
    --primary: #e63946;
    --primary-hover: #c1121f;
    --primary-light: rgba(230,57,70,.12);
    --primary-glow: rgba(230,57,70,.3);
    --success: #34d399;
    --danger: #f05252;
    --danger-light: rgba(240,82,82,.15);
    --warning: #f4a261;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow: 0 2px 8px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
    --navbar-bg: #1a1d27;
    --new-bg: rgba(230,57,70,.07);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background .2s, color .2s;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }

/* ===== NAVBAR ===== */
.navbar {
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--border);
    padding: .75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.navbar-inner { display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--primary); text-decoration: none; letter-spacing: -.02em; }
.nav-right { display: flex; align-items: center; gap: .75rem; }
.nav-link { color: var(--text2); text-decoration: none; font-size: .875rem; font-weight: 500; }
.nav-link:hover { color: var(--primary); }

.theme-toggle {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 34px; height: 34px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    color: var(--text2);
    transition: background .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--border); border-color: var(--border2); }

/* ===== HERO ===== */
.hero { padding: 3rem 1.25rem 1.5rem; }
.hero h1 { font-size: 2rem; font-weight: 800; margin-bottom: .35rem; letter-spacing: -.03em; color: var(--text); }
.hero p { color: var(--text2); font-size: 1rem; }

/* ===== LAYOUT: CATALOG ===== */
.catalog-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; padding: 0 1.25rem 3rem; max-width: 1200px; margin: 0 auto; }
@media (max-width: 860px) { .catalog-layout { grid-template-columns: 1fr; } }

/* ===== FILTERS SIDEBAR ===== */
.filters-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    height: fit-content;
    position: sticky;
    top: 70px;
}
.filters-title { font-size: .875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 1rem; }
.filter-group { margin-bottom: 1rem; }
.filter-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text2); margin-bottom: .35rem; }
.filter-select, .filter-input {
    width: 100%;
    padding: .45rem .7rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    background: var(--surface2);
    color: var(--text);
    outline: none;
    transition: border-color .15s;
    appearance: none;
    -webkit-appearance: none;
}
.filter-select:focus, .filter-input:focus { border-color: var(--primary); }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.filter-actions { display: flex; flex-direction: column; gap: .5rem; margin-top: 1.25rem; }
.active-filters-count { font-size: .8rem; color: var(--primary); font-weight: 600; margin-bottom: .5rem; }

/* ===== PRODUCTS GRID ===== */
.catalog-main {}
.results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.results-count { font-size: .875rem; color: var(--text2); }
.sort-select { padding: .4rem .7rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .875rem; background: var(--surface); color: var(--text); outline: none; cursor: pointer; }

.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow .2s, transform .15s, border-color .2s;
}
.product-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary);
}
.product-thumb { width: 100%; height: 190px; object-fit: cover; display: block; background: var(--surface2); }
.product-thumb.placeholder { height: 190px; background: var(--surface2); }
.product-info { padding: .875rem 1rem; }
.product-title { font-size: .9rem; font-weight: 600; margin-bottom: .2rem; color: var(--text); line-height: 1.3; }
.product-price { color: var(--primary); font-weight: 700; font-size: 1.05rem; margin-bottom: .4rem; }
.product-specs { display: flex; flex-wrap: wrap; gap: .3rem; }
.spec-tag {
    font-size: .72rem;
    color: var(--text2);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .15rem .45rem;
}

/* ===== PRODUCT DETAIL ===== */
.product-detail-page { max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.product-detail-grid { display: grid; grid-template-columns: 1fr 400px; gap: 2.5rem; }
@media (max-width: 860px) { .product-detail-grid { grid-template-columns: 1fr; } }

/* Gallery / Carousel */
.gallery { position: relative; }
.gallery-main {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface2);
    aspect-ratio: 4/3;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-main .placeholder { width: 100%; height: 100%; background: var(--surface2); }
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,.45);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px; height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
    z-index: 2;
}
.gallery-nav:hover { background: rgba(0,0,0,.7); }
.gallery-nav.prev { left: .6rem; }
.gallery-nav.next { right: .6rem; }
.gallery-counter {
    position: absolute;
    bottom: .6rem;
    right: .75rem;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    padding: .2rem .55rem;
    border-radius: 20px;
}
.gallery-thumbs { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.gallery-thumbs .thumb {
    width: 68px; height: 52px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: .65;
    transition: opacity .15s, border-color .15s;
}
.gallery-thumbs .thumb:hover, .gallery-thumbs .thumb.active { opacity: 1; border-color: var(--primary); }

/* Detail info panel */
.detail-info {}
.detail-title { font-size: 1.6rem; font-weight: 800; margin-bottom: .35rem; letter-spacing: -.02em; line-height: 1.2; }
.detail-price { font-size: 1.8rem; font-weight: 800; color: var(--primary); margin-bottom: 1.25rem; }
.detail-specs { background: var(--surface2); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.25rem; }
.spec-row { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.spec-row:last-child { border-bottom: none; }
.spec-key { color: var(--text2); }
.spec-val { font-weight: 600; color: var(--text); }
.detail-description { color: var(--text2); margin-bottom: 1.5rem; line-height: 1.7; font-size: .9rem; }
.detail-description p { margin-bottom: .6rem; }
.detail-description strong { color: var(--text); }
.detail-description ul, .detail-description ol { padding-left: 1.4rem; margin-bottom: .6rem; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .6rem 1.25rem;
    border-radius: var(--radius);
    font-size: .9rem; font-weight: 600;
    cursor: pointer; border: none;
    text-decoration: none;
    transition: background .15s, color .15s, box-shadow .15s, transform .1s;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px var(--primary-glow); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-full { width: 100%; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(3px); }
.modal-overlay.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; width: 100%; max-width: 460px; position: relative; box-shadow: var(--shadow-lg); }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ===== CONTACT FORM ===== */
.contact-form h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: .2rem; }
.form-hint { color: var(--muted); font-size: .85rem; margin-bottom: 1.25rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; color: var(--text); }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: .6rem .875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    background: var(--surface2);
    color: var(--text);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-error { color: var(--danger); font-size: .85rem; margin-bottom: .75rem; }
.form-success { text-align: center; color: var(--success); font-weight: 600; padding: 1rem 0; }

/* ===== ADMIN ===== */
.admin-nav { background: var(--surface); border-bottom: 1px solid var(--border); padding: .75rem 0; }
.admin-nav .container { display: flex; align-items: center; justify-content: space-between; }
.admin-nav-links { display: flex; gap: 1rem; align-items: center; }

.page-header { display: flex; align-items: center; justify-content: space-between; padding: 2rem 0 1.25rem; }
.page-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.badge { background: var(--primary); color: #fff; font-size: .72rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; }

.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border); margin-bottom: 1.5rem; }
.admin-table th { background: var(--surface2); text-align: left; padding: .7rem 1rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--border); }
.admin-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-size: .875rem; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table a { color: var(--primary); text-decoration: none; }
.admin-table a:hover { text-decoration: underline; }
.row-new { background: var(--new-bg); }
.status-new { color: var(--primary); font-weight: 600; font-size: .8rem; }
.status-done { color: var(--muted); font-size: .8rem; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Product form */
.product-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; }
.form-section-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.5rem 0 .75rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.required { color: var(--danger); }
.form-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }
.alert-error { background: var(--danger-light); border: 1px solid var(--danger); border-radius: var(--radius); padding: .875rem 1rem; margin-bottom: 1.25rem; color: var(--danger); font-size: .875rem; }
.alert-error p { margin-bottom: .2rem; }
.alert-error p:last-child { margin-bottom: 0; }

/* Upload area */
.upload-area { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.75rem; text-align: center; cursor: pointer; position: relative; transition: border-color .15s, background .15s; }
.upload-area:hover, .upload-area.drag-over { border-color: var(--primary); background: var(--primary-light); }
.upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-hint span { display: block; font-weight: 600; color: var(--text); margin-bottom: .2rem; font-size: .9rem; }
.upload-hint small { color: var(--muted); font-size: .78rem; }
.preview-grid { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .75rem; }
.preview-thumb { position: relative; }
.preview-thumb img { width: 80px; height: 62px; object-fit: cover; border-radius: 6px; border: 2px solid var(--border); display: block; }

/* EasyMDE dark overrides */
.EasyMDEContainer .CodeMirror { background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.EasyMDEContainer .CodeMirror:focus-within { border-color: var(--primary); }
.editor-toolbar { background: var(--surface2); border: 1.5px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; }
.editor-toolbar a { color: var(--muted) !important; }
.editor-toolbar a:hover, .editor-toolbar a.active { color: var(--text) !important; background: var(--border) !important; }
.editor-toolbar i.separator { border-color: var(--border); }
.editor-preview { background: var(--surface2); color: var(--text); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: .75rem; justify-content: center; padding: 1.5rem 0; }
.pagination-info { font-size: .875rem; color: var(--text2); }

/* Misc */
.empty-state { color: var(--muted); text-align: center; padding: 3rem 0; font-size: .95rem; }
.hidden { display: none !important; }
.tag-inactive { opacity: .5; }

/* Filter option table */
.category-label { display: inline-block; padding: .2rem .6rem; border-radius: 4px; font-size: .75rem; font-weight: 600; background: var(--primary-light); color: var(--primary); }

/* Button Group Selector */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-option {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-family: inherit;
}

.btn-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.btn-option.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

@media (max-width: 600px) {
    .btn-group {
        flex-direction: column;
    }
    .btn-option {
        width: 100%;
    }
}

/* Searchable Select */
.searchable-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.searchable-select {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    background: var(--surface2);
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}

.searchable-select:focus {
    border-color: var(--primary);
}

.searchable-select option {
    padding: 0.5rem;
}

/* Image Manager Styles */
.image-manager {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.image-item {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    background: var(--surface);
}

.image-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.image-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.image-control-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.15s;
}

.image-control-label:hover {
    background: var(--surface2);
}

.image-control-label input[type="checkbox"],
.image-control-label input[type="radio"] {
    cursor: pointer;
}

.btn-icon {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.875rem;
}

.btn-icon:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
