/* --- Root Variables --- */
:root {
    --primary-color: #110af0; /* Strong Blue */
    --secondary-color: #64748b; /* Slate */
    --success-color: #22c55e; /* Green */
    --danger-color: #ef4444; /* Red */
    --warning-color: #f97316; /* Orange */

    /* Theme-independent variables */
    --font-family-sans-serif: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 0.5rem;
    --box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --box-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --transition: all 0.2s ease-in-out;

    /* Renamed Dark Theme variables to be the new base */
    --bg-color: #0f172a; /* Slate 900 */
    --surface-color: #1e293b; /* Slate 800 */
    --text-color: #f8fafc; /* Slate 50 */
    --text-muted-color: #94a3b8; /* Slate 400 */
    --border-color: #334155; /* Slate 700 */
}

/* --- Global Styles --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family-sans-serif);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    text-decoration: none;
    opacity: 0.8;
}

img {
    vertical-align: middle;
    max-width: 100%;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}
h2.category-title {
    margin-top: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* --- Layout --- */
.container {
    width: 100%;
    padding-right: 1.5rem;
    padding-left: 1.5rem;
    margin-right: auto;
    margin-left: auto;
}
@media (min-width: 768px) { .container { max-width: 720px; } }
@media (min-width: 992px) { .container { max-width: 960px; } }
@media (min-width: 1200px) { .container { max-width: 1140px; } }

/* --- Header --- */
.main-header {
    background-color: var(--surface-color);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--box-shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1020;
    transition: var(--transition);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.logo { height: 40px; }
.main-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0;
    color: var(--text-color);
}

.main-nav {
    display: none; /* Hidden by default on mobile */
}

.main-nav.is-open {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    box-shadow: var(--box-shadow);
    z-index: 1000;
}

.main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.main-nav a {
    font-weight: 500;
    color: var(--text-muted-color);
    padding-bottom: 0.25rem;
    border-bottom: 2px solid transparent;
}
.main-nav a:hover, .main-nav a.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.nav-toggle {
    display: block;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}
.nav-toggle .icon-bar {
    display: block;
    width: 24px;
    height: 3px;
    background-color: var(--text-color);
    margin: 5px 0;
    transition: var(--transition);
}

.nav-toggle.is-active .icon-bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.nav-toggle.is-active .icon-bar:nth-child(2) {
    opacity: 0;
}
.nav-toggle.is-active .icon-bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

@media (min-width: 768px) {
    .main-nav {
        display: block;
    }
    .main-nav ul {
        flex-direction: row;
        gap: 1.5rem;
    }
    .nav-toggle {
        display: none;
    }
    .main-nav.is-open {
        position: static;
        border: none;
        padding: 0;
        box-shadow: none;
    }
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
}

/* --- Footer --- */
.main-footer-bar {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface-color);
    color: var(--text-muted-color);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    transition: var(--transition);
}

/* --- Card Component --- */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: var(--surface-color);
    background-clip: border-box;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    margin-bottom: 1.5rem;
    transition: var(--transition);
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.3);
}

.card-header {
    padding: 1rem 1.5rem;
    margin-bottom: 0;
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    flex: 1 1 auto;
    padding: 1.5rem;
}
.card-title {
    margin-bottom: 0.75rem;
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.card-img-top {
    width: 100%;
    height: 220px;
    object-fit: contain;
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    background-color: var(--surface-color);
    cursor: pointer;
}

/* --- Button Component --- */
.btn {
    display: inline-block;
    font-weight: 600;
    line-height: 1.5;
    color: #fff;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: var(--primary-color);
    border: 1px solid transparent;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--box-shadow); }
.btn-primary { background-color: var(--primary-color); }
.btn-primary:hover { background-color: #0d08c0; }
.btn-success { background-color: var(--success-color); }
.btn-success:hover { background-color: #16a34a; }
.btn-danger { background-color: var(--danger-color); }
.btn-danger:hover { background-color: #dc2626; }
.btn-secondary { background-color: var(--secondary-color); color: var(--bg-color); }
.btn-secondary:hover { background-color: #475569; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: .875rem; }
.d-grid .btn { width: 100%; }

/* --- Alert Component --- */
.alert {
    position: relative;
    padding: 1rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
}
.alert-success { background-color: #14532d; color: #dcfce7; border-color: #22c55e; }
.alert-danger { background-color: #7f1d1d; color: #fee2e2; border-color: #ef4444; }
.alert-warning { background-color: #7c2d12; color: #ffedd5; border-color: #f97316; }

/* --- Form Styling --- */
.form-group { margin-bottom: 1.5rem; }
.form-label { display: inline-block; margin-bottom: 0.5rem; font-weight: 500; }
.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--surface-color);
    background-clip: padding-box;
    border: 2px solid var(--secondary-color);
    appearance: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
}
.form-control:focus {
    color: var(--text-color);
    background-color: var(--surface-color);
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(17, 10, 240, 0.25);
}
.form-check-label { margin-left: 0.5rem; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Form Layout Utilities --- */
.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 0; /* Remove margin, use padding and borders instead */
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.form-row:last-child {
    border-bottom: none;
}
.form-row:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05); /* Subtle zebra striping */
}
.form-row-label {
    flex: 1; /* Allow label to take up space */
    padding-right: 1rem;
    font-weight: 500;
}
.form-row-input {
    flex: 0 0 120px; /* Fixed width for the input area */
}

.form-control-small {
    max-width: 100px;
    margin-left: auto; /* Align to the right */
}

/* --- Table Styling --- */
.table {
    width: 100%;
    margin-bottom: 1rem;
    vertical-align: top;
    border-color: var(--border-color);
    border-collapse: collapse;
}
.table th, .table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.table thead th {
    vertical-align: bottom;
    border-bottom-width: 2px;
    background-color: var(--surface-color);
}

.table tbody tr:hover {
    background-color: #2a374a;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Modal styles --- */
.modal { display: none; position: fixed; z-index: 1050; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.7); }
.modal-content {
    background-color: var(--surface-color);
    margin: 10% auto;
    padding: 0;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); }
.modal-title { margin: 0; font-size: 1.25rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); }
.close-btn { border: none; background: transparent; font-size: 1.5rem; cursor: pointer; color: var(--text-muted-color); }

/* --- Quill.js Dark Theme --- */
.ql-toolbar {
    border-color: var(--border-color) !important;
}
.ql-container {
    border-color: var(--border-color) !important;
}
.ql-editor {
    color: var(--text-color);
}
.ql-snow .ql-stroke {
    stroke: var(--text-muted-color);
}
.ql-snow .ql-picker-label {
    color: var(--text-muted-color);
}
.ql-snow .ql-fill, .ql-snow .ql-stroke.ql-fill {
    fill: var(--text-muted-color);
}

/* --- Grid Layout --- */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}
.col-md-6 {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}
@media (min-width: 768px) {
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* --- List Group --- */
.list-group { display: flex; flex-direction: column; padding-left: 0; margin-bottom: 0; border-radius: var(--border-radius); }
.list-group-item {
    position: relative;
    display: block;
    padding: .75rem 1.25rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
}
.list-group-item:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.list-group-item:last-child { border-bottom-right-radius: inherit; border-bottom-left-radius: inherit; }
.list-group-item + .list-group-item { border-top-width: 0; }

/* --- Utility classes --- */
.text-muted { color: var(--text-muted-color) !important; }
.badge.bg-warning {
    background-color: #4d3802 !important;
    color: #fff3cd !important;
}

/* --- Responsive --- */
@media (max-width: 767px) {
    body {
        font-size: 1rem;
        line-height: 1.6;
    }
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    .btn-sm {
        padding: 0.5rem 0.8rem;
    }
    .form-control {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }
    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .row.g-3 {
        flex-direction: column;
    }
    .row.g-3 > .col-md-5, .row.g-3 > .col-md-2 {
        width: 100%;
    }

    /* --- Responsive Tables --- */
    .table-responsive-cards {
        border: 0;
    }
    .table-responsive-cards thead {
        border: none;
        clip: rect(0 0 0 0);
        height: 1px;
        margin: -1px;
        overflow: hidden;
        padding: 0;
        position: absolute;
        width: 1px;
    }
    .table-responsive-cards tr {
        border-bottom: 3px solid var(--border-color);
        display: block;
        margin-bottom: 1rem;
        box-shadow: var(--box-shadow-sm);
        border-radius: var(--border-radius);
        padding: 1rem;
    }
    .table-responsive-cards td {
        border-bottom: 1px solid var(--border-color);
        display: block;
        text-align: right;
        padding: .75rem 0;
    }
    .table-responsive-cards td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        text-transform: uppercase;
    }
    .table-responsive-cards td:last-child {
        border-bottom: 0;
    }
}

/* --- Image Lightbox Modal --- */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 1060;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
}

.lightbox-modal.show {
    display: flex;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    display: block;
    margin: auto;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
}

.tag-badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: .75em;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    border: 1px solid transparent;
}

/* --- Select2 Dark Theme Override --- */
.select2-container .select2-selection--multiple {
    background-color: var(--surface-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius) !important;
    padding: 0.25rem !important;
    min-height: 40px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--primary-color) !important;
    border: 1px solid var(--primary-color) !important;
    color: #fff !important;
    padding: 2px 5px !important;
    margin-right: 5px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #fff !important;
    margin-left: 5px !important;
    cursor: pointer !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    opacity: 0.7 !important;
}

.select2-container--default .select2-search--inline .select2-search__field {
    color: var(--text-color) !important;
    margin-top: 5px !important;
}

.select2-dropdown {
    background-color: var(--bg-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--box-shadow) !important;
}

.select2-search--dropdown .select2-search__field {
    background-color: var(--surface-color) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
}

.select2-results__option {
    color: var(--text-muted-color) !important;
    padding: 0.75rem 1rem !important;
}

.select2-results__option--highlighted,
.select2-results__option[aria-selected=true] {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

/* --- Toast Notification --- */
.toast-notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--success-color);
    color: #fff;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    z-index: 2000;
    transition: bottom 0.5s ease-in-out;
}
.toast-notification.show {
    bottom: 20px;
}
.toast-notification.error {
    background-color: var(--danger-color);
}

/* Specific styles for the stock modal to align with theme */
#stock-modal .modal-content {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    max-width: 500px;
}

#stock-modal .modal-header {
    border-bottom: 1px solid var(--border-color);
}

#stock-modal .modal-footer {
    border-top: 1px solid var(--border-color);
}

#stock-modal .close-button {
    color: var(--text-muted-color);
    transition: var(--transition);
}
#stock-modal .close-button:hover {
    color: var(--text-color);
}

/* --- Public Pre-Order Page Logo --- */
.public-logo-container {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    z-index: 10;
}

.public-logo {
    width: 100px;
    height: auto;
}

@media (max-width: 768px) {
    .public-logo-container {
        top: 0.5rem;
        right: 1rem;
    }
    .public-logo {
        width: 80px;
    }
}

@media (max-width: 576px) {
    .public-logo {
        width: 60px;
    }
}
