/* ==========================================================================
   Khamen (خمّن) — Auth & Account pages
   Visual port of the prototype (login / register / forgot / reset / profile)
   onto the site's kh- design system. Plain CSS on top of Bootstrap 5 RTL.
   Loaded only on auth + account screens via @push('styles').
   ========================================================================== */

/* ---- Auth screens (login / register / forgot / reset) ---- */
.kh-auth {
    min-height: calc(100vh - 66px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    background: linear-gradient(160deg, #2D1B69 0%, #1A0A2E 100%);
}

.kh-auth-card {
    width: 100%;
    max-width: 480px;
    background: var(--kh-bg);
    border-radius: var(--kh-radius-xl);
    box-shadow: var(--kh-shadow-lg);
    padding: 2.5rem 2rem;
}

.kh-auth-card h1 {
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: .35rem;
    color: var(--kh-dark);
}

.kh-auth-subtitle {
    color: var(--kh-gray);
    margin-bottom: 1.75rem;
}

/* Brand avatar badge ("خ" / 🔑 / 👤) */
.kh-avatar-circle {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--kh-gradient-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 900;
    box-shadow: var(--kh-shadow-glow);
}

.kh-avatar-circle-sm {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
    box-shadow: none;
}

/* Free-game note on the register card */
.kh-auth-note {
    background: rgba(16, 185, 129, .1);
    border: 1px solid var(--kh-success);
    color: #0b8a63;
    border-radius: var(--kh-radius-md);
    padding: .85rem 1rem;
    text-align: center;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.kh-auth-card .form-label { font-weight: 600; color: var(--kh-dark); }
.kh-auth-card .form-control,
.kh-auth-card .form-select {
    padding: .7rem .9rem;
    border-radius: var(--kh-radius-md);
    border: 2px solid var(--border);
    background: var(--kh-bg-surface);
}
.kh-auth-card .form-control:focus,
.kh-auth-card .form-select:focus {
    border-color: var(--kh-primary);
    box-shadow: 0 0 0 3px rgba(107, 10, 111, .12);
}

.kh-auth-foot { color: var(--kh-gray); }
.kh-auth-foot a { color: var(--kh-primary); font-weight: 700; text-decoration: none; }
.kh-auth-foot a:hover { text-decoration: underline; }

/* ---- Account shell (profile / dashboard) ---- */
.kh-account {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - 66px);
    background: var(--kh-bg-surface);
}

.kh-account-side {
    background: var(--kh-bg);
    border-inline-end: 1px solid var(--border);
    padding: 1.75rem 1rem;
    position: sticky;
    top: 66px;
    align-self: start;
    height: calc(100vh - 66px);
    overflow-y: auto;
}

.kh-side-head { text-align: center; margin-bottom: 1.5rem; }
.kh-side-name { font-size: 1.05rem; font-weight: 800; margin: .5rem 0 .1rem; color: var(--kh-dark); }
.kh-side-email { font-size: .82rem; color: var(--kh-gray-light); margin: 0; word-break: break-all; }

.kh-side-nav { display: flex; flex-direction: column; gap: .25rem; }
.kh-side-nav form { display: contents; } /* let the logout button be a direct flex child */
.kh-side-nav a,
.kh-side-nav button {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .7rem 1rem;
    border-radius: var(--kh-radius-md);
    font-weight: 600;
    font-size: .92rem;
    color: var(--kh-gray);
    text-decoration: none;
    transition: all .2s ease;
}
.kh-side-nav a:hover,
.kh-side-nav button:hover { background: var(--kh-primary-bg); color: var(--kh-primary); }
.kh-side-nav a.active {
    background: var(--kh-primary-bg);
    color: var(--kh-primary);
    border-inline-start: 3px solid var(--kh-primary);
}
.kh-side-nav a .ic,
.kh-side-nav button .ic { width: 22px; text-align: center; font-size: 1rem; }
.kh-side-nav .text-danger:hover { background: rgba(239, 68, 68, .1); color: var(--kh-danger); }

.kh-account-main { padding: 2rem; }
.kh-account-main h1 { font-size: 1.5rem; font-weight: 800; color: var(--kh-dark); margin-bottom: 1.5rem; }

/* Profile summary card */
.kh-profile-head {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}
.kh-profile-head .kh-avatar-circle { margin: 0; flex-shrink: 0; }
.kh-profile-head img.kh-avatar-img {
    width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
    box-shadow: var(--kh-shadow-glow);
}

/* ---- Dashboard ---- */
.kh-dash-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.kh-dash-head h1 { font-size: 1.5rem; font-weight: 800; color: var(--kh-dark); }

.kh-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.kh-stat-card { text-align: center; padding: 1.25rem 1rem; }
.kh-stat-ic { font-size: 1.6rem; margin-bottom: .4rem; }
.kh-stat-val { font-size: 1.8rem; font-weight: 900; color: var(--kh-primary); line-height: 1; }
.kh-stat-label { font-size: .82rem; color: var(--kh-gray); margin-top: .35rem; }

.kh-games-list { display: flex; flex-direction: column; gap: .75rem; }
.kh-game-row { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1rem 1.25rem; flex-wrap: wrap; }
.kh-game-main { flex: 1 1 auto; min-width: 0; }
.kh-game-score { display: flex; align-items: center; gap: .5rem; font-size: .9rem; flex-wrap: wrap; }
.kh-game-score b { color: var(--kh-dark); }

.kh-badge { padding: .25rem .75rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.kh-badge-draft       { background: #EFEFF5; color: var(--kh-gray); }
.kh-badge-in_progress { background: rgba(0, 180, 216, .12); color: #0883a3; }
.kh-badge-completed   { background: rgba(16, 185, 129, .12); color: #0b8a63; }
.kh-badge-abandoned   { background: rgba(239, 68, 68, .12); color: var(--kh-danger); }

/* ---- بند 5 — "ألعابي السابقة" redesigned card grid (Sin Game style) ---- */
.kh-mg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
    gap: 1.1rem;
}
.kh-mg-card {
    display: flex;
    flex-direction: column;
    background: var(--kh-card, #fff);
    border: 1px solid var(--border, #ECECF3);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--kh-shadow-md);
    transition: transform .15s ease, box-shadow .15s ease;
}
.kh-mg-card:hover { transform: translateY(-2px); box-shadow: var(--kh-shadow-lg); }
.kh-mg-card-abandoned { opacity: .8; }

.kh-mg-head { background: var(--kh-gradient-primary); color: #fff; padding: 14px 16px 16px; }
.kh-mg-head-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .55rem; }
.kh-mg-head .kh-badge { background: rgba(255, 255, 255, .22); color: #fff; }
.kh-mg-plays { font-size: .72rem; font-weight: 700; background: rgba(0, 0, 0, .18); color: #fff; padding: .2rem .55rem; border-radius: 999px; white-space: nowrap; }
.kh-mg-name {
    display: block; color: #fff; font-weight: 800; font-size: 1.08rem; text-decoration: none;
    line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kh-mg-name:hover { color: #fff; text-decoration: underline; }
.kh-mg-date { font-size: .76rem; color: rgba(255, 255, 255, .85); margin-top: .2rem; }

.kh-mg-cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: var(--border, #ECECF3); }
.kh-mg-cats-special { grid-template-columns: 1fr; }
.kh-mg-cat { position: relative; aspect-ratio: 1 / 1; background: #F7F7FB; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.kh-mg-cats-special .kh-mg-cat { aspect-ratio: 16 / 7; }
.kh-mg-cat img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.kh-mg-cat-emoji { font-size: 1.9rem; }
.kh-mg-cat-label {
    position: absolute; inset-inline: 0; bottom: 0; z-index: 1;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .72));
    color: #fff; font-size: .64rem; font-weight: 700; text-align: center;
    padding: 12px 4px 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.kh-mg-score { display: flex; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap; font-size: .86rem; padding: 12px 14px 0; }
.kh-mg-score b { color: var(--kh-dark); font-size: 1rem; }
.kh-mg-team { color: var(--kh-gray); }
.kh-mg-team.is-winner { color: var(--kh-dark); font-weight: 800; }
.kh-mg-dash { color: var(--kh-gray-light, #B8B8C8); }

.kh-mg-card .kh-game-progress { margin: 12px 14px 0; }

.kh-mg-actions { display: flex; align-items: center; gap: .5rem; padding: 14px; margin-top: auto; }
.kh-mg-actions .flex-grow-1 { flex: 1 1 auto; }

@media (max-width: 400px) {
    .kh-mg-grid { grid-template-columns: 1fr; }
}

/* ---- Responsive: collapse the sidebar into a horizontal scroller ---- */
@media (max-width: 991.98px) {
    .kh-account { grid-template-columns: 1fr; }
    .kh-account-side {
        position: relative;
        top: 0;
        height: auto;
        border-inline-end: none;
        border-bottom: 1px solid var(--border);
        padding: 1rem;
    }
    .kh-side-head { display: none; }
    .kh-side-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: .4rem;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }
    .kh-side-nav a,
    .kh-side-nav button {
        white-space: nowrap;
        width: auto;
        flex: 0 0 auto;
        padding: .5rem .9rem;
        border-radius: 999px;
        font-size: .82rem;
        scroll-snap-align: start;
        border-inline-start: none !important;
    }
    .kh-account-main { padding: 1.25rem; }
}

/* ---- Small phones ---- */
@media (max-width: 575.98px) {
    .kh-auth { padding: 1.5rem .75rem; }
    .kh-auth-card { padding: 1.75rem 1.25rem; }

    /* Give each game's score its own full-width line so score↔team stays clear */
    .kh-game-row { align-items: flex-start; }
    .kh-game-main { flex: 1 1 100%; }
    .kh-game-score { flex: 1 1 100%; justify-content: flex-start; }
    .kh-badge { order: 2; }
}

/* ============================================================
   My Games (ألعابي) — filter tabs + per-row progress / actions
   ============================================================ */
.kh-game-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.25rem; }
.kh-game-tab {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .35rem .9rem; border-radius: 999px;
    background: var(--kh-light, #f4f4f8); color: var(--kh-gray);
    font-size: .85rem; font-weight: 700; text-decoration: none;
    border: 1px solid transparent; transition: .15s;
}
.kh-game-tab:hover { background: var(--kh-primary-bg); color: var(--kh-primary); }
.kh-game-tab.active { background: var(--kh-primary); color: #fff; }
.kh-game-tab-count {
    font-size: .72rem; padding: 0 .45rem; border-radius: 999px;
    background: rgba(0, 0, 0, .08); line-height: 1.6;
}
.kh-game-tab.active .kh-game-tab-count { background: rgba(255, 255, 255, .25); }

.kh-game-progress {
    position: relative; flex: 0 0 120px; height: 18px;
    background: var(--border); border-radius: 999px; overflow: hidden;
}
.kh-game-progress-bar { height: 100%; background: var(--kh-primary); border-radius: 999px; }
.kh-game-progress-txt {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: .68rem; font-weight: 700; color: var(--kh-dark);
}

.kh-game-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.kh-game-row-abandoned { opacity: .72; }

@media (max-width: 575.98px) {
    .kh-game-progress { flex: 1 1 100%; }
    .kh-game-actions { flex: 1 1 100%; order: 3; }
}

/* ============================================================
   Dashboard polish — resume banner + clickable game rows
   ============================================================ */
.kh-resume {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    background: linear-gradient(135deg, var(--kh-primary-bg), var(--kh-secondary-bg));
    border: 2px solid var(--kh-secondary); border-radius: var(--kh-radius-xl);
    padding: 1.1rem 1.4rem; margin-bottom: 1.5rem;
    text-decoration: none; color: var(--kh-dark);
    transition: transform .2s, box-shadow .2s;
}
.kh-resume:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(192, 0, 143, .12); color: var(--kh-dark); }
.kh-resume-info { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.kh-resume-icon { font-size: 1.8rem; flex-shrink: 0; }
.kh-resume-title { font-weight: 800; font-size: 1rem; }
.kh-resume-sub { font-size: .82rem; color: var(--kh-gray); overflow-wrap: anywhere; }
.kh-resume-btn { flex-shrink: 0; pointer-events: none; }   /* whole banner is the link */

/* the recent-games rows are now links → give them a hover affordance */
a.kh-game-row { transition: transform .15s ease, box-shadow .15s ease; }
a.kh-game-row:hover { transform: translateY(-1px); box-shadow: var(--kh-shadow-md); }

/* Danger zone — delete account */
.kh-danger-zone { border: 1.5px solid rgba(239, 68, 68, .35); background: rgba(239, 68, 68, .03); }
.kh-danger-zone .form-control:focus { border-color: var(--kh-danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }

/* ---------- Notifications list ---------- */
.notif-list { display: flex; flex-direction: column; gap: 12px; }
.notif-card {
    display: flex; align-items: flex-start; gap: 14px;
    background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--kh-radius-lg);
    padding: 18px 20px; text-decoration: none; color: var(--kh-dark);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.notif-clickable { cursor: pointer; }
.notif-clickable:hover { transform: translateY(-3px); box-shadow: var(--kh-shadow-md); border-color: var(--kh-secondary); color: var(--kh-dark); }
.notif-card.is-new { border-color: var(--kh-primary); background: var(--kh-primary-bg); }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: transparent; }
.notif-card.is-new .notif-dot { background: var(--kh-secondary); }
.notif-body { flex: 1; min-width: 0; }
.notif-card-title { font-weight: 800; font-size: 1rem; color: var(--kh-dark); }
.notif-card-text { margin: 4px 0 6px; color: var(--kh-gray); font-size: .92rem; line-height: 1.7; overflow-wrap: anywhere; }
.notif-time { font-size: .78rem; color: var(--kh-gray-light); font-weight: 600; }
.notif-go { align-self: center; color: var(--kh-primary); flex-shrink: 0; }
.notif-empty { text-align: center; padding: 60px 20px; color: var(--kh-gray); }
.notif-empty-icon { font-size: 3rem; color: var(--kh-gray-light); display: block; margin-bottom: 14px; }

/* ---- بند 10 — very narrow phones (≤360px): keep the account area breathable ---- */
@media (max-width: 360px) {
    .kh-account-main { padding: 1rem .7rem; }
    .kh-dash-head { flex-direction: column; align-items: stretch; gap: .6rem; }
    .kh-dash-head .btn { width: 100%; }
    .kh-mg-actions { flex-wrap: wrap; }
    .kh-mg-name { font-size: 1rem; }
}

/* ---- تاسك 1 — "العب مرة أخرى" setup screen ---- */
.kh-replay-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 22px; }
.kh-replay-cat { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; background: var(--kh-card, #fff); border: 1.5px solid var(--border, #ECECF3); border-radius: 14px; text-align: center; }
.kh-replay-cat img { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; }
.kh-replay-cat-emoji { font-size: 2rem; line-height: 1; }
.kh-replay-cat-name { font-size: .78rem; font-weight: 700; color: var(--kh-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.kh-replay-cat-lock { position: absolute; top: 6px; inset-inline-end: 6px; font-size: .62rem; color: var(--kh-gray-light, #B8B8C8); }
.kh-replay-powers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kh-replay-power { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border: 2px solid var(--border, #ECECF3); border-radius: 12px; cursor: pointer; font-size: .85rem; font-weight: 700; transition: border-color .15s ease, background .15s ease; }
.kh-replay-power .kh-pow-check { accent-color: var(--kh-primary); flex-shrink: 0; }
.kh-replay-power.is-picked { border-color: var(--kh-primary); background: var(--kh-primary-bg, rgba(107, 10, 111, .06)); }
.kh-replay-power img { width: 26px; height: 26px; object-fit: contain; }
.kh-replay-power > i { font-size: 1.1rem; width: 26px; text-align: center; }
