@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    color-scheme: light;
    color: #111827;
    background: #f5f7fb;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #eff3f8;
    color: #111827;
    line-height: 1.65;
}

.admin-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 48px;
}

.qr-modal[hidden] {
    display: none;
}

.qr-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
}

.qr-modal-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 420px;
    width: calc(100% - 32px);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
    text-align: center;
}

.qr-modal-dialog h2 {
    margin: 0 0 16px;
    font-size: 1.25rem;
}

.qr-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    border: none;
    background: transparent;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
}

.qr-modal-close:hover {
    color: #111827;
}

.qr-modal-body img {
    width: 256px;
    height: 256px;
    max-width: 100%;
    image-rendering: pixelated;
}

.qr-modal-url {
    margin: 14px 0 0;
    font-size: 0.85rem;
    color: #4b5563;
    word-break: break-all;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    margin-bottom: 32px;
    border-bottom: 2px solid #e5e7eb;
}

.admin-header-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.admin-header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-header-username {
    color: #475569;
    font-size: 0.95rem;
}

.admin-header-username strong {
    color: #0f172a;
    font-weight: 600;
}

.btn-logout {
    background: #ef4444;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.16s ease;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

.btn-logout:hover {
    background: #dc2626;
    transform: translateY(-1px);
    text-decoration: none;
}

.page-shell {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.page-header,
.top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.page-header h1,
.page-header h2 {
    margin: 0;
    color: #0f172a;
}

.page-header p {
    margin: 0;
    color: #475569;
    max-width: 760px;
}

section,
.page-card {
    background: #ffffff;
    border: 1px solid #dbe4ef;
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
    padding: 28px;
}

section + section,
.page-card + section {
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 18px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

th,
td {
    padding: 16px 18px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

th {
    background: #f8fafc;
    color: #334155;
    font-weight: 600;
    font-size: 0.95rem;
}

th.sortable-header {
    cursor: pointer;
    user-select: none;
}

th.sortable-header:hover {
    background: #eef2f7;
}

th.sortable-header::after {
    content: '\2195';
    opacity: 0.35;
    margin-left: 6px;
    font-size: 0.8em;
}

th.sortable-header.sorted-asc::after {
    content: '\2191';
    opacity: 0.9;
}

th.sortable-header.sorted-desc::after {
    content: '\2193';
    opacity: 0.9;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

/* Expandable table styles */
tr.product-row {
    cursor: pointer;
}

tr.product-row:hover {
    background: #f1f5f9 !important;
}

th.expand-col {
    width: 40px;
}

td.expand-indicator {
    text-align: center;
    width: 40px;
}

.expand-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 7px solid #64748b;
    transition: transform 0.2s ease;
}

.expand-arrow.expanded {
    transform: rotate(-90deg);
}

tr.product-detail {
    display: none;
    background: #fafbfc;
}

tr.product-detail.expanded {
    display: table-row;
}

.detail-content {
    padding: 20px;
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.detail-info {
    flex: 1;
}

.detail-row {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
}

.detail-label {
    font-weight: 600;
    color: #64748b;
    min-width: 120px;
}

.detail-value {
    color: #334155;
}

.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Button styles */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-view {
    background: #cacaca;
    color: #475569;
    border-color: #cbd5e1;
}

.btn-view:hover {
    background: #a5a5a5;
    border-color: #94a3b8;
}

.btn-edit {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-edit:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-archive {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.btn-archive:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.btn-activate {
    background: #16a34a;
    color: white;
    border-color: #16a34a;
}

.btn-activate:hover {
    background: #15803d;
    border-color: #15803d;
}

.btn-qr {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

.btn-qr:hover {
    background: #7c3aed;
    border-color: #7c3aed;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: underline;
}

button,
.btn,
input[type="submit"],
input[type="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 14px;
    padding: 12px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.16s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

button:hover,
.btn:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    transform: translateY(-1px);
}

.btn-primary,
button[type="submit"] {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.18);
}

.btn-secondary {
    background: #f1f5f9;
    color: #0f172a;
}

input,
textarea,
select {
    width: 100%;
    min-width: 0;
    font: inherit;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    color: #0f172a;
    padding: 14px 16px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

input[type="checkbox"] {
    width: auto;
    height: 20px;
    width: 20px;
    margin: 0 8px 0 0;
    cursor: pointer;
    vertical-align: middle;
}

label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

input[readonly],
textarea[readonly] {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
    border-color: #e2e8f0;
}

/* ─── Material Picker ─── */
.mat-pick-list {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    max-height: 780px;
    overflow-y: auto;
    background: #f8fafc;
    resize: vertical;
}
.mat-pick-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s;
}
.mat-pick-item--available:hover {
    background: #e0f2fe;
}
.mat-pick-item--selected {
    cursor: default;
}
.mat-pick-item__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mat-pick-item__group {
    font-size: 0.78rem;
    color: #64748b;
    white-space: nowrap;
}
.mat-pick-item__remove {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #dc2626;
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    transition: background 0.15s;
}
.mat-pick-item__remove:hover {
    background: #fee2e2;
}
.mat-pick-group-header {
    padding: 8px 12px 2px;
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e293b;
    background: none;
    border: none;
    letter-spacing: 0.01em;
    margin-top: 6px;
}
.mat-pick-group-header:first-child {
    margin-top: 0;
}
.mat-pick-empty {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: #94a3b8;
    font-style: italic;
}
label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #334155;
}

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

/* ─── Pagination ─── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 20px 0;
    flex-wrap: wrap;
}
.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    color: #334155;
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
}
.pagination-link:hover {
    background: #e0f2fe;
    border-color: #93c5fd;
}
.pagination-current {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    cursor: default;
}
.pagination-current:hover {
    background: #3b82f6;
    border-color: #3b82f6;
}
.error {
    border-radius: 18px;
    padding: 18px 22px;
    margin-bottom: 24px;
}

.message {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
}

.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

ul li {
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
}

ul li a {
    display: block;
    width: 100%;
}

code {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 2px 6px;
    font-size: 0.95rem;
}

@media (max-width: 860px) {
    .admin-shell {
        padding: 24px 16px 32px;
    }

    .page-header,
    .top-bar {
        flex-direction: column;
        align-items: stretch;
    }

    th,
    td {
        padding: 12px 10px;
    }
}
