/* ============================================================
   KMA Member Portal — Custom Styles
   Modern, premium design for the member self-service portal.
   ============================================================ */

:root {
    --member-primary: #242b5f;
    --member-primary-light: #0072bb;
    --member-primary-dark: #161c47;
    --member-accent: #0072bb;
    --member-accent-light: #3394db;
    --member-success: #22c55e;
    --member-warning: #f57c00;
    --member-danger: #c62828;
    --member-bg: #f6f7fb;
    --member-card: #ffffff;
    --member-sidebar: #ffffff;
    --member-sidebar-active: #242b5f;
    --member-sidebar-hover: rgba(36, 43, 95, 0.06);
    --member-text: #1f1f2e;
    --member-text-light: #6b7280;
    --member-border: #f0f0f3;
    --member-shadow: 0 10px 28px rgba(36, 43, 95, 0.06);
    --member-radius: 18px;
    --member-radius-sm: 10px;
    --member-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --member-font-arabic: 'Cairo', 'IBM Plex Sans Arabic', sans-serif;
    --member-font-english: 'Inter', 'IBM Plex Sans', sans-serif;
    --member-font: var(--member-font-arabic);
}

html[dir="ltr"] {
    --member-font: var(--member-font-english);
}

/* ── Font Import ── */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.member-portal, .member-sidebar, .member-main, input, select, textarea, button, h1, h2, h3, h4, h5, h6, p, span:not([class*="fa-"]), a:not([class*="fa-"]) {
    font-family: var(--member-font);
    font-weight: 400;
    line-height: 180%;
    letter-spacing: 0%;
}

/* Ensure Font Awesome is never overridden */
i.fa, i.fas, i.far, i.fab, i.fa-solid, i.fa-regular, i.fa-brands, [class^="fa-"], [class*=" fa-"], .menu-icon {
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", "FontAwesome" !important;
    font-weight: 900 !important;
    font-style: normal !important;
    line-height: 1 !important;
    display: inline-block;
}

i.fa-brands, i.fab {
    font-family: "Font Awesome 6 Brands", "Font Awesome 5 Brands" !important;
    font-weight: 400 !important;
}

body.member-portal {
    background: var(--member-bg);
    color: var(--member-text);
    min-height: 100vh;
    overflow-x: hidden;
}

html[dir="rtl"] body.member-portal {
    text-align: right;
}

/* ============ SIDEBAR ============ */
.member-sidebar {
    position: fixed;
    top: 0;
    width: 260px;
    height: 100vh;
    background: #ffffff;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--member-transition);
    border-inline-end: 1px solid #ececec;
    box-shadow: -4px 0 18px rgba(15, 23, 42, 0.04);
}

html[dir="ltr"] .member-sidebar {
    box-shadow: 4px 0 18px rgba(15, 23, 42, 0.04);
}

html[dir="ltr"] .member-sidebar { left: 0; }
html[dir="rtl"] .member-sidebar { right: 0; }

.member-sidebar::-webkit-scrollbar {
    width: 4px;
}
.member-sidebar::-webkit-scrollbar-thumb {
    background: rgba(36, 43, 95, 0.18);
    border-radius: 10px;
}

/* Sidebar Brand */
.member-sidebar .sidebar-brand {
    padding: 18px 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
}

.member-sidebar .sidebar-brand img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: contain;
    padding: 4px;
    background: rgba(36, 43, 95, 0.08);
    box-sizing: content-box;
}

.member-sidebar .sidebar-brand-text {
    color: #242b5f;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.3;
}

.member-sidebar .sidebar-brand-text small {
    display: block;
    color: #6b7280;
    font-weight: 400;
    font-size: 0.72rem;
    margin-top: 2px;
}

/* Sidebar User Card */
.sidebar-user-card {
    padding: 16px;
    margin: 10px 14px 6px;
    border: 1px solid rgba(36, 43, 95, 0.08);
    border-radius: 10px;
    background: rgba(36, 43, 95, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-card .user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(36, 43, 95, 0.12);
    flex-shrink: 0;
}

.sidebar-user-card .user-avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--member-accent), var(--member-primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-user-card .user-info {
    overflow: hidden;
}

.sidebar-user-card .user-name {
    color: #242b5f;
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-card .user-package {
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 500;
    margin-top: 2px;
}

/* Sidebar Menu */
.member-sidebar .sidebar-menu {
    list-style: none;
    padding: 4px 8px;
    margin: 0;
}

.member-sidebar .sidebar-menu .menu-label {
    padding: 12px 18px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #6b7280;
}

.member-sidebar .sidebar-menu .menu-item {
    margin: 3px 0;
}

.member-sidebar .sidebar-menu .menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 14px;
    color: #242b5f;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--member-transition);
    border-radius: 10px;
    position: relative;
    height: 48px;
}

.member-sidebar .sidebar-menu .menu-item a:hover {
    background: var(--member-sidebar-hover);
    color: #242b5f;
}

.member-sidebar .sidebar-menu .menu-item.active a {
    background: #242b5f;
    color: #fff;
    font-weight: 600;
}

html[dir="ltr"] .member-sidebar .sidebar-menu .menu-item.active a::before,
html[dir="rtl"] .member-sidebar .sidebar-menu .menu-item.active a::before {
    display: none;
}

.member-sidebar .sidebar-menu .menu-item a .menu-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.member-sidebar .sidebar-menu .menu-item a .badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

html[dir="ltr"] .member-sidebar .sidebar-menu .menu-item a .badge { margin-left: auto; }
html[dir="rtl"] .member-sidebar .sidebar-menu .menu-item a .badge { margin-right: auto; }

.menu-item.logout-item a {
    color: #c62828 !important;
}
.menu-item.logout-item a:hover {
    color: #c62828 !important;
    background: rgba(198, 40, 40, 0.08) !important;
}

/* ============ MAIN CONTENT ============ */
.member-main {
    min-height: 100vh;
    transition: var(--member-transition);
}

html[dir="ltr"] .member-main { margin-left: 260px; }
html[dir="rtl"] .member-main { margin-right: 260px; }

/* ============ TOP HEADER ============ */
.member-topbar {
    background: #ffffff;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid #ececec;
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-left .page-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1f1f2e;
    margin: 0;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--member-text);
    cursor: pointer;
    padding: 4px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-right .topbar-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    color: #161c47;
    cursor: pointer;
    transition: var(--member-transition);
    text-decoration: none;
    position: relative;
}

.topbar-right .topbar-btn:hover {
    background: rgba(36, 43, 95, 0.06);
    color: #242b5f;
    border-color: transparent;
}

.topbar-right .topbar-btn .notif-dot {
    position: absolute;
    top: 6px;
    width: 8px;
    height: 8px;
    background: var(--member-danger);
    border-radius: 50%;
    border: 2px solid var(--member-card);
}

html[dir="ltr"] .topbar-right .topbar-btn .notif-dot { right: 6px; }
html[dir="rtl"] .topbar-right .topbar-btn .notif-dot { left: 6px; }

.lang-switch {
    font-size: 14px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 10px;
    background: transparent;
    border: 0;
    color: #161c47;
    text-decoration: none;
    transition: var(--member-transition);
}

.lang-switch:hover {
    background: rgba(36, 43, 95, 0.06);
    color: #242b5f;
    border-color: transparent;
}

/* ============ CONTENT AREA ============ */
.member-content {
    padding: 28px;
}

/* ============ CARDS ============ */
.member-card {
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid #f0f0f3;
    box-shadow: 0 10px 28px rgba(36, 43, 95, 0.06);
    transition: var(--member-transition);
    overflow: hidden;
}

.member-card:hover {
    box-shadow: 0 10px 28px rgba(36, 43, 95, 0.08);
}

.member-card .card-header-custom {
    padding: 22px 24px 12px;
    border-bottom: 0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.member-card .card-header-custom h5 {
    font-size: 20px;
    font-weight: 800;
    margin: 0;
    color: #242b5f;
}

.member-card .card-body-custom {
    padding: 12px 24px 20px;
}

/* ============ STAT CARDS ============ */
.stat-card {
    position: relative;
    overflow: hidden;
    min-height: 128px;
    background: linear-gradient(135deg, #0072bb 0%, #242b5f 55%, #161c47 100%);
    border-radius: 16px;
    border: 0;
    padding: 22px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: var(--member-transition);
    box-shadow: 0 10px 24px rgba(36, 43, 95, 0.18);
    color: #ffffff;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.35;
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(36, 43, 95, 0.22);
}

.stat-card .stat-icon {
    position: relative;
    z-index: 1;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
    order: 2;
    margin-inline-start: auto;
}

.stat-card > div:last-child {
    position: relative;
    z-index: 1;
}

.stat-icon.bg-primary,
.stat-icon.bg-accent,
.stat-icon.bg-success,
.stat-icon.bg-warning,
.stat-icon.bg-danger {
    background: rgba(22, 28, 71, 0.45);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    color: #ffffff;
}

.stat-card .stat-label {
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin-top: 4px;
}

/* ============ STATUS BADGES ============ */
.member-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.member-badge.badge-active { background: #22c55e; color: #ffffff; }
.member-badge.badge-pending { background: #fff3e0; color: #e65100; }
.member-badge.badge-expired { background: #e11d48; color: #ffffff; }
.member-badge.badge-info { background: #e0f2f1; color: #00695c; }

/* ============ BUTTONS ============ */
.btn-member {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: var(--member-radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--member-transition);
    text-decoration: none;
}

.btn-member-primary {
    background: #242b5f;
    color: #fff;
}

.btn-member-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(36, 43, 95, 0.28);
    color: #fff;
    background: #161c47;
}

.btn-member-outline {
    background: transparent;
    color: var(--member-primary);
    border: 1.5px solid var(--member-primary);
}

.btn-member-outline:hover {
    background: var(--member-primary);
    color: #fff;
}

.btn-member-danger {
    background: linear-gradient(135deg, #c62828, #e53935);
    color: #fff;
}

.btn-member-sm {
    padding: 6px 14px;
    font-size: 0.78rem;
}

/* ============ TABLES ============ */
.member-table,
.member-card table.table,
.member-content table.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.member-table th,
.member-card table.table thead th,
.member-content table.table thead th {
    background: #ffffff !important;
    padding: 14px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f1f2e !important;
    text-transform: none;
    letter-spacing: 0;
    border: 0;
    border-bottom: 1px solid #eeeeee !important;
    vertical-align: middle;
}

.member-table td,
.member-card table.table td,
.member-content table.table td {
    padding: 16px;
    font-size: 0.875rem;
    color: #6b7280;
    border: 0;
    border-bottom: 1px solid #f0f0f2 !important;
    vertical-align: middle;
    background: #ffffff !important;
}

.member-table tbody tr:hover,
.member-table tbody tr:hover td,
.member-card table.table tbody tr:hover,
.member-card table.table tbody tr:hover td {
    background: #faf8fc !important;
}

/* ============ FORMS ============ */
.member-form-group {
    margin-bottom: 18px;
}

.member-form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--member-text);
    margin-bottom: 6px;
}

.member-form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--member-border);
    border-radius: var(--member-radius-sm);
    font-size: 0.85rem;
    font-family: inherit;
    transition: var(--member-transition);
    background: var(--member-card);
    color: var(--member-text);
}

.member-form-control:focus {
    outline: none;
    border-color: var(--member-primary);
    box-shadow: 0 0 0 3px rgba(14, 74, 134, 0.12);
}

.member-form-control::placeholder {
    color: var(--member-text-light);
}

/* ============ UPLOAD ZONE ============ */
.upload-zone {
    border: 2px dashed var(--member-border);
    border-radius: var(--member-radius);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--member-transition);
    background: rgba(14, 74, 134, 0.02);
}

.upload-zone:hover {
    border-color: var(--member-primary);
    background: rgba(14, 74, 134, 0.05);
}

.upload-zone i {
    font-size: 2rem;
    color: var(--member-primary);
    margin-bottom: 10px;
}

.upload-zone p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--member-text-light);
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--member-border);
    margin-bottom: 14px;
}

.empty-state h5 {
    font-weight: 700;
    color: var(--member-text);
    margin-bottom: 6px;
}

.empty-state p {
    color: var(--member-text-light);
    font-size: 0.88rem;
}

/* ============ AUTH PAGES ============ */
.member-auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b2948 0%, #0e4a86 50%, #00838f 100%);
    padding: 24px;
}

.member-auth-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 24px 64px rgba(11, 41, 72, 0.25);
    width: 100%;
    max-width: 540px;
    padding: 44px 40px;
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.btn-member-lang-pill {
    background: #f1f5f9;
    color: #1e293b;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
}

.btn-member-lang-pill:hover {
    background: #e2e8f0;
    color: var(--member-primary);
}

.member-auth-card .member-form-control {
    border-radius: 12px;
    border: 1.5px solid #e2e8f0;
    padding: 12px 16px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.member-auth-card .member-form-control:focus {
    border-color: var(--member-primary);
    box-shadow: 0 0 0 3px rgba(0, 114, 199, 0.15);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.member-auth-card .auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

.member-auth-card .auth-logo img {
    width: 60px;
    height: 60px;
    border-radius: 14px;
}

.member-auth-card .auth-logo h4 {
    margin-top: 10px;
    font-weight: 800;
    color: var(--member-primary-dark);
    font-size: 1.1rem;
}

.member-auth-card .auth-logo p {
    color: var(--member-text-light);
    font-size: 0.82rem;
    margin-top: 4px;
}

.member-auth-card .auth-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #0b1b3d, #0072bc);
    color: #fff;
    transition: var(--member-transition);
}

.member-auth-card .auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(11, 27, 61, 0.35);
    color: #fff;
}

.member-auth-card .auth-link {
    color: var(--member-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
}

.member-auth-card .auth-link:hover {
    text-decoration: underline;
}

/* ============ PENDING PAGE ============ */
.pending-container {
    text-align: center;
    padding: 20px;
}

.pending-container .pending-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 2rem;
    color: #e65100;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 991px) {
    .member-sidebar {
        transform: translateX(-100%);
    }

    html[dir="rtl"] .member-sidebar {
        transform: translateX(100%);
    }

    .member-sidebar.show {
        transform: translateX(0);
    }

    html[dir="ltr"] .member-main { margin-left: 0; }
    html[dir="rtl"] .member-main { margin-right: 0; }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1045;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* Admin-matching extras: badges, buttons, tables, forms */
.member-content .card {
    background: #ffffff;
    border: 1px solid #f0f0f3;
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(36, 43, 95, 0.06);
}

.member-content .card-header {
    background: #ffffff;
    border-bottom: 0;
    color: #242b5f;
}

.member-card .card-body-custom.p-0 {
    padding: 0 12px 16px !important;
}

.member-content .badge,
.member-content .badge-success,
.member-content .badge-danger,
.member-content .badge-warning,
.member-content .badge-info,
.member-content .badge-primary {
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 600;
    border: 0;
}

.member-content .badge-success,
.member-content .badge.bg-success {
    background: #22c55e !important;
    color: #ffffff !important;
}

.member-content .btn-primary,
.member-content .btn-group .btn-primary {
    background: #242b5f !important;
    border-color: #242b5f !important;
    color: #ffffff !important;
}

.member-content .btn-outline-primary {
    color: #242b5f !important;
    border-color: #e5e7eb !important;
    background: #ffffff !important;
    border-radius: 10px;
    font-weight: 600;
}

.member-content .btn-outline-primary:hover {
    background: #f8fafc !important;
    color: #242b5f !important;
}

.member-content .text-primary {
    color: #242b5f !important;
}

.member-content .pagination .page-link {
    color: #242b5f;
    border-radius: 10px;
    border-color: #e5e7eb;
}

.member-content .pagination .page-item.active .page-link {
    background: #242b5f;
    border-color: #242b5f;
    color: #ffffff;
}

.member-table .btn.btn-sm.border-0,
.member-table .btn-outline-danger {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0 !important;
    border-radius: 50% !important;
    border: 0 !important;
    background: #eef1f8 !important;
    color: #4b5563 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.member-table .btn.btn-sm.border-0:hover,
.member-table .btn-outline-danger:hover {
    background: #e3e9f7 !important;
    color: #242b5f !important;
}

.member-form-control:focus {
    border-color: #242b5f;
    box-shadow: 0 0 0 3px rgba(36, 43, 95, 0.12);
}

.member-content .form-control:focus,
.member-content .form-select:focus {
    border-color: #242b5f;
    box-shadow: 0 0 0 3px rgba(36, 43, 95, 0.12);
}

@media (max-width: 575px) {
    .member-content {
        padding: 16px;
    }

    .member-topbar {
        padding: 0 16px;
    }

    .member-auth-card {
        padding: 28px 20px;
    }

    .stat-card {
        padding: 16px;
    }
}
