/* =========================================================
   Panel Admin - Kedai Emas Lelong
   ========================================================= */

:root {
    --gold: #b8860b;
    --gold-strong: #8a6508;
    --gold-soft: #faf3e0;
    --ink: #1c1a17;
    --ink-soft: #4c473f;
    --muted: #635d54;
    --bg: #f4f2ed;
    --surface: #ffffff;
    --surface-2: #f2eee6;
    --line: #ddd6c9;
    --danger: #a32114;
    --danger-soft: #fdecea;
    --success: #106b3f;
    --success-soft: #e7f5ee;
    --warning: #8a5a06;
    --warning-soft: #fdf4e3;
    --radius-sm: 6px;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(28, 26, 23, 0.07);
    --shadow: 0 4px 14px rgba(28, 26, 23, 0.1);
    --sidebar-w: 250px;
    --topbar-h: 60px;
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

a, button, select, summary, label[for] {
    cursor: pointer;
}

:disabled {
    cursor: not-allowed;
}

:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

h1, h2, h3 {
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1.25;
    margin: 0 0 0.6rem;
}

h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }

/* -------------------------------------------------------------- Shell */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    min-height: var(--topbar-h);
}

.admin-brand-logo {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: #17140f;
}

.admin-brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: var(--radius-sm);
    background: var(--gold);
    color: #fff;
}

.admin-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.admin-brand-text strong {
    font-size: 0.95rem;
}

.admin-brand-text small {
    font-size: 0.72rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.85rem 0.65rem;
    flex: 1;
    overflow-y: auto;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    padding: 0 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ink-soft);
}

.admin-nav-link:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.admin-nav-link.is-active {
    background: var(--gold-soft);
    color: var(--gold-strong);
    font-weight: 600;
}

.admin-nav-link.is-danger {
    color: var(--danger);
}

.admin-nav-link.is-danger:hover {
    background: var(--danger-soft);
}

.admin-nav-link svg {
    flex: none;
}

.admin-sidebar-foot {
    padding: 0.65rem;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.admin-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: var(--topbar-h);
    padding: 0 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 900;
}

.admin-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 990;
    background: rgba(0, 0, 0, 0.45);
    border: 0;
    padding: 0;
}

/* -------------------------------------------------------------- Panel */

.admin-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.35rem;
    margin-bottom: 1.25rem;
}

.admin-panel-head {
    margin-bottom: 1rem;
}

.admin-hint {
    font-size: 0.88rem;
    color: var(--muted);
    margin: 0 0 1rem;
}

.admin-hint code {
    background: var(--surface-2);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.admin-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
    margin: 0;
}

/* -------------------------------------------------------------- Alert */

.admin-alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.admin-alert ul {
    margin: 0;
    padding-left: 1.2rem;
}

.admin-alert-success {
    background: var(--success-soft);
    border-color: #bfe3d0;
    color: var(--success);
}

.admin-alert-error {
    background: var(--danger-soft);
    border-color: #f5c9c4;
    color: var(--danger);
}

.admin-alert-warning {
    background: var(--warning-soft);
    border-color: #f0dcae;
    color: var(--warning);
}

/* ------------------------------------------------------------- Butang */

.admin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 40px;
    padding: 0.5rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.admin-btn:disabled {
    opacity: 0.55;
}

.admin-btn-primary {
    background: var(--gold);
    border-color: var(--gold);
    color: #fff;
}

.admin-btn-primary:hover:not(:disabled) {
    background: var(--gold-strong);
    border-color: var(--gold-strong);
}

.admin-btn-outline {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

.admin-btn-outline:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--gold-strong);
}

.admin-btn-danger {
    background: var(--surface);
    border-color: #e8c4bf;
    color: var(--danger);
}

.admin-btn-danger:hover:not(:disabled) {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.admin-btn-sm {
    min-height: 34px;
    padding: 0.3rem 0.7rem;
    font-size: 0.84rem;
}

.admin-btn-block {
    width: 100%;
}

/* ------------------------------------------------------------- Statistik */

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.admin-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.admin-stat-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.admin-stat-value {
    font-family: Georgia, serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gold-strong);
    line-height: 1.1;
}

.admin-stat-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gold-strong);
}

.admin-stat-link:hover {
    text-decoration: underline;
}

.admin-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

/* -------------------------------------------------------------- Medan */

.admin-field {
    margin-bottom: 1rem;
}

.admin-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 0.35rem;
}

.admin-field .req {
    color: var(--danger);
}

.admin-field input[type="text"],
.admin-field input[type="number"],
.admin-field input[type="email"],
.admin-field input[type="password"],
.admin-field input[type="search"],
.admin-field select,
.admin-field textarea {
    width: 100%;
    min-height: 42px;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.admin-field textarea {
    resize: vertical;
}

.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.15);
}

.admin-field-inline {
    margin-bottom: 0;
}

.admin-field-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-field-check label {
    margin-bottom: 0;
    font-weight: 500;
}

.admin-field-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--gold);
}

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0 1.25rem;
}

.settings-section-heading {
    margin-bottom: 1.35rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.settings-section-heading h2 {
    margin: 0.2rem 0 0.35rem;
    font-size: 1.25rem;
}

.settings-section-heading p {
    max-width: 68ch;
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.settings-section-heading code {
    padding: 0.12rem 0.35rem;
    border-radius: 4px;
    background: var(--surface-2);
}

.settings-kicker {
    color: var(--gold-strong);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.13em;
}

.settings-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1.4rem;
}

.settings-subgroup {
    margin-top: 0.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--line);
}

.settings-subgroup h3 {
    margin: 0 0 1rem;
    color: var(--ink);
    font-size: 0.98rem;
}

.settings-wide {
    grid-column: 1 / -1;
}

.settings-check-field {
    align-self: center;
    min-height: 42px;
}

.settings-logo-layout {
    display: grid;
    grid-template-columns: minmax(135px, 190px) minmax(0, 1fr);
    align-items: center;
    gap: 1.5rem;
}

.settings-logo-preview {
    margin: 0;
    padding: 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #17140f;
    text-align: center;
}

.settings-logo-preview img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
}

.settings-logo-preview figcaption {
    margin-top: 0.4rem;
    color: #e8d7a5;
    font-size: 0.75rem;
}

.settings-logo-input {
    min-width: 0;
}

.admin-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding-top: 0.5rem;
}

.admin-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.65rem;
}

.admin-filters .admin-field input,
.admin-filters .admin-field select {
    min-width: 200px;
}

/* -------------------------------------------------------------- Jadual */

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    white-space: nowrap;
}

.admin-table th {
    background: var(--surface-2);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 700;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table tbody tr:hover {
    background: var(--surface-2);
}

.admin-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.admin-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--surface-2);
    display: block;
}

.admin-cell-name {
    display: block;
    font-weight: 600;
}

.admin-cell-sub {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
}

.admin-cell-comment {
    max-width: 320px;
    white-space: normal;
    color: var(--ink-soft);
}

.admin-stock {
    font-weight: 600;
}

.admin-stock.is-out {
    color: var(--danger);
}

.admin-row-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.admin-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--success-soft);
    color: var(--success);
}

.admin-badge.is-off {
    background: var(--surface-2);
    color: var(--muted);
}

.admin-image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.admin-image-grid img {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--line);
}

/* Item galeri dalam borang produk (tandakan untuk hapus). */
.admin-gallery-item {
    position: relative;
    display: block;
    cursor: pointer;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--line);
}

.admin-gallery-item input[type="checkbox"] {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--gold);
    cursor: pointer;
}

.admin-gallery-remove {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 5px 0;
    background: rgba(28, 26, 23, 0.74);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

/* -------------------------------------------------------------- Login */

.admin-login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: var(--bg);
}

.admin-login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.admin-login-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.admin-login-logo {
    display: block;
    width: 104px;
    height: 104px;
    margin: 0 auto 0.9rem;
    border-radius: var(--radius);
    object-fit: cover;
    background: #17140f;
}

.admin-login-brand .admin-brand-mark {
    width: 46px;
    height: 46px;
    margin: 0 auto 0.75rem;
}

.admin-login-brand h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.admin-login-brand p {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
}

.admin-login-back {
    display: block;
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.admin-login-back:hover {
    color: var(--gold-strong);
}

/* --------------------------------------------------------- Responsif */

@media (max-width: 960px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
    }

    .admin-backdrop.is-open {
        display: block;
    }

    .admin-main {
        margin-left: 0;
    }

    .admin-nav-toggle {
        display: block;
    }

    .admin-stats {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .admin-content {
        padding: 1.15rem 1rem 2.5rem;
    }
}

@media (max-width: 520px) {
    .admin-form-grid {
        grid-template-columns: 1fr;
    }

    .admin-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-filters .admin-field input,
    .admin-filters .admin-field select {
        min-width: 0;
    }

    .admin-user {
        display: none;
    }
}

.admin-nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 0 9px;
}

.admin-nav-toggle span {
    display: block;
    height: 2px;
    background: var(--ink);
    margin: 4px 0;
    border-radius: 2px;
}

.admin-title {
    margin: 0;
    font-size: 1.15rem;
    flex: 1;
    min-width: 0;
}

.admin-user {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
    white-space: nowrap;
}

.admin-content {
    padding: 1.5rem 1.25rem 3rem;
    flex: 1;
}

@media (max-width: 960px) {
    .admin-nav-toggle {
        display: block;
        flex: none;
    }

    .admin-content {
        padding: 1.15rem 1rem 2.5rem;
    }

    .admin-stats {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media (max-width: 520px) {
    .admin-user {
        display: none;
    }

    .admin-form-grid.settings-field-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-logo-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
    }

    .settings-logo-preview {
        width: min(100%, 220px);
    }

    .admin-panel {
        padding: 1rem;
    }
}

/* =========================================================
   Dark mode (data-theme="dark") - Panel Admin
   ========================================================= */

[data-theme="dark"] {
    --gold: #e6b422;
    --gold-strong: #f2ca52;
    --gold-soft: #2e2614;
    --ink: #f4efe5;
    --ink-soft: #d5cec0;
    --muted: #b0a898;
    --bg: #141210;
    --surface: #1c1a17;
    --surface-2: #26231e;
    --line: #3a3630;
    --danger: #ef6a5c;
    --danger-soft: #3a211d;
    --success: #4fbf85;
    --success-soft: #17301f;
    --warning: #e0b45c;
    --warning-soft: #32260f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .admin-sidebar {
    background: #17140f;
}

[data-theme="dark"] .admin-topbar {
    background: #1c1a17;
    border-color: #3a3630;
}

[data-theme="dark"] .admin-field input,
[data-theme="dark"] .admin-field select,
[data-theme="dark"] .admin-field textarea {
    background: #141210;
    border-color: #3a3630;
    color: #f4efe5;
}

[data-theme="dark"] .admin-field input:focus,
[data-theme="dark"] .admin-field select:focus,
[data-theme="dark"] .admin-field textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(230, 180, 34, 0.15);
}

[data-theme="dark"] .admin-table thead th {
    background: #201d19;
    border-color: #3a3630;
}

[data-theme="dark"] .admin-table td {
    border-color: #2e2a24;
}

[data-theme="dark"] .admin-table tbody tr:hover {
    background: #26231e;
}

[data-theme="dark"] .admin-alert-error {
    border-color: #8a4b45;
}

[data-theme="dark"] .admin-alert-success {
    border-color: #3d7a55;
}

[data-theme="dark"] .admin-alert-warning {
    border-color: #8a6a2e;
}

[data-theme="dark"] .admin-thumb {
    background: #26231e;
}
