* {
    box-sizing: border-box;
}

html {
    direction: rtl;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    background: #f4f6f8;
    color: #1f2937;
    font-family: Tahoma, Arial, sans-serif;
}

/* =========================================================
   HEADER
========================================================= */

.topbar {
    width: 100%;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;

    position: sticky;
    top: 0;

    z-index: 100;
}

.topbar-content {
    width: min(1400px, calc(100% - 40px));

    min-height: 76px;

    margin: 0 auto;

    padding: 12px 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 30px;
}

/* =========================================================
   PAGE INFO
========================================================= */

.page-info {
    min-width: 0;
}

.page-info h1 {
    margin: 0 0 5px;

    font-size: 24px;
    line-height: 1.3;

    font-weight: 800;

    color: #111827;
}

.page-info p {
    margin: 0;

    color: #6b7280;

    font-size: 13px;
    line-height: 1.6;
}

/* =========================================================
   HEADER ACTIONS
========================================================= */

.header-actions {
    display: flex;
    align-items: center;

    gap: 8px;

    flex-shrink: 0;
}

.header-actions button {
    border: 0;

    min-height: 42px;

    padding: 0 15px;

    border-radius: 9px;

    font-family: inherit;

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 7px;

    white-space: nowrap;

    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease,
        opacity 0.18s ease;
}

.header-actions button:hover {
    transform: translateY(-1px);
}

.header-actions button:active {
    transform: translateY(0);
}

.header-actions button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* =========================================================
   PREVIEW BUTTON
========================================================= */

.preview-btn {
    background: #eef2ff;
    color: #3730a3;

    border: 1px solid #e0e7ff !important;
}

.preview-btn:hover {
    background: #e0e7ff;
}

/* =========================================================
   SAVE BUTTON
========================================================= */

.save-btn {
    background: #111827;
    color: #ffffff;

    box-shadow:
        0 2px 6px rgba(17, 24, 39, 0.12);
}

.save-btn:hover {
    background: #1f2937;
}

/* =========================================================
   CLOSE BUTTON
========================================================= */

.close-btn {
    background: #ffffff;
    color: #6b7280;

    border: 1px solid #e5e7eb !important;
}

.close-btn:hover {
    background: #f9fafb;
    color: #dc2626;

    border-color: #fecaca !important;
}

.close-btn span:first-child {
    font-size: 15px;
    line-height: 1;
}

/* =========================================================
   MAIN
========================================================= */

.container {
    width: min(1400px, calc(100% - 40px));

    margin: 0 auto;

    padding: 25px 0 60px;
}

/* =========================================================
   STATUS
========================================================= */

.status {
    min-height: 0;

    margin-bottom: 15px;

    text-align: center;

    font-size: 14px;
    font-weight: 700;
}

.status-success {
    color: #15803d;
}

.status-error {
    color: #dc2626;
}

.status-loading {
    color: #2563eb;
}

/* =========================================================
   GALLERY INFO
========================================================= */

.gallery-info {
    display: flex;

    align-items: center;
    justify-content: center;

    flex-wrap: wrap;

    gap: 10px;

    margin-bottom: 25px;
}

.gallery-info > div {
    background: #ffffff;

    border: 1px solid #e5e7eb;

    border-radius: 9px;

    padding: 9px 16px;

    font-size: 13px;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.03);
}

.gallery-info strong {
    font-size: 17px;

    margin-left: 4px;

    color: #111827;
}

/* =========================================================
   GALLERY
========================================================= */

.gallery {
    width: 100%;

    display: grid;

    /*
     * 4 صور في الصف على الشاشة الكبيرة
     */
    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 22px;

    align-items: start;
}

/* =========================================================
   PHOTO CARD
========================================================= */

.photo-card {
    width: 100%;

    background: #ffffff;

    border: 1px solid #e5e7eb;

    border-radius: 13px;

    padding: 9px;

    position: relative;

    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.06);

    transition:
        opacity 0.2s ease,
        filter 0.2s ease,
        transform 0.2s ease;

    overflow: visible;
}

/* =========================================================
   IMAGE
========================================================= */

.image-wrapper {
    width: 100%;

    aspect-ratio: 1 / 1;

    overflow: hidden;

    border-radius: 9px;

    background: #eeeeee;
}

.image-wrapper img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: cover;

    user-select: none;

    -webkit-user-drag: none;
}

/* =========================================================
   DRAG HANDLE
========================================================= */

.drag-handle {
    position: absolute;

    top: 16px;
    right: 16px;

    width: 36px;
    height: 36px;

    display: flex;

    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.72);

    color: #ffffff;

    border-radius: 8px;

    font-size: 20px;
    font-weight: bold;

    cursor: grab;

    z-index: 20;

    user-select: none;

    touch-action: none;
}

.drag-handle:hover {
    background: rgba(0, 0, 0, 0.82);
}

.drag-handle:active {
    cursor: grabbing;
}

/* =========================================================
   ORDER BADGE
========================================================= */

.order-badge {
    position: absolute;

    top: 16px;
    left: 16px;

    min-width: 32px;
    height: 32px;

    padding: 0 7px;

    display: flex;

    align-items: center;
    justify-content: center;

    background: rgba(17, 24, 39, 0.88);

    color: #ffffff;

    border-radius: 8px;

    font-size: 13px;
    font-weight: 800;

    z-index: 20;
}

/* =========================================================
   VISIBILITY BUTTON
========================================================= */

.visibility-btn {
    width: 100%;

    margin-top: 9px;

    height: 40px;

    border: 1px solid #e5e7eb;

    border-radius: 8px;

    background: #f9fafb;

    color: #374151;

    display: flex;

    align-items: center;
    justify-content: center;

    gap: 7px;

    font-family: inherit;

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;

    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease;
}

.visibility-btn:hover {
    background: #f3f4f6;

    border-color: #d1d5db;
}

.visibility-icon {
    font-size: 16px;
}

/* =========================================================
   HIDDEN IMAGE
========================================================= */

.photo-card.is-hidden {
    opacity: 0.72;
}

.photo-card.is-hidden .image-wrapper img {
    filter: grayscale(100%);
}

.hidden-label {
    display: none;

    position: absolute;

    left: 50%;
    top: 50%;

    transform: translate(-50%, -50%);

    background: rgba(17, 24, 39, 0.9);

    color: #ffffff;

    padding: 8px 15px;

    border-radius: 8px;

    font-size: 13px;
    font-weight: 700;

    z-index: 15;

    white-space: nowrap;
}

.photo-card.is-hidden .hidden-label {
    display: block;
}

/* =========================================================
   SORTABLE
========================================================= */

.sortable-ghost {
    opacity: 0.25;
}

.sortable-chosen {
    cursor: grabbing;
}

.sortable-drag {
    opacity: 0.95;

    transform: rotate(2deg);

    z-index: 9999;
}

/*
 * مهم جدًا:
 * لا نغير الـ Grid أثناء السحب
 */
.is-dragging .photo-card {
    transition: none;
}

/* =========================================================
   EMPTY STATE
========================================================= */

.empty-state {
    background: #ffffff;

    border: 1px dashed #d1d5db;

    border-radius: 16px;

    padding: 70px 30px;

    text-align: center;
}

.empty-icon {
    font-size: 50px;

    margin-bottom: 15px;
}

.empty-state h2 {
    margin: 0 0 10px;

    font-size: 22px;
}

.empty-state p {
    color: #6b7280;

    font-size: 14px;
}

/* =========================================================
   RESPONSIVE - LARGE TABLET
========================================================= */

@media (max-width: 1100px) {

    .gallery {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

}

/* =========================================================
   RESPONSIVE - TABLET
========================================================= */

@media (max-width: 850px) {

    .topbar-content {
        width: calc(100% - 28px);

        gap: 15px;
    }

    .page-info h1 {
        font-size: 20px;
    }

    .page-info p {
        font-size: 12px;
    }

    .header-actions {
        gap: 6px;
    }

    .header-actions button {
        padding: 0 11px;
    }

    .gallery {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 18px;
    }

}

/* =========================================================
   RESPONSIVE - MOBILE
========================================================= */

@media (max-width: 600px) {

    .topbar-content {
        width: calc(100% - 20px);

        min-height: auto;

        padding: 12px 0;

        flex-direction: column;

        align-items: stretch;

        gap: 12px;
    }

    .page-info {
        text-align: center;
    }

    .page-info h1 {
        font-size: 19px;

        margin-bottom: 4px;
    }

    .page-info p {
        font-size: 11px;
    }

    .header-actions {
        width: 100%;

        display: grid;

        grid-template-columns:
            repeat(3, 1fr);

        gap: 6px;
    }

    .header-actions button {
        width: 100%;

        min-height: 40px;

        padding: 0 5px;

        font-size: 11px;
    }

    .container {
        width: calc(100% - 20px);

        padding-top: 18px;
    }

    .gallery {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 12px;
    }

    .photo-card {
        padding: 7px;

        border-radius: 10px;
    }

    .image-wrapper {
        border-radius: 7px;
    }

    .drag-handle {
        top: 12px;
        right: 12px;

        width: 30px;
        height: 30px;

        font-size: 17px;
    }

    .order-badge {
        top: 12px;
        left: 12px;

        min-width: 28px;
        height: 28px;

        font-size: 11px;
    }

    .visibility-btn {
        height: 36px;

        margin-top: 7px;

        font-size: 11px;
    }

}

/* =========================================================
   VERY SMALL MOBILE
========================================================= */

@media (max-width: 380px) {

    .gallery {
        grid-template-columns:
            1fr;
    }

    .header-actions button {
        font-size: 10px;
    }

}
/* =========================================================
   PRIORITY BUTTON
========================================================= */

.priority-btn {
    width: 100%;
    height: 48px;

    margin-top: 10px;

    border: 2px solid #d1d5db;
    border-radius: 10px;

    background: #ffffff;
    color: #374151;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 9px;

    font-size: 15px;
    font-weight: 800;

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.2s ease;
}


/* =========================================================
   STAR
========================================================= */

.priority-icon {
    font-size: 22px;
    line-height: 1;
    transition: transform 0.2s ease;
}


/* =========================================================
   HOVER
========================================================= */

.priority-btn:hover {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #15803d;

    transform: translateY(-1px);

    box-shadow:
        0 4px 12px rgba(34, 197, 94, 0.15);
}


/* =========================================================
   ACTIVE
========================================================= */

.priority-btn.active {
    background: #16a34a;
    border-color: #16a34a;

    color: #ffffff;

    box-shadow:
        0 5px 15px rgba(22, 163, 74, 0.25);
}


.priority-btn.active .priority-icon {
    transform: scale(1.15);
}


/* =========================================================
   ACTIVE HOVER
========================================================= */

.priority-btn.active:hover {
    background: #15803d;
    border-color: #15803d;

    color: #ffffff;

    transform: translateY(-1px);
}


/* =========================================================
   CLICK
========================================================= */

.priority-btn:active {
    transform: scale(0.98);
}


/* =========================================================
   PHOTO ACTIONS
========================================================= */

.photo-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}
/* =========================================================
/* ================================
   UPLOAD BUTTON
================================ */

.upload-btn {
    border: 0;
    border-radius: 10px;
    padding: 12px 18px;

    background: #2563eb;
    color: #ffffff;

    font-size: 14px;
    font-weight: 700;

    cursor: pointer;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 9px;

    transition: 0.2s ease;
}

.upload-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.upload-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}


/* أيقونة الإضافة */

.upload-icon {
    width: 24px;
    height: 24px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-size: 22px;
    font-weight: 400;

    line-height: 1;
}


/* عداد الصور الجديدة */

.new-images-count {
    min-width: 24px;
    height: 24px;

    padding: 0 6px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #ffffff;
    color: #2563eb;

    font-size: 12px;
    font-weight: 800;

    line-height: 1;

    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* =========================================================
NEW IMAGE
========================================================= */

.photo-card.is-new {
box-shadow:
0 0 0 2px rgba(4, 120, 87, 0.18),
0 6px 20px rgba(0, 0, 0, 0.08);
}

.new-image-label {
position: absolute;

```
top: 17px;

right: 62px;

z-index: 25;

background: #047857;

color: #ffffff;

padding: 7px 11px;

border-radius: 8px;

font-size: 12px;

font-weight: 800;

pointer-events: none;
```

}

/* =========================================================
RESPONSIVE UPLOAD
========================================================= */

@media (max-width: 700px) {

```
.upload-btn {
    padding: 11px 12px;

    font-size: 13px;
}

.new-image-label {
    right: 55px;

    font-size: 11px;

    padding: 6px 8px;
}
```

}
