/* =====================================================
   Advanced Members System - Public Stylesheet
   Full RTL/Arabic Professional Support
   ===================================================== */

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

/* ─── CSS Variables ─── */
:root {
    --ams-primary: #2563eb;
    --ams-primary-light: #eff6ff;
    --ams-primary-dark: #1d4ed8;
    --ams-text: #111827;
    --ams-muted: #6b7280;
    --ams-border: #f3f4f6;
    --ams-bg: #ffffff;
    --ams-radius: 1.25rem;
    --ams-radius-sm: 0.75rem;
    --ams-shadow: 0 4px 24px rgba(37, 99, 235, 0.08);
    --ams-shadow-lg: 0 12px 40px rgba(37, 99, 235, 0.15);
    --ams-font-ar: 'IBM Plex Sans Arabic', 'Tahoma', 'Arial', sans-serif;
    --ams-font-en: 'Inter', -apple-system, sans-serif;
}

/* ─── Base: RTL/LTR Font Selection ─── */
.ams-profile-container,
.ams-directory-container {
    font-family: var(--ams-font-en);
    box-sizing: border-box;
}

[dir="rtl"] .ams-profile-container,
[dir="rtl"] .ams-directory-container,
html[lang="ar"] .ams-profile-container,
html[lang="ar"] .ams-directory-container {
    font-family: var(--ams-font-ar);
    direction: rtl;
    text-align: right;
}

/* ─── Badges ─── */
.ams-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    line-height: 1;
    margin-inline-start: 0.375rem; /* works for both LTR and RTL */
}

/* ═══════════════════════════════════════════════
   PROFILE PAGE
   ═══════════════════════════════════════════════ */

.ams-profile-container {
    max-width: 900px;
    margin: 2.5rem auto;
    background: var(--ams-bg);
    border-radius: 2rem;
    box-shadow: 0 8px 48px rgba(0,0,0,0.10);
    overflow: hidden;
}

/* Banner */
.ams-profile-banner {
    height: 200px;
    background: linear-gradient(135deg, #1e40af 0%, #4f46e5 60%, #7c3aed 100%);
    position: relative;
}

/* Avatar wrapper: LTR = left, RTL = right */
.ams-avatar-wrap {
    position: absolute;
    bottom: -4rem;
    inset-inline-start: 2rem; /* replaces left/right — works for both */
}

.ams-avatar-wrap img {
    width: 128px;
    height: 128px;
    border-radius: 1.25rem;
    border: 4px solid #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    object-fit: cover;
    background: #e5e7eb;
    display: block;
}

/* Profile Body */
.ams-profile-body {
    padding: 5rem 2rem 2.5rem;
}

/* Header Row */
.ams-profile-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ams-profile-name {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--ams-text);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0 0 0.25rem;
    line-height: 1.2;
}

.ams-profile-username {
    color: var(--ams-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* Action Buttons */
.ams-action-btns {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.ams-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1.5rem;
    border-radius: var(--ams-radius-sm);
    font-weight: 700;
    font-size: 0.925rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

.ams-btn-primary {
    background: var(--ams-primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}

.ams-btn-primary:hover {
    background: var(--ams-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(37,99,235,0.35);
    color: #fff;
    text-decoration: none;
}

.ams-btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.ams-btn-secondary:hover {
    background: #e5e7eb;
    color: #111827;
    text-decoration: none;
}

/* Stats Bar */
.ams-stats-bar {
    display: flex;
    gap: 0;
    border-top: 1px solid #f3f4f6;
    border-bottom: 1px solid #f3f4f6;
    padding: 1.25rem 0;
    margin: 1.5rem 0;
}

.ams-stat {
    flex: 1;
    text-align: center;
    padding: 0 1rem;
    border-inline-end: 1px solid #f3f4f6;
}

.ams-stat:last-child {
    border-inline-end: none;
}

.ams-stat-num {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ams-text);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.ams-stat-label {
    font-size: 0.75rem;
    color: var(--ams-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Content Grid */
.ams-content-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2.5rem;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .ams-content-grid {
        grid-template-columns: 1fr;
    }
    .ams-profile-body {
        padding: 4.5rem 1.25rem 2rem;
    }
}

/* Sidebar Sections */
.ams-sidebar-section {
    margin-bottom: 1.75rem;
}

.ams-sidebar-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ams-text);
    margin: 0 0 0.875rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.ams-sidebar-section p {
    color: #4b5563;
    line-height: 1.75;
    font-size: 0.95rem;
    margin: 0;
}

/* Badges */
.ams-badges-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ams-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.875rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.ams-badge-pill.blue {
    background: #eff6ff;
    color: #2563eb;
}

.ams-badge-pill.green {
    background: #f0fdf4;
    color: #16a34a;
}

/* Verification Form */
.ams-verify-box {
    background: linear-gradient(135deg, #eff6ff, #e0e7ff);
    border: 1px solid #c7d2fe;
    border-radius: var(--ams-radius);
    padding: 1.25rem;
}

.ams-verify-box h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #1e3a8a;
    margin: 0 0 0.375rem;
    border: none;
    padding: 0;
}

.ams-verify-box p {
    font-size: 0.85rem;
    color: #3730a3;
    margin: 0 0 1rem;
}

.ams-form-field {
    width: 100%;
    background: #fff;
    border: 1.5px solid #c7d2fe;
    border-radius: var(--ams-radius-sm);
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    display: block;
    margin-bottom: 0.75rem;
    box-sizing: border-box;
    color: var(--ams-text);
}

.ams-form-field:focus {
    border-color: var(--ams-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* Posts List */
.ams-posts-section h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--ams-text);
    margin: 0 0 1.25rem;
}

.ams-post-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--ams-radius);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    align-items: flex-start;
}

.ams-post-card:hover {
    background: #f9fafb;
    border-color: #f3f4f6;
}

.ams-post-thumb {
    width: 88px;
    height: 88px;
    border-radius: var(--ams-radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.ams-post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ams-post-info h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ams-text);
    margin: 0 0 0.25rem;
    line-height: 1.4;
}

.ams-post-info h4 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.ams-post-info h4 a:hover {
    color: var(--ams-primary);
}

.ams-post-date {
    font-size: 0.8rem;
    color: var(--ams-muted);
    margin: 0 0 0.375rem;
}

.ams-post-excerpt {
    font-size: 0.875rem;
    color: #4b5563;
    margin: 0;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* RTL: flip post card image order */
[dir="rtl"] .ams-post-card,
html[lang="ar"] .ams-post-card {
    flex-direction: row-reverse;
}

/* ═══════════════════════════════════════════════
   MEMBERS DIRECTORY
   ═══════════════════════════════════════════════ */

.ams-directory-container {
    max-width: 1200px;
    margin: 3rem auto;
    padding: 0 1.25rem;
}

.ams-dir-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.ams-dir-header h2 {
    font-size: 2.25rem;
    font-weight: 900;
    color: var(--ams-text);
    margin: 0 0 0.375rem;
    line-height: 1.15;
}

.ams-dir-header p {
    color: var(--ams-muted);
    font-size: 1.05rem;
    margin: 0;
}

/* Filter Bar */
.ams-filter-bar {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
    align-items: center;
}

.ams-filter-btn {
    padding: 0.5rem 1.125rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    font-family: inherit;
}

.ams-filter-btn:hover,
.ams-filter-btn.active {
    background: var(--ams-primary);
    border-color: var(--ams-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.25);
    text-decoration: none;
}

.ams-search-input {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    font-size: 0.875rem;
    outline: none;
    min-width: 180px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    color: var(--ams-text);
}

.ams-search-input:focus {
    border-color: var(--ams-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* Members Grid */
.ams-members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

/* Member Card */
.ams-member-card {
    background: #fff;
    border-radius: 1.5rem;
    padding: 1.5rem;
    border: 1.5px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.ams-member-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ams-primary), #7c3aed);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.ams-member-card:hover {
    border-color: #dbeafe;
    box-shadow: 0 12px 40px rgba(37,99,235,0.1);
    transform: translateY(-4px);
}

.ams-member-card:hover::before {
    transform: scaleX(1);
}

.ams-member-avatar-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.ams-member-avatar-wrap img {
    width: 88px;
    height: 88px;
    border-radius: 1rem;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    display: block;
}

.ams-member-card:hover .ams-member-avatar-wrap img {
    transform: scale(1.06);
}

/* Badge position: bottom-start in both LTR and RTL */
.ams-member-badge-pos {
    position: absolute;
    bottom: -4px;
    inset-inline-end: -4px;
    background: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    font-size: 0.85rem;
}

.ams-member-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ams-text);
    margin: 0 0 0.25rem;
    line-height: 1.3;
}

.ams-member-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.ams-member-name a:hover {
    color: var(--ams-primary);
}

.ams-member-username {
    font-size: 0.8rem;
    color: var(--ams-muted);
    margin: 0 0 1rem;
    font-weight: 500;
}

.ams-member-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    justify-content: center;
}

.ams-member-stat-num {
    display: block;
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--ams-text);
    line-height: 1.2;
}

.ams-member-stat-label {
    font-size: 0.65rem;
    color: var(--ams-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.ams-view-profile-btn {
    display: block;
    width: 100%;
    padding: 0.7rem;
    border-radius: var(--ams-radius-sm);
    background: #eff6ff;
    color: var(--ams-primary);
    font-weight: 700;
    font-size: 0.875rem;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.ams-view-profile-btn:hover {
    background: var(--ams-primary);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(37,99,235,0.3);
}

/* ─── Animations ─── */
@keyframes ams-fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ams-member-card {
    animation: ams-fadeUp 0.4s ease forwards;
}

/* Stagger delay */
.ams-member-card:nth-child(2)  { animation-delay: 0.05s; }
.ams-member-card:nth-child(3)  { animation-delay: 0.10s; }
.ams-member-card:nth-child(4)  { animation-delay: 0.15s; }
.ams-member-card:nth-child(5)  { animation-delay: 0.20s; }
.ams-member-card:nth-child(6)  { animation-delay: 0.25s; }
.ams-member-card:nth-child(7)  { animation-delay: 0.30s; }
.ams-member-card:nth-child(8)  { animation-delay: 0.35s; }

/* ─── Empty State ─── */
.ams-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--ams-muted);
    font-size: 1rem;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .ams-dir-header {
        flex-direction: column;
        align-items: flex-start;
    }
    [dir="rtl"] .ams-dir-header,
    html[lang="ar"] .ams-dir-header {
        align-items: flex-end;
    }
    .ams-members-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    .ams-profile-body {
        padding: 5rem 1rem 2rem;
    }
    .ams-profile-name {
        font-size: 1.5rem;
    }
}

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