@font-face {
    font-family: Pinar;
    src: url("fonts/Pinar-Regular.ttf") format("truetype");
    font-display: swap;
}

.form-stack {
    display: grid;
    gap: 0.5rem;
    max-width: 420px;
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.field {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.error {
    color: #FF7A85;
}

.success {
    color: #5FD39A;
}

/* کاشی والپیپر خود مرکز یک label است که پنجرهٔ انتخاب فایل را باز می‌کند. */
.custom-tile-form {
    display: contents;
}

.custom-tile {
    position: relative;
    cursor: pointer;
}

.custom-tile:hover {
    border-color: #4A4A55;
    background: #15151B;
}

.custom-tile:focus-within {
    outline: 2px solid #7A4DEB;
    outline-offset: 2px;
}

.panel-content .custom-tile input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.custom-tile.uploading {
    pointer-events: none;
    opacity: 0.7;
}

.panel-content {
    color-scheme: dark;
}

.panel-content h1 {
    margin: 0 0 16px;
    font-size: 30px;
    font-weight: 600;
}

.panel-content h2 {
    margin: 32px 0 12px;
    font-size: 20px;
    font-weight: 600;
}

.panel-content a {
    color: #A67CFF;
}

.panel-content input:not([type="checkbox"]),
.panel-content select {
    height: 40px;
    box-sizing: border-box;
    padding: 0 12px;
    border-radius: 8px;
    font: inherit;
    color: #F4F3F8;
    background: #101014;
    border: 1px solid #36363F;
    outline: none;
}

.panel-content input:focus,
.panel-content select:focus {
    border-color: #8B5CF6;
}

.panel-content button {
    height: 40px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    color: #FFFFFF;
    background: #7A4DEB;
}

.panel-content button:hover {
    background: #8B5CF6;
}

.panel-content code {
    padding: 2px 6px;
    border-radius: 6px;
    background: #1A1A21;
}

.panel-content .computers-table th {
    color: #9C9CA8;
    font-weight: 400;
}

.panel-content .computers-table th,
.panel-content .computers-table td {
    border-bottom-color: #2A2A32;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px 16px;
}

.form-grid label {
    display: grid;
    gap: 6px;
    align-content: start;
}

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

.panel-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
    gap: 16px;
}

.panel-section {
    box-sizing: border-box;
    padding: 20px 24px;
    border: 1px solid #2A2A32;
    border-inline-start: 4px solid #7A4DEB;
    background: #101014;
}

.panel-content .panel-section h2 {
    margin-top: 0;
}

.save-state {
    color: #6FCF97;
}

.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}

.panel-content .settings-tabs a {
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 14px;
    text-decoration: none;
    color: #C9C9D3;
    border: 1px solid #2A2A32;
}

.panel-content .settings-tabs a.active {
    color: #FFFFFF;
    background: #7A4DEB;
    border-color: #7A4DEB;
}

/* سروری که همین حالا به هاب وصل است. */
.presence {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #8A8A96;
}

.presence::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4A4A55;
}

.presence.on {
    color: #3DDC97;
}

.presence.on::before {
    background: #3DDC97;
    box-shadow: 0 0 6px #3DDC97;
}

/* پس‌زمینه‌ها: کاشی‌ها به نسبت صفحهٔ کلاینت، تا پیش‌نمایش همان برش را نشان دهد. */
.background-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    width: 100%;
}

.background-tile {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 8px;
    border: 1px solid #2A2A32;
    border-radius: 12px;
    color: inherit;
    text-align: start;
    background: #101014;
}

/* کاشی دکمه است، پس باید رنگ و اندازهٔ دکمه‌های عمومی پنل را کنار بگذارد. */
.panel-content button.background-tile {
    min-height: 0;
    min-width: 0;
    height: auto;
    padding: 8px;
    border: 1px solid #2A2A32;
    border-radius: 12px;
    font-size: inherit;
    color: inherit;
    background: #101014;
    cursor: pointer;
}

.panel-content button.background-tile:hover {
    border-color: #4A4A55;
    background: #15151B;
}

.panel-content .background-tile.selected,
.panel-content .background-tile.selected:hover {
    border-color: #7A4DEB;
    box-shadow: 0 0 0 2px #7A4DEB55;
    background: #7A4DEB14;
}

.background-tile img,
.background-tile video {
    display: block;
    pointer-events: none;
}

.background-tile img,
.background-tile video,
.tile-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    object-fit: cover;
    background: #1A1A21;
}

.tile-placeholder {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 6px;
    color: #6E6E7A;
}

.tile-placeholder svg {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tile-placeholder.custom {
    border: 1px dashed #4A4A55;
}

.tile-placeholder small {
    padding: 0 10px;
    font-size: 12px;
    text-align: center;
}

.tile-caption,
.background-tile figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    color: #C9C9D3;
}

.panel-content label.ghost.upload {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    border: 1px solid #36363F;
    border-radius: 10px;
    font-size: 14px;
    color: #C9C9D3;
}

.panel-content label.ghost.upload:hover {
    color: #F4F3F8;
    border-color: #8B5CF6;
}

.panel-content .upload {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.panel-content .upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.panel-content .background-search {
    width: min(360px, 100%);
    margin: 6px 0 4px;
}

.background-group {
    margin-top: 22px;
}

.background-group h2,
.background-group-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 18px 0 10px;
    font-size: 15px;
}

.background-tile input {
    width: 100%;
    min-width: 0;
}

.tile-caption {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* نشان پخش تا ویدیو از تصویر جدا شود؛ با پخش شدن کنار می‌رود. */
.video-preview {
    position: relative;
    display: block;
}

.video-preview .play-badge {
    position: absolute;
    inset-inline-end: 8px;
    bottom: 8px;
    width: 26px;
    height: 26px;
    padding: 5px;
    border-radius: 50%;
    fill: #FFFFFF;
    background: #00000099;
    pointer-events: none;
    transition: opacity 0.2s;
}

.background-tile:hover .play-badge,
.background-tile:focus-within .play-badge {
    opacity: 0;
}

/* جدول فهرست‌ها؛ با کلیک روی هر ردیف ویرایشگر از کنار صفحه باز می‌شود. */
.grid-card {
    padding: 16px 18px 18px;
    border: 1px solid #2A2A32;
    border-radius: 14px;
    background: #101014;
}

.grid-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.grid-toolbar input[type="search"] {
    flex: 1 1 240px;
    min-width: 0;
}

.grid-toolbar select {
    flex: 0 1 200px;
}

.grid-count {
    font-size: 13px;
    color: #6E6E7A;
    white-space: nowrap;
}

.grid-toolbar .grid-count:last-child,
.grid-toolbar button:last-child {
    margin-inline-start: auto;
}

.grid-toolbar .toolbar-push {
    margin-inline-start: auto;
}

.toolbar-more {
    position: relative;
}

.toolbar-more > button {
    min-width: 38px;
    font-size: 18px;
    line-height: 1;
}

.toolbar-more-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.toolbar-more-menu {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    z-index: 41;
    display: grid;
    gap: 12px;
    min-width: 300px;
    padding: 14px 16px;
    border: 1px solid #2A2A32;
    border-radius: 12px;
    background: #15151B;
    box-shadow: 0 12px 32px #00000080;
}

.grid-scroll {
    overflow-x: auto;
    border: 1px solid #22222A;
    border-radius: 10px;
}

.data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-grid th {
    position: sticky;
    top: 0;
    padding: 10px 14px;
    text-align: start;
    font-size: 12px;
    font-weight: 400;
    color: #9C9CA8;
    white-space: nowrap;
    background: #15151B;
    border-bottom: 1px solid #2A2A32;
}

.data-grid th button.sort {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.data-grid th button.sort:hover,
.data-grid th[aria-sort="ascending"] button.sort,
.data-grid th[aria-sort="descending"] button.sort {
    color: #E8E8EE;
}

.data-grid td {
    padding: 11px 14px;
    color: #E4E3EA;
    border-bottom: 1px solid #1C1C23;
    vertical-align: middle;
}

.data-grid tbody tr:last-child td {
    border-bottom: 0;
}

.data-grid tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.data-grid tbody tr:hover {
    background: #17171E;
}

.data-grid tbody tr:focus-visible {
    outline: 2px solid #A67CFF;
    outline-offset: -2px;
}

.data-grid tbody tr.selected {
    background: #7A4DEB1F;
    box-shadow: inset 3px 0 0 #7A4DEB;
}

[dir="rtl"] .data-grid tbody tr.selected {
    box-shadow: inset -3px 0 0 #7A4DEB;
}

.data-grid .strong {
    color: #F4F3F8;
    font-weight: 600;
}

.data-grid .sub {
    color: #9C9CA8;
}

.data-grid .number {
    width: 1%;
    color: #9C9CA8;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.data-grid .cell-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.grid-empty {
    margin: 14px 2px 0;
    font-size: 14px;
    color: #6E6E7A;
}

/* ویرایشگر وسط صفحه باز می‌شود و جدول پشتش تیره می‌ماند؛ با کلیک بیرون، Esc یا دکمهٔ بستن کنار می‌رود. */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: #00000099;
    backdrop-filter: blur(2px);
    animation: modal-fade 0.15s ease-out;
}

.panel-content .modal {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 21;
    box-sizing: border-box;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    margin: 0;
    padding: 24px 24px 26px;
    overflow-y: auto;
    border: 1px solid #2A2A32;
    border-radius: 16px;
    background: #101014;
    box-shadow: 0 24px 60px #000000A0;
    transform: translate(-50%, -50%);
    animation: modal-in 0.18s ease-out;
}

.panel-content .modal.wide {
    width: min(760px, calc(100vw - 32px));
}

.panel-content .modal-close {
    position: absolute;
    top: 16px;
    inset-inline-end: 16px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: #9C9CA8;
    background: transparent;
    border: 1px solid #2A2A32;
}

.panel-content .modal-close:hover {
    color: #F4F3F8;
    background: #1A1A21;
}

.modal-close svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

/* در ویرایشگرهای زبانه‌دار خود پنجره پیمایش نمی‌شود: دکمهٔ بستن و زبانه‌ها بالا می‌مانند
   و فقط محتوای زیر زبانه‌ها پیمایش می‌شود. */
.panel-content .modal:has(> form > .editor-tabs) {
    --modal-pad: 24px;
    display: flex;
    flex-direction: column;
    padding-inline: var(--modal-pad);
    overflow: hidden;
}

.panel-content .modal:has(> form > .editor-tabs) > form {
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    min-height: 0;
}

.panel-content .modal:has(> form > .editor-tabs) > form > .editor-tabs,
.panel-content .modal:has(> form > .editor-tabs) > form > .actions {
    flex: none;
    padding-inline-end: 160px;
}

/* نام زبانه دو خط نمی‌شود. */
.panel-content .modal .editor-tabs button {
    white-space: nowrap;
}

.panel-content .modal:has(> form > .editor-tabs) > form > .actions {
    padding-inline-end: 0;
}

.panel-content .modal:has(> form > .editor-tabs) > form > fieldset,
.panel-content .modal:has(> form > .editor-tabs) > :not(form):not(.modal-close) {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    /* نوار پیمایش به لبهٔ پنجره می‌چسبد، نه به حاشیهٔ داخلی آن. */
    margin-inline: calc(-1 * var(--modal-pad, 24px));
    padding-inline: var(--modal-pad, 24px);
}

/* عنوان کنار دکمه‌های بستن و ذخیره جا باز می‌کند؛ فرمی که بی‌عنوان و بی‌زبانه شروع می‌شود زیر آن‌ها. */
.modal > :first-child + :not(form) {
    padding-inline-end: 160px;
}

.modal > :first-child + form:not(:has(> .editor-tabs)) {
    margin-top: 44px;
}

/* دکمهٔ ذخیره کنار دکمهٔ بستن، بالای پنجره. */
.panel-content .modal > form .actions > button[type="submit"] {
    position: absolute;
    top: 16px;
    inset-inline-end: 60px;
    z-index: 2;
    height: 34px;
    min-height: 0;
    padding: 0 18px;
}

.grid-card > [role="alert"],
.modal > [role="alert"] {
    margin: 0 0 12px;
    font-size: 14px;
}

@keyframes modal-in {
    from {
        transform: translate(-50%, -48%) scale(0.98);
        opacity: 0;
    }
}

@keyframes modal-fade {
    from {
        opacity: 0;
    }
}

/* در جدول دستگاه‌ها نوع و گروه همان‌جا عوض می‌شوند. */
.data-grid .cell-edit {
    cursor: default;
}

.panel-content .data-grid .cell-edit select {
    width: 100%;
    min-width: 140px;
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
    background: #0B0B0E;
    border-color: #2A2A32;
}

.panel-content .data-grid .cell-edit select:hover {
    border-color: #4A4A55;
}

/* در گوشی زبانه‌ها زیر دکمه‌های ذخیره و بستن می‌آیند و به خط بعد می‌شکنند. */
@media (max-width: 720px) {
    .panel-content .modal:has(> form > .editor-tabs) > form > .editor-tabs {
        flex-wrap: wrap;
        margin-top: 44px;
        padding-inline-end: 0;
    }
}
