/* assets/css/lang.css - Language Switching & RTL Urdu Typography Engine */

@import url('https://fonts.googleapis.com/css2?family=Noto+Nastaliq+Urdu:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap');

/* --- RTL & Urdu Typography Rules --- */
html[dir="rtl"],
body.lang-ur,
.lang-ur {
    font-family: 'Noto Sans Arabic', 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Urdu Typesetting', -apple-system, BlinkMacSystemFont, sans-serif !important;
    letter-spacing: 0 !important;
    text-align: right;
}

/* Headings in Urdu */
.lang-ur h1,
.lang-ur h2,
.lang-ur h3,
.lang-ur h4,
.lang-ur h5,
.lang-ur h6,
.lang-ur .ios-nav-text,
.lang-ur .ios-card-title,
.lang-ur .stat-label,
.lang-ur .page-title {
    font-family: 'Noto Sans Arabic', 'Noto Nastaliq Urdu', sans-serif !important;
    line-height: 1.6 !important;
}

/* Numbers in Urdu Mode remain LTR */
.lang-ur .number-ltr,
.lang-ur .ios-amount,
.lang-ur .stat-value,
.lang-ur .badge-number,
.lang-ur [data-numeric] {
    direction: ltr !important;
    display: inline-block;
}

/* Sidebar & Navigation RTL Adjustments */
html[dir="rtl"] .ios-sidebar,
body.lang-ur .ios-sidebar {
    right: 0 !important;
    left: auto !important;
    border-left: 1px solid var(--ios-separator, rgba(0, 0, 0, 0.08)) !important;
    border-right: none !important;
}

/* Mobile & Tablet (<1024px) */
@media (max-width: 1023px) {
    html[dir="rtl"] .ios-sidebar,
    body.lang-ur .ios-sidebar {
        transform: translateX(100%) !important;
    }

    html[dir="rtl"] .ios-sidebar.active,
    body.lang-ur .ios-sidebar.active {
        transform: translateX(0) !important;
    }

    html[dir="rtl"] .ios-main,
    body.lang-ur .ios-main {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* Desktop & Laptop (>=1024px) */
@media (min-width: 1024px) {
    html[dir="rtl"] .ios-sidebar,
    body.lang-ur .ios-sidebar {
        transform: translateX(0) !important;
    }

    html[dir="rtl"] .ios-sidebar.desktop-visible,
    body.lang-ur .ios-sidebar.desktop-visible {
        transform: translateX(0) !important;
    }

    html[dir="rtl"] .ios-sidebar.desktop-hidden,
    body.lang-ur .ios-sidebar.desktop-hidden {
        transform: translateX(100%) !important;
    }

    html[dir="rtl"] .ios-main.with-sidebar,
    body.lang-ur .ios-main.with-sidebar {
        margin-right: var(--sidebar-width, 280px) !important;
        margin-left: 0 !important;
    }

    html[dir="rtl"] .ios-main.without-sidebar,
    body.lang-ur .ios-main.without-sidebar {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }
}

html[dir="rtl"] .ios-sidebar-close,
body.lang-ur .ios-sidebar-close {
    left: 16px !important;
    right: auto !important;
}

html[dir="rtl"] .ios-nav-link i,
body.lang-ur .ios-nav-link i {
    margin-left: 12px !important;
    margin-right: 0 !important;
}

/* Profile Hero & Avatar Center Alignment */
.ios-profile-hero,
.ios-profile-avatar-section,
.ios-profile-stats,
.ios-profile-avatar-section .ios-profile-avatar {
    text-align: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.ios-profile-hero h3,
.ios-profile-hero p {
    text-align: center !important;
    justify-content: center !important;
}

.ios-profile-stats {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

/* Form Labels in RTL */
html[dir="rtl"] .ios-form-label,
body.lang-ur .ios-form-label,
html[dir="rtl"] .form-label,
body.lang-ur .form-label {
    text-align: right !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    justify-content: flex-start !important;
    flex-direction: row !important;
}

html[dir="rtl"] .ios-form-label i,
body.lang-ur .ios-form-label i {
    margin-left: 6px !important;
    margin-right: 0 !important;
}

/* Form Switcher in RTL */
html[dir="rtl"] .form-switch,
body.lang-ur .form-switch {
    padding-right: 2.5em !important;
    padding-left: 0 !important;
}

html[dir="rtl"] .form-switch .form-check-input,
body.lang-ur .form-switch .form-check-input {
    float: right !important;
    margin-right: -2.5em !important;
    margin-left: 0 !important;
}

/* Form Inputs & Groups RTL */
html[dir="rtl"] .form-control,
html[dir="rtl"] .form-select,
html[dir="rtl"] .ios-form-control,
body.lang-ur .form-control,
body.lang-ur .form-select,
body.lang-ur .ios-form-control {
    text-align: right !important;
    direction: rtl !important;
}

html[dir="rtl"] .input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback),
body.lang-ur .input-group > :not(:first-child):not(.dropdown-menu) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 12px !important;
    border-bottom-left-radius: 12px !important;
}

html[dir="rtl"] .input-group > :not(:last-child):not(.dropdown-toggle):not(.popover-header):not(.popover-body),
body.lang-ur .input-group > :not(:last-child) {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: 12px !important;
    border-bottom-right-radius: 12px !important;
}

/* Margins & Flex Direction Inversions */
html[dir="rtl"] .me-1, body.lang-ur .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
html[dir="rtl"] .me-2, body.lang-ur .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
html[dir="rtl"] .me-3, body.lang-ur .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
html[dir="rtl"] .ms-1, body.lang-ur .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ms-2, body.lang-ur .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
html[dir="rtl"] .ms-3, body.lang-ur .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }

html[dir="rtl"] .text-start, body.lang-ur .text-start { text-align: right !important; }
html[dir="rtl"] .text-end, body.lang-ur .text-end { text-align: left !important; }

/* Table Text Alignments */
html[dir="rtl"] .table th,
html[dir="rtl"] .table td,
body.lang-ur .table th,
body.lang-ur .table td {
    text-align: right !important;
}

/* --- Language Switcher UI Components --- */

/* --- iOS-Style Sidebar Toggle Bar On/Off --- */
.kameti-sidebar-lang-box {
    margin: 10px 14px 14px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.kameti-sidebar-lang-box .kameti-ios-switch-btn {
    width: 100% !important;
    justify-content: space-between !important;
    padding: 7px 16px !important;
    background: #FFFFFF !important;
    border: 1px solid var(--ios-separator, #E5E5EA) !important;
    border-radius: 9999px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
}

.kameti-sidebar-lang-box .kameti-ios-switch-btn:hover {
    border-color: var(--ios-blue, #007AFF) !important;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.12) !important;
}

.kameti-lang-toggle-wrapper {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    flex-shrink: 0;
}

.kameti-ios-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--ios-separator, #E5E5EA);
    border-radius: 9999px;
    padding: 3px 8px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    user-select: none;
}

.kameti-ios-switch-btn:hover {
    background: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
    border-color: var(--ios-blue, #007AFF);
}

.kameti-ios-switch-btn .switch-lang-txt {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--ios-gray, #8E8E93);
    transition: color 0.2s ease, font-weight 0.2s ease;
}

.kameti-ios-switch-btn .switch-lang-txt.active {
    color: var(--ios-blue, #007AFF);
    font-weight: 700;
}

.kameti-ios-switch-btn .switch-track {
    width: 26px;
    height: 15px;
    background: #E5E5EA;
    border-radius: 20px;
    position: relative;
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-block;
}

.kameti-ios-switch-btn .switch-track.on {
    background: #007AFF;
}

.kameti-ios-switch-btn .switch-thumb {
    width: 11px;
    height: 11px;
    background: #FFFFFF;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.kameti-ios-switch-btn .switch-track.on .switch-thumb {
    transform: translateX(11px);
}

/* Mobile Screen Specific Header Tightening (< 768px) */
@media (max-width: 767px) {
    .ios-header {
        padding: 8px 12px !important;
        gap: 6px !important;
    }

    .ios-header-left {
        gap: 6px !important;
        min-width: 0;
        flex-shrink: 1;
    }

    .ios-header-left .ios-page-title {
        font-size: 1.05rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ios-header-right {
        gap: 4px !important;
        flex-shrink: 0;
    }

    .ios-header-right .ios-profile-btn {
        padding: 4px 8px !important;
        font-size: 0.8rem !important;
        max-width: 100px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ios-header-right .ios-profile-btn span {
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
    }

    .kameti-ios-switch-btn {
        padding: 2px 6px !important;
        gap: 4px !important;
    }

    .kameti-ios-switch-btn .switch-lang-txt {
        font-size: 0.65rem !important;
    }

    .kameti-ios-switch-btn .switch-track {
        width: 22px !important;
        height: 13px !important;
    }

    .kameti-ios-switch-btn .switch-thumb {
        width: 9px !important;
        height: 9px !important;
    }

    .kameti-ios-switch-btn .switch-track.on .switch-thumb {
        transform: translateX(9px) !important;
    }
}

/* Hide floating popup */
.kameti-floating-lang-switcher,
#kametiLangSwitcher {
    display: none !important;
}

/* 2. Sidebar Widget Style */
.kameti-sidebar-lang-box {
    margin: 14px 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}

.kameti-sidebar-lang-box .lang-box-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.kameti-sidebar-lang-box .lang-switch-pills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.kameti-sidebar-lang-box .lang-pill {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.kameti-sidebar-lang-box .lang-pill:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #FFFFFF;
}

.kameti-sidebar-lang-box .lang-pill.active {
    background: #007AFF;
    border-color: #007AFF;
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.35);
}

/* 3. Floating Capsule Switcher (Fixed Bottom-Left or Top) */
.kameti-floating-lang-switcher {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99990;
}

html[dir="rtl"] .kameti-floating-lang-switcher,
body.lang-ur .kameti-floating-lang-switcher {
    left: auto !important;
    right: 24px !important;
}

.lang-toggle-capsule {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(20, 20, 25, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 6px 14px;
    border-radius: 9999px;
    color: #FFFFFF;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lang-toggle-capsule:hover {
    transform: scale(1.04);
    border-color: rgba(0, 122, 255, 0.5);
    box-shadow: 0 10px 36px rgba(0, 122, 255, 0.25);
}

.lang-toggle-capsule .globe-anim {
    color: #007AFF;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    animation: globeSpin 20s linear infinite;
}

@keyframes globeSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.lang-toggle-capsule .lang-option-text {
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0.55;
    transition: opacity 0.2s, font-weight 0.2s, color 0.2s;
}

.lang-toggle-capsule .lang-option-text.selected {
    opacity: 1;
    font-weight: 700;
    color: #007AFF;
}

.lang-toggle-capsule .lang-switch-slider {
    width: 24px;
    height: 14px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    position: relative;
    transition: background 0.3s ease;
}

.lang-toggle-capsule .lang-switch-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background: #FFFFFF;
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-toggle-capsule .lang-switch-slider.ur-active {
    background: #007AFF;
}

.lang-toggle-capsule .lang-switch-slider.ur-active::after {
    transform: translateX(10px);
}

/* Toast alert for language change */
.kameti-lang-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-50px);
    background: rgba(24, 24, 30, 0.95);
    border: 1px solid rgba(0, 122, 255, 0.4);
    backdrop-filter: blur(20px);
    color: #FFFFFF;
    padding: 10px 22px;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.kameti-lang-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
