:root {
    --ink: #071f3d;
    --muted: #5f6d7b;
    --line: #dbe2ea;
    --soft: #f6f8fb;
    --brand: #071f3d;
    --brand-dark: #041326;
    --accent: #cf145b;
    --accent-dark: #a90f48;
    --danger: #cf145b;
    --white: #ffffff;
}

@font-face {
    font-family: "MontserratArabic";
    src: url("../fonts/Montserrat-Arabic-Regular.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "MontserratArabic";
    src: url("../fonts/Montserrat-Arabic-Bold.otf") format("opentype");
    font-weight: 700 900;
    font-style: normal;
    font-display: swap;
}

* { box-sizing: border-box; }
html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
html, body, input, textarea, select, button, .form-control, .form-select, .dropdown-menu, .table {
    font-family: "MontserratArabic", "Segoe UI", Arial, sans-serif;
    font-weight: 400;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: #ffffff;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6,
.brand,
.btn,
.nav-link,
.eyebrow,
.stat-card strong,
.resource-body h2,
.quick-grid a,
.form-label,
strong {
    font-family: "MontserratArabic", "Segoe UI", Arial, sans-serif;
    font-weight: 700;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        linear-gradient(rgba(7, 31, 61, .72), rgba(7, 31, 61, .72)),
        url("https://images.unsplash.com/photo-1562259949-e8e7689d7828?auto=format&fit=crop&w=1600&q=80") center/cover;
}
.auth-panel {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 24px 80px rgba(10, 20, 15, .28);
}
.auth-visual {
    min-height: 520px;
    padding: 52px;
    color: white;
    background: linear-gradient(140deg, rgba(7,31,61,.96), rgba(207,20,91,.82));
    display: flex;
    flex-direction: column;
    justify-content: end;
}
.auth-visual h1 { font-size: 48px; font-weight: 800; margin: 28px 0 12px; }
.auth-visual p { max-width: 520px; font-size: 18px; opacity: .92; }
.auth-logo {
    width: 128px;
    height: auto;
    padding: 12px;
    border-radius: 8px;
    background: #fff;
}
.auth-card { padding: 52px; align-self: center; }
.auth-card h2 { font-weight: 800; margin-bottom: 22px; }
.auth-link { margin: 18px 0 0; text-align: center; color: var(--muted); }

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: white;
    background: var(--accent);
    font-weight: 900;
}
.brand-mark.large { width: 72px; height: 72px; font-size: 26px; background: rgba(255,255,255,.2); }

.app-shell { display: flex; min-height: 100vh; width: 100%; max-width: 100%; overflow-x: hidden; }
.sidebar {
    width: 300px;
    flex: 0 0 300px;
    background: #0d1b16;
    color: white;
    border-right: 1px solid var(--line);
    padding: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 20px;
}
.sidebar .nav-link {
    color: rgba(255,255,255,.92);
    border-radius: 8px;
    padding: 11px 12px;
    display: flex;
    gap: 12px;
    align-items: center;
}
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: var(--accent);
    background: rgba(255,255,255,.12);
}
.nav-section {
    margin: 20px 8px 8px;
    color: rgba(255,255,255,.58);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: .08em;
}
.main { flex: 1; min-width: 0; max-width: 100%; overflow-x: hidden; }
.topbar {
    height: 72px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 4;
}
.content { padding: 30px; max-width: 100%; overflow-x: hidden; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; }
.search-box {
    align-items: center;
    gap: 8px;
    width: min(460px, 45vw);
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}
.search-box input {
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
}
.user-pill {
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--soft);
    color: var(--muted);
    font-size: 14px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    margin-bottom: 22px;
}
.page-heading h1 {
    margin: 4px 0 0;
    font-weight: 850;
    font-size: 34px;
}
.eyebrow {
    color: var(--accent);
    font-weight: 800;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.dashboard-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    padding: 34px;
    border-radius: 8px;
    color: white;
    background: linear-gradient(120deg, #071f3d, #12375f 62%, #cf145b);
}
.dashboard-hero h1 { font-size: 44px; font-weight: 850; margin: 4px 0 10px; }
.dashboard-hero p { max-width: 720px; margin: 0; opacity: .88; }
.dashboard-hero .eyebrow { color: rgba(255,255,255,.82); }

.stat-grid, .quick-grid, .resource-grid {
    display: grid;
    gap: 18px;
}
.stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 22px 0;
}
.stat-card, .quick-grid a, .admin-table, .admin-form, .admin-resource-form, .sticker-controls, .preview-frame {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 10px 30px rgba(23, 32, 26, .05);
}
.stat-card { padding: 22px; }
.stat-card span { color: var(--muted); display: block; }
.stat-card strong { font-size: 38px; line-height: 1; }
.quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quick-grid a {
    padding: 24px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 14px;
}
.quick-grid i { font-size: 26px; color: var(--accent); }

.filter-bar {
    display: grid;
    grid-template-columns: 1fr 260px auto;
    gap: 12px;
    margin-bottom: 20px;
}
.resource-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 100%; }
.resource-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}
.resource-card > img, .resource-fallback, .color-swatch-large {
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: var(--soft);
}
.resource-fallback {
    display: grid;
    place-items: center;
    color: var(--accent);
    font-size: 42px;
}
.resource-body { padding: 18px; }
.resource-body h2 {
    margin: 12px 0 8px;
    font-size: 20px;
    font-weight: 850;
}
.resource-body p { color: var(--muted); }
.resource-body .code { color: var(--brand-dark); font-weight: 800; margin-bottom: 6px; }
.permission { background: #eef3f8; color: var(--brand-dark); }
.file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.admin-form {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
    margin-bottom: 22px;
}
.admin-form > div { grid-column: span 2; }
.admin-resource-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
    margin-bottom: 22px;
}
.span-2 { grid-column: span 2; }
.admin-table { padding: 8px; }
.type-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.type-tabs a {
    color: var(--ink);
    text-decoration: none;
    border: 1px solid var(--line);
    background: white;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 700;
}
.type-tabs a.active { color: white; background: var(--brand); border-color: var(--brand); }
.status-pending { background: #fff4d6; color: #8a5a00; }
.status-approved { background: #e9f7ef; color: #17633b; }
.status-blocked { background: #fdecec; color: var(--danger); }

.preview-frame { min-height: 70vh; padding: 16px; }
.preview-frame iframe, .preview-frame video, .preview-frame img {
    width: 100%;
    height: 70vh;
    object-fit: contain;
    border: 0;
}
.empty-state {
    text-align: center;
    padding: 70px 24px;
    color: var(--muted);
}
.empty-state h1, .empty-state h2 { color: var(--ink); font-weight: 850; }

.sticker-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 22px;
    align-items: start;
}
.sticker-controls { padding: 20px; }
.sticker-preview-wrap {
    min-height: 520px;
    display: grid;
    place-items: center;
    border: 1px dashed #b8c5ba;
    border-radius: 8px;
    background: white;
    overflow: auto;
    padding: 28px;
}
.sticker-preview {
    width: 420px;
    aspect-ratio: 8 / 5;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    background: white;
}
.sticker-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sticker-text {
    position: absolute;
    left: 8%;
    right: 8%;
    text-align: center;
    color: #101813;
    text-shadow: 0 1px 2px rgba(255,255,255,.65);
}
.sticker-text.name {
    bottom: 30%;
    font-size: 34px;
    font-weight: 900;
}
.sticker-text.code {
    bottom: 18%;
    font-size: 20px;
    font-weight: 800;
    color: var(--brand-dark);
}

.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.brand-logo {
    width: 132px;
    max-width: 100%;
    height: auto;
    max-height: 132px;
    object-fit: contain;
}
.brand:has(.brand-logo) {
    justify-content: center;
    margin: 0 0 30px;
    padding: 16px 12px;
    border-radius: 6px;
    background: #ffffff;
    overflow: hidden;
}
.brand { color: #ffffff; }
.brand:hover { color: var(--accent); }
.mini-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}
.mini-specs span, .family-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 8px;
    color: var(--ink);
    background: var(--soft);
    font-size: 13px;
    font-weight: 800;
}
.detail-layout {
    display: grid;
    grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}
.detail-media, .detail-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
.detail-media img, .detail-media .resource-fallback, .detail-media .color-swatch-large {
    width: 100%;
    height: min(46vh, 380px);
    object-fit: contain;
    background: var(--soft);
}
.detail-panel { padding: 22px; }
.lead-text { color: var(--muted); font-size: 17px; }
.spec-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}
.spec-grid div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}
.spec-grid dt { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 800; }
.spec-grid dd { margin: 4px 0 0; font-weight: 800; color: var(--ink); }
.notes-box {
    padding: 14px;
    border-left: 4px solid var(--accent);
    background: #fff7f7;
    color: var(--ink);
}
.empty-specs {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: var(--soft);
    color: var(--muted);
}
.empty-specs strong {
    display: block;
    color: var(--ink);
    margin-bottom: 6px;
}
.empty-specs p { margin-bottom: 12px; }
.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.check-row label {
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}
.table-actions {
    display: flex;
    justify-content: end;
    gap: 6px;
}
.table-actions form { display: inline; }

.rtl .ms-auto { margin-left: 0 !important; margin-right: auto !important; }

@media (max-width: 1100px) {
    .resource-grid, .stat-grid, .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-resource-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-form > div { grid-column: span 1; }
}

@media (max-width: 900px) {
    .auth-panel, .sticker-layout { grid-template-columns: 1fr; }
    .detail-layout { grid-template-columns: 1fr; }
    .auth-visual { min-height: 260px; padding: 34px; }
    .auth-card { padding: 34px; }
    .sidebar {
        position: fixed;
        z-index: 20;
        width: min(300px, 86vw);
        max-width: 86vw;
        inset-block: 0;
        right: 0;
        left: auto;
        transform: translateX(105%);
        transition: transform .2s ease;
    }
    .rtl .sidebar { transform: translateX(105%); }
    .sidebar.open { transform: translateX(0); }
    .topbar {
        height: auto;
        min-height: 64px;
        padding: 10px 12px;
        flex-wrap: wrap;
    }
    .topbar .ms-auto {
        max-width: calc(100vw - 74px);
        overflow: hidden;
    }
    .content { padding: 16px; }
    .filter-bar { grid-template-columns: 1fr; }
    .page-heading { gap: 12px; }
    .admin-table { overflow-x: auto; }
    .table { min-width: 680px; }
}

@media (max-width: 640px) {
    .resource-grid, .stat-grid, .quick-grid { grid-template-columns: 1fr; }
    .page-heading, .dashboard-hero { align-items: stretch; flex-direction: column; }
    .page-heading h1, .dashboard-hero h1 { font-size: 26px; line-height: 1.25; }
    .admin-resource-form, .admin-form { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .user-pill { display: none; }
    .sticker-preview { width: 100%; min-width: 300px; }
    .auth-page { padding: 14px; }
    .spec-grid { grid-template-columns: 1fr; }
    .dashboard-hero { padding: 22px; }
    .resource-card > img, .resource-fallback, .color-swatch-large { height: 180px; }
    .file-actions .btn { width: 100%; justify-content: center; }
    .topbar .btn,
    .topbar .icon-btn {
        flex: 0 0 auto;
    }
    .brand-logo { width: 116px; }
}

@media (max-width: 420px) {
    .content { padding: 12px; }
    .page-heading h1, .dashboard-hero h1 { font-size: 24px; }
    .resource-body { padding: 14px; }
    .auth-card, .auth-visual { padding: 24px; }
    .auth-visual h1 { font-size: 32px; }
}

@media print {
    body * { visibility: hidden; }
    .sticker-preview, .sticker-preview * { visibility: visible; }
    .sticker-preview {
        position: fixed;
        left: 0;
        top: 0;
        width: var(--print-w, 80mm);
        height: var(--print-h, 50mm);
        border: 0;
    }
}
