@font-face {
    font-family: "Cairo";
    src: url("fonts/cairo-arabic-400.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Cairo";
    src: url("fonts/cairo-arabic-600.woff2") format("woff2");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Cairo";
    src: url("fonts/cairo-arabic-700.woff2") format("woff2");
    font-style: normal;
    font-weight: 700 900;
    font-display: swap;
}

:root {
    --primary: #3046b8;
    --primary-strong: #23358e;
    --primary-soft: #eef1ff;
    --accent: #f23870;
    --success: #159957;
    --warning: #c27812;
    --danger: #d92d57;
    --page: #f5f7fc;
    --surface: #ffffff;
    --surface-2: #f9faff;
    --text: #17213b;
    --muted: #68728a;
    --line: #e0e5f0;
    --shadow: 0 12px 36px rgba(27, 39, 84, .09);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: "Cairo", "Noto Kufi Arabic", Tahoma, Arial, sans-serif;
    line-height: 1.65;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.admin-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: 30;
    width: 286px;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    color: #fff;
    background:
        radial-gradient(circle at 85% 8%, rgba(110, 133, 255, .45), transparent 28%),
        linear-gradient(170deg, #2e43b5 0%, #1e2f88 100%);
    box-shadow: -10px 0 32px rgba(25, 39, 105, .18);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 24px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(255, 255, 255, .15);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15);
    font-size: 1.55rem;
    font-weight: 900;
}

.brand strong {
    display: block;
    font-size: 1.22rem;
}

.brand small {
    opacity: .72;
}

.nav-label {
    margin: 8px 12px 7px;
    font-size: .78rem;
    opacity: .58;
}

.side-nav {
    display: grid;
    gap: 7px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 50px;
    padding: 11px 14px;
    border-radius: 16px;
    color: rgba(255, 255, 255, .82);
    text-decoration: none;
    font-weight: 700;
    transition: .18s ease;
}

.side-nav a:hover,
.side-nav a.active {
    color: #fff;
    background: rgba(255, 255, 255, .14);
    transform: translateX(-2px);
}

.nav-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
}

.logout-link {
    color: #fff;
    text-decoration: none;
    opacity: .76;
}

.page-shell {
    min-height: 100vh;
    margin-inline-end: 286px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 78px;
    padding: 13px 34px;
    border-bottom: 1px solid rgba(224, 229, 240, .9);
    background: rgba(245, 247, 252, .9);
    backdrop-filter: blur(14px);
}

.topbar h1 {
    margin: 0;
    font-size: 1.42rem;
}

.topbar p {
    margin: 1px 0 0;
    color: var(--muted);
    font-size: .88rem;
}

.menu-button {
    display: none;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    color: var(--primary);
    background: var(--primary-soft);
    cursor: pointer;
}

.content {
    width: min(1450px, calc(100% - 44px));
    margin: 0 auto;
    padding: 26px 0 60px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(260px, .8fr);
    gap: 18px;
    margin-bottom: 20px;
}

.hero-main,
.hero-side,
.panel,
.stat-card,
.editor-card {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.hero-main {
    position: relative;
    overflow: hidden;
    padding: 30px;
    color: #fff;
    border: 0;
    background:
        radial-gradient(circle at 12% 10%, rgba(255, 255, 255, .18), transparent 30%),
        linear-gradient(135deg, #3046b8, #4568f2);
}

.hero-main::after {
    content: "";
    position: absolute;
    inset-inline-start: -70px;
    bottom: -100px;
    width: 240px;
    height: 240px;
    border: 30px solid rgba(255, 255, 255, .07);
    border-radius: 50%;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--primary);
    font-weight: 800;
    font-size: .85rem;
}

.hero-main .eyebrow {
    color: rgba(255, 255, 255, .72);
}

.hero h2 {
    margin: 0 0 8px;
    font-size: clamp(1.55rem, 3vw, 2.2rem);
}

.hero p {
    margin: 0;
    max-width: 720px;
    opacity: .82;
}

.hero-side {
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 24px;
}

.api-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--success);
    font-weight: 800;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 5px rgba(21, 153, 87, .12);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block: 0;
    width: 5px;
    background: var(--primary);
}

.stat-card.pink::after {
    background: var(--accent);
}

.stat-card.green::after {
    background: var(--success);
}

.stat-card.purple::after {
    background: #8a5ed6;
}

.stat-card span {
    color: var(--muted);
    font-size: .9rem;
}

.stat-card strong {
    display: block;
    margin-top: 4px;
    color: var(--primary);
    font-size: 1.9rem;
}

.panel {
    padding: 22px;
    margin-bottom: 18px;
}

.panel-head,
.editor-summary,
.element-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.panel h2,
.panel h3 {
    margin: 0;
}

.muted {
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 16px;
}

button,
.btn {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 17px;
    border: 0;
    border-radius: 16px;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 7px 18px rgba(48, 70, 184, .18);
    cursor: pointer;
    text-decoration: none;
    font-weight: 800;
    transition: .18s ease;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(48, 70, 184, .23);
}

.btn-soft {
    color: var(--primary);
    background: var(--primary-soft);
    box-shadow: none;
}

.btn-outline {
    color: var(--primary);
    border: 1px solid var(--primary);
    background: transparent;
    box-shadow: none;
}

.btn-danger {
    color: var(--danger);
    background: #fff0f4;
    box-shadow: none;
}

.btn-small {
    min-height: 39px;
    padding: 7px 12px;
    border-radius: 13px;
    font-size: .88rem;
}

.flash,
.error {
    padding: 13px 16px;
    margin-bottom: 16px;
    border-radius: 16px;
    font-weight: 700;
}

.flash {
    color: #116c42;
    border: 1px solid #c7edd9;
    background: #ebf9f2;
}

.error {
    color: #9f2045;
    border: 1px solid #f3c7d4;
    background: #fff0f4;
}

.group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 28px 4px 12px;
}

.group-title::before {
    content: "";
    width: 8px;
    height: 30px;
    border-radius: 99px;
    background: linear-gradient(var(--primary), #6c82f2);
}

.group-title h2 {
    margin: 0;
}

.editor-card {
    overflow: hidden;
    margin-bottom: 12px;
}

.editor-card summary {
    list-style: none;
    cursor: pointer;
}

.editor-card summary::-webkit-details-marker {
    display: none;
}

.editor-summary {
    min-height: 82px;
    padding: 17px 20px;
}

.editor-summary:hover {
    background: var(--surface-2);
}

.element-name {
    display: flex;
    align-items: center;
    gap: 12px;
}

.element-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 900;
}

.element-name h3 {
    margin: 0;
}

.element-key,
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 99px;
    color: var(--muted);
    background: #f0f2f8;
    font-family: Consolas, monospace;
    font-size: .76rem;
}

.editor-body {
    padding: 0 20px 20px;
    border-top: 1px solid var(--line);
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
    gap: 18px;
    padding-top: 18px;
}

.fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.field-wide {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #303a52;
    font-weight: 800;
    font-size: .88rem;
}

input,
select,
textarea {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid #d8deeb;
    border-radius: 14px;
    color: var(--text);
    background: #fff;
    outline: 0;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(48, 70, 184, .10);
}

.color-input {
    display: grid;
    grid-template-columns: 50px 1fr;
    gap: 8px;
}

.color-input input[type="color"] {
    min-height: 48px;
    padding: 4px;
    cursor: pointer;
}

.switch-line {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
}

.switch-line input {
    width: 42px;
    min-height: 22px;
    accent-color: var(--primary);
}

.preview-card {
    position: sticky;
    top: 98px;
    min-height: 260px;
    display: grid;
    place-items: center;
    padding: 20px;
    border: 1px dashed #b9c2d7;
    border-radius: 20px;
    background:
        linear-gradient(45deg, #f5f7fc 25%, transparent 25%),
        linear-gradient(-45deg, #f5f7fc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f5f7fc 75%),
        linear-gradient(-45deg, transparent 75%, #f5f7fc 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.live-preview {
    min-width: 150px;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 800;
    transition: .18s ease;
}

.tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 3px;
    margin-bottom: 16px;
}

.tabs a {
    flex: 0 0 auto;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--muted);
    background: #fff;
    text-decoration: none;
    font-weight: 800;
}

.tabs a.active {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
}

.table-wrap {
    width: 100%;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 11px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}

th {
    color: var(--muted);
    background: #fafbff;
    font-size: .84rem;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at 15% 15%, rgba(69, 104, 242, .18), transparent 28%),
        radial-gradient(circle at 85% 85%, rgba(242, 56, 112, .12), transparent 25%),
        var(--page);
}

.auth-card {
    width: min(760px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(25, 38, 85, .14);
}

.auth-card.compact {
    width: min(480px, 100%);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.auth-brand .brand-mark {
    color: #fff;
    background: var(--primary);
}

.auth-card h1 {
    margin: 0 0 5px;
}

@media (max-width: 1180px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        width: min(310px, 88vw);
        transform: translateX(110%);
        transition: transform .2s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .page-shell {
        margin-inline-end: 0;
    }

    .menu-button {
        display: grid;
        place-items: center;
    }

    .topbar {
        padding-inline: 18px;
    }

    .content {
        width: min(100% - 24px, 1450px);
    }

    .hero,
    .editor-grid {
        grid-template-columns: 1fr;
    }

    .preview-card {
        position: static;
    }
}

@media (max-width: 620px) {
    .stats-grid,
    .fields {
        grid-template-columns: 1fr;
    }

    .topbar h1 {
        font-size: 1.15rem;
    }

    .panel,
    .auth-card {
        padding: 17px;
        border-radius: 20px;
    }

    .hero-main,
    .hero-side {
        padding: 21px;
    }

    .editor-summary {
        padding: 14px;
    }

    .editor-body {
        padding: 0 14px 14px;
    }

    .element-key {
        display: none;
    }

    .actions > * {
        flex: 1 1 auto;
    }
}
