/* =========================================================
   SHAM GOLDEN
   الصفحة الرئيسية
   تصميم البطاقات مستوحى من بطاقة المشروع القديم
   ========================================================= */

:root {
    --home-bg: #0f0f11;
    --home-card: #18181c;
    --home-card-hover: #202026;

    --home-gold: #d4af37;
    --home-gold-light: #f3e5ab;

    --home-gold-soft: rgba(212, 175, 55, 0.10);
    --home-gold-border: rgba(212, 175, 55, 0.25);

    --home-text: #f5f5f7;
    --home-muted: #a1a1a6;

    --home-radius-lg: 18px;
    --home-radius-md: 12px;

    --home-shadow:
        0 10px 30px rgba(0, 0, 0, 0.25);

    --home-gold-shadow:
        0 10px 30px rgba(212, 175, 55, 0.15);
}


/* =========================================================
   الصفحة
   ========================================================= */

body {
    background: var(--home-bg);
    color: var(--home-text);
}


/* =========================================================
   شبكة الأنظمة
   ========================================================= */

#featured {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(280px, 1fr));

    gap: 25px;

    width: 100%;
    align-items: stretch;
}


/* =========================================================
   البطاقة
   ========================================================= */

.system-card,
.gallery-card {

    width: 100%;

    background: var(--home-card);

    border: 1px solid var(--home-gold-border);

    border-radius: var(--home-radius-lg);

    overflow: hidden;

    display: flex;

    flex-direction: column;

    padding: 15px;

    position: relative;

    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.30);

    transition:
        transform 0.30s ease,
        box-shadow 0.30s ease,
        border-color 0.30s ease,
        background 0.30s ease;

    min-width: 0;
}


/* ارتفاع البطاقات متقارب */

.system-card {
    height: 100%;
}


/* Hover */

.system-card:hover,
.gallery-card:hover {

    transform: translateY(-5px);

    background: var(--home-card-hover);

    border-color: var(--home-gold);

    box-shadow: var(--home-gold-shadow);
}


/* =========================================================
   صورة البطاقة
   ========================================================= */

.system-card .card-img-holder,
.gallery-card .card-img-holder {

    position: relative;

    width: 100%;

    overflow: hidden;

    flex-shrink: 0;
}


.system-card .card-img-holder img,
.gallery-card .card-img-holder img {

    width: 100%;

    height: 210px;

    display: block;

    object-fit: contain;

    border-radius: var(--home-radius-md);

    background: #111;

    transition:
        transform 0.35s ease;
}


.system-card:hover .card-img-holder img,
.gallery-card:hover .card-img-holder img {

    transform: scale(1.025);
}


/* =========================================================
   كود النظام
   ========================================================= */

.system-card .badge-code,
.gallery-card .badge-code {

    position: absolute;

    top: 12px;

    left: 12px;

    z-index: 5;

    padding: 6px 12px;

    border-radius: 20px;

    background:
        rgba(15, 15, 17, 0.88);

    border: 1px solid var(--home-gold-border);

    color: var(--home-gold);

    font-size: 0.75rem;

    font-weight: 800;

    line-height: 1;

    white-space: nowrap;

    backdrop-filter: blur(8px);
}


/* =========================================================
   التصنيف
   ========================================================= */

.system-card .badge-category,
.gallery-card .badge-category {

    position: absolute;

    top: 12px;

    right: 12px;

    z-index: 5;

    padding: 6px 12px;

    border-radius: 20px;

    background:
        rgba(15, 15, 17, 0.88);

    border: 1px solid var(--home-gold-border);

    color: var(--home-gold);

    font-size: 0.75rem;

    font-weight: 700;

    line-height: 1;

    white-space: nowrap;

    max-width: calc(100% - 24px);

    overflow: hidden;

    text-overflow: ellipsis;

    backdrop-filter: blur(8px);
}


/* =========================================================
   جسم البطاقة
   ========================================================= */

.system-card .gallery-info,
.gallery-card .gallery-info {

    display: flex;

    flex-direction: column;

    flex: 1;

    min-width: 0;

    padding: 10px 0 0;
}


/* =========================================================
   اسم النظام
   ========================================================= */

.system-card .gallery-info h3,
.gallery-card .gallery-info h3 {

    color: var(--home-gold);

    font-size: 1.12rem;

    font-weight: 800;

    line-height: 1.55;

    margin: 0 0 5px;

    text-align: right;

    min-height: 35px;

    display: -webkit-box;

    -webkit-box-orient: vertical;

    -webkit-line-clamp: 2;
    line-clamp: 2;

    overflow: hidden;
}


/* =========================================================
   الوصف
   ========================================================= */

.system-card .project-summary,
.gallery-card .project-summary,
.system-card .gallery-info p,
.gallery-card .gallery-info p {

    color: var(--home-muted);

    font-size: 0.82rem;

    line-height: 1.65;

    margin: 0;

    min-height: 42px;

    display: -webkit-box;

    -webkit-box-orient: vertical;

    -webkit-line-clamp: 2;
    line-clamp: 2;

    overflow: hidden;
}


/* =========================================================
   السعر
   ========================================================= */

.system-price {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 10px;

    margin-top: 9px;

    padding: 7px 10px;

    border-radius: var(--home-radius-md);

    background: var(--home-gold-soft);

    border: 1px solid var(--home-gold-border);
}


.system-price .price-label {

    color: var(--home-muted);

    font-size: 0.76rem;

    font-weight: 600;
}


.system-price strong {

    color: var(--home-gold-light);

    font-size: 0.92rem;

    font-weight: 900;

    white-space: nowrap;
}


/* =========================================================
   الصف الرئيسي
   💬 + معاينة والتفاصيل
   ========================================================= */

.system-card .card-main-actions,
.gallery-card .card-main-actions {

    display: flex;

    align-items: stretch;

    gap: 8px;

    width: 100%;

    margin-top: 12px;
}


/* زر الدردشة المربع */

.system-card .btn-chat-icon,
.gallery-card .btn-chat-icon {

    width: 45px;

    min-width: 45px;

    height: 42px;

    display: flex;

    align-items: center;

    justify-content: center;

    background:
        var(--home-gold-soft);

    border: 1px solid var(--home-gold-border);

    color: var(--home-gold);

    border-radius: var(--home-radius-md);

    text-decoration: none;

    font-size: 1rem;

    transition:
        background 0.25s ease,
        color 0.25s ease,
        transform 0.25s ease;
}


.system-card .btn-chat-icon:hover,
.gallery-card .btn-chat-icon:hover {

    background: var(--home-gold);

    color: #0d0d0d;

    transform: translateY(-1px);
}


/* زر التفاصيل */

.system-card .btn-preview,
.gallery-card .btn-preview {

    flex: 1;

    min-width: 0;

    height: 42px;

    padding: 8px 12px;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 7px;

    background:
        var(--home-gold-soft);

    border: 1px solid var(--home-gold-border);

    color: var(--home-gold-light);

    border-radius: var(--home-radius-md);

    text-decoration: none;

    font-size: 0.78rem;

    font-weight: 800;

    white-space: nowrap;

    transition:
        background 0.25s ease,
        color 0.25s ease;
}


.system-card .btn-preview:hover,
.gallery-card .btn-preview:hover {

    background: var(--home-gold);

    color: #0d0d0d;
}


/* =========================================================
   الصف السفلي
   3 أزرار متساوية تمامًا
   ========================================================= */

.system-card .card-sub-actions,
.gallery-card .card-sub-actions {

    display: flex;

    align-items: stretch;

    gap: 8px;

    width: 100%;

    margin-top: 8px;
}


.system-card .btn-sub-action,
.gallery-card .btn-sub-action {

    flex: 1;

    min-width: 0;

    height: 38px;

    padding: 6px 7px;

    display: flex;

    align-items: center;

    justify-content: center;

    gap: 5px;

    border: 0;

    border-radius: var(--home-radius-md);

    background:
        linear-gradient(
            135deg,
            #bf953f,
            #fcf6ba,
            #b38728
        );

    color: #0d0d0d;

    text-decoration: none;

    font-size: 0.72rem;

    font-weight: 800;

    white-space: nowrap;

    overflow: hidden;

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease,
        filter 0.25s ease;
}


.system-card .btn-sub-action:hover,
.gallery-card .btn-sub-action:hover {

    transform: translateY(-2px);

    filter: brightness(1.05);

    box-shadow:
        0 5px 14px
        rgba(212, 175, 55, 0.20);
}


.system-card .btn-sub-action span,
.gallery-card .btn-sub-action span {

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;
}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 700px) {

    #featured {

        grid-template-columns:
            repeat(
                auto-fill,
                minmax(260px, 1fr)
            );

        gap: 18px;
    }


    .system-card,
    .gallery-card {

        padding: 13px;
    }


    .system-card .card-img-holder img,
    .gallery-card .card-img-holder img {

        height: 195px;
    }


    .system-card .btn-sub-action,
    .gallery-card .btn-sub-action {

        font-size: 0.68rem;

        gap: 3px;

        padding-left: 4px;

        padding-right: 4px;
    }
}


/* =========================================================
   شاشات صغيرة جدًا
   ========================================================= */

@media (max-width: 380px) {

    #featured {

        grid-template-columns: 1fr;

    }


    .system-card .card-img-holder img,
    .gallery-card .card-img-holder img {

        height: 190px;
    }


    .system-card .btn-preview span,
    .gallery-card .btn-preview span {

        font-size: 0.74rem;
    }
}

/* Respect the shared theme when the light-mode toggle is active. */
body.light-mode {
    --home-bg: #f8f9fa;
    --home-card: #ffffff;
    --home-card-hover: #f1f3f5;
    --home-text: #1a1a1a;
    --home-muted: #62666b;
    --home-gold-soft: rgba(191, 149, 63, 0.10);
    --home-gold-border: rgba(191, 149, 63, 0.38);
    background: radial-gradient(circle at top right, rgba(212,175,55,.13), transparent 30%), #f8f9fa;
    color: var(--home-text);
}

/* Shared product layout: reserve the same information rows even without a summary. */
#featured, .systems-grid, .sector-system-list {
    grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr));
    grid-auto-rows: 1fr;
    align-items: stretch;
}
.system-card .card-img-holder img {
    height: auto;
    aspect-ratio: 16 / 10;
    margin-bottom: 0;
    object-fit: contain;
}
.system-card .badge-code {
    top: auto;
    bottom: 10px;
    max-width: calc(100% - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
}
.system-card .gallery-info {
    display: grid;
    grid-template-rows: 3.5rem 2.8rem auto 44px 44px;
    gap: 8px;
    align-content: start;
}
.system-card .gallery-info h3 {
    grid-row: 1;
    min-height: 0;
    margin: 0;
    overflow-wrap: anywhere;
}
.system-card .gallery-info .project-summary {
    grid-row: 2;
    min-height: 0;
    margin: 0;
    overflow-wrap: anywhere;
}
.system-card .system-price { grid-row: 3; margin-top: 0; min-height: 44px; flex-wrap: wrap; }
.system-card .system-price strong { white-space: normal; overflow-wrap: anywhere; }
.system-card .card-main-actions { grid-row: 4; margin-top: 0; }
.system-card .card-sub-actions { grid-row: 5; margin-top: 0; }
.system-card .btn-preview, .system-card .btn-chat-icon, .system-card .btn-sub-action { height: 44px; }

/* Reference image badges: two independent columns keep code and category apart. */
:is(.system-card,.gallery-card) .card-img-holder {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);isolation:isolate;}
:is(.system-card,.gallery-card) .card-img-holder > img {grid-area:1 / 1 / 2 / 3;min-width:0;}
:is(.system-card,.gallery-card) .card-img-holder > :is(.badge-code,.badge-category) {position:relative;inset:auto;top:auto;right:auto;left:auto;grid-row:1;align-self:start;max-width:calc(100% - 16px);margin:12px 8px;padding:7px 12px;white-space:normal;overflow-wrap:anywhere;line-height:1.5;min-height:38px;border:1px solid var(--border-gold);border-radius:22px;background:rgba(15,15,17,.85);color:var(--gold-primary);backdrop-filter:blur(8px);z-index:3;font-size:12px;}
:is(.system-card,.gallery-card) .card-img-holder > .badge-category {grid-column:1;justify-self:start;text-align:center;}
:is(.system-card,.gallery-card) .card-img-holder > .badge-code {grid-column:2;justify-self:end;direction:ltr;text-align:center;cursor:pointer;}
@media(max-width:420px){:is(.system-card,.gallery-card) .card-img-holder > :is(.badge-code,.badge-category){font-size:11px;padding:6px 9px;margin:9px 6px;max-width:calc(100% - 12px);}}
