/* Profile Page Specific Bundle */

/* Apply background directly to body for 100% coverage and fixed attachment */
body.profile-page,
body.recharge-page {
    background:
        linear-gradient(135deg, rgba(26, 35, 50, 0.92) 0%, rgba(36, 52, 71, 0.95) 100%),
        url('../pics/1.jpg') !important;
    background-size: cover !important;
    background-attachment: fixed !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    min-height: 100vh;
}

/* Adjust Profile Section to be transparent where needed */
.profile-section {
    position: relative;
    background: transparent;
    padding-top: var(--spacing-xl);
}

.profile-sidebar,
.profile-main {
    position: relative;
    z-index: 2;
}

/* Update cards to be semi-transparent/glassmorphic to blend with background */
.profile-sidebar.user-card {
    background: white !important;
    border: 1px solid #e0e6ed;
    padding: var(--spacing-xl) !important;
    border-radius: var(--radius-lg) !important;
    text-align: center !important;
    box-shadow: var(--shadow-lg) !important;
}

/* profile-nav داخل profile-sidebar.user-card يجب أن يكون منفصل */
.profile-sidebar.user-card > .profile-nav {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: var(--spacing-lg);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
}

.user-card,
.profile-nav,
.certificate-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.profile-tab {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: var(--spacing-xl);
    /* Added padding */
    border-radius: 16px;
    /* Added border-radius */
}

/* Active Nav Item */
.profile-nav-item.active {
    background: rgba(74, 144, 226, 0.1);
    color: var(--primary-blue);
    border-right-color: var(--primary-blue);
}

/* WebAuthn - تسجيل الدخول بالبصمة */
.webauthn-section .security-desc {
    color: #2c3e50;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.webauthn-box {
    padding: 1rem 0;
}

.webauthn-box .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-blue, #4a90e2);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.webauthn-box .btn:hover {
    background: #3a7bc8;
}

.webauthn-box .btn-outline-danger {
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.webauthn-box .btn-outline-danger:hover {
    background: rgba(220, 53, 69, 0.1);
}

.webauthn-hint {
    color: #8b95a5;
    font-size: 0.9rem;
    margin-top: 12px;
}

.webauthn-unsupported {
    background: #f5f7fa;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    padding: 16px;
    color: #2c3e50;
}

.webauthn-unsupported p {
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

/* جدول البصمة المسجلة */
.webauthn-table-wrap {
    margin-bottom: 1.25rem;
    max-width: 100%;
    box-sizing: border-box;
}

.webauthn-table-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a2332;
    margin: 0 0 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.webauthn-table-title i {
    color: var(--primary-blue, #4a90e2);
}

.webauthn-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e0e6ed;
    border-radius: 8px;
    background: #fff;
    max-width: 100%;
}

.webauthn-credential-table {
    width: 100%;
    min-width: 320px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.webauthn-credential-table thead {
    background: #f5f7fa;
    color: #2c3e50;
}

.webauthn-credential-table th {
    padding: 10px 12px;
    text-align: right;
    font-weight: 600;
    border-bottom: 1px solid #e0e6ed;
}

.webauthn-credential-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e6ed;
    color: #2c3e50;
}

.webauthn-credential-table tbody tr:last-child td {
    border-bottom: none;
}

.webauthn-credential-table .webauthn-cred-id {
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
}

.webauthn-credential-table .webauthn-empty-cell {
    text-align: center;
    color: #8b95a5;
    font-style: italic;
}

.btn-webauthn-delete-row {
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-webauthn-delete-row:hover {
    background: rgba(220, 53, 69, 0.1);
}

.webauthn-no-credential-msg {
    color: #8b95a5;
    font-size: 0.9rem;
    margin: 0.5rem 0 0 0;
}

/* جدول البصمة - تابلت */
@media (max-width: 768px) {
    .webauthn-table-wrap {
        padding: 0;
        margin-left: 0;
        margin-right: 0;
    }

    .webauthn-table-title {
        font-size: 0.95rem;
    }

    .webauthn-table-responsive {
        border-radius: var(--radius-md);
        margin: 0;
    }

    .webauthn-credential-table {
        font-size: 0.85rem;
        min-width: 280px;
    }

    .webauthn-credential-table th,
    .webauthn-credential-table td {
        padding: 8px 10px;
    }
}

/* جدول البصمة - موبايل: عرض كبطاقات (Card layout) */
@media (max-width: 576px) {
    .webauthn-table-wrap {
        padding: 0;
    }

    .webauthn-table-responsive {
        overflow-x: visible;
        border: none;
        background: transparent;
    }

    .webauthn-credential-table {
        min-width: 0;
        display: block;
    }

    .webauthn-credential-table thead {
        display: none;
    }

    .webauthn-credential-table tbody {
        display: block;
    }

    .webauthn-credential-table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e0e6ed;
        border-radius: var(--radius-md);
        margin-bottom: var(--spacing-sm);
        padding: var(--spacing-md);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    }

    .webauthn-credential-table tbody tr:last-child {
        margin-bottom: 0;
    }

    .webauthn-credential-table td {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.25rem 0.5rem;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f0f2f5;
        text-align: right;
    }

    .webauthn-credential-table tbody tr td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        padding-top: 0.75rem;
    }

    .webauthn-credential-table td::before {
        font-weight: 600;
        color: #2c3e50;
        flex: 0 0 100%;
        font-size: 0.75rem;
        margin-bottom: 2px;
    }

    .webauthn-credential-table td:nth-child(1)::before {
        content: "نوع الجهاز";
    }

    .webauthn-credential-table td:nth-child(2)::before {
        content: "معرف البصمة";
    }

    .webauthn-credential-table td:nth-child(3)::before {
        content: "تاريخ التسجيل";
    }

    .webauthn-credential-table td:nth-child(4)::before {
        content: "إجراء";
    }

    .webauthn-credential-table .webauthn-cred-id {
        font-size: 0.8rem;
        word-break: break-all;
        flex: 1 1 100%;
    }

    .btn-webauthn-delete-row {
        width: 100%;
        padding: 8px 12px;
        margin-top: 4px;
    }

    .webauthn-no-credential-msg {
        font-size: 0.85rem;
    }
}

/* سجل المعاملات + طلبات تعبئة الرصيد - توافق الموبايل (منع الخروج عن الشاشة) */
@media (max-width: 768px) {
    .profile-tab .transactions-section-premium,
    .profile-tab .recharge-requests-section {
        padding: var(--spacing-md);
        max-width: 100%;
        box-sizing: border-box;
        border-radius: var(--radius-md);
        overflow-x: hidden;
    }

    .profile-tab .recharge-requests-section {
        margin-bottom: var(--spacing-md);
    }

    .profile-tab .transactions-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
        margin-bottom: var(--spacing-md);
        padding-bottom: var(--spacing-sm);
    }

    .profile-tab .section-heading-premium {
        font-size: 1.1rem;
        font-weight: 700;
    }

    .profile-tab .section-heading-premium i {
        font-size: 1rem;
    }

    .profile-tab .transactions-filter {
        width: 100%;
    }

    .profile-tab .filter-select {
        width: 100%;
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .profile-tab .transactions-list-premium {
        min-height: 180px;
        gap: var(--spacing-xs);
    }

    .profile-tab .transaction-item-premium {
        padding: 6px 8px;
        gap: 8px;
    }

    .profile-tab .transaction-icon-premium {
        width: 40px;
        height: 40px;
        border-radius: 8px;
        font-size: 0.9rem;
    }

    .profile-tab .transaction-details-premium {
        min-width: 0;
        overflow: hidden;
        flex: 1;
        padding: 2px 0;
    }

    .profile-tab .transaction-title-premium {
        font-size: 0.8rem;
        font-weight: 600;
        margin: 0 0 2px 0;
        line-height: 1.25;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .profile-tab .transaction-date-premium {
        font-size: 0.7rem;
        margin: 0;
        gap: 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .profile-tab .transaction-amount-premium {
        font-size: 0.9rem;
        font-weight: 700;
        flex-shrink: 0;
    }

    .profile-tab .pagination-container {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
        margin-top: var(--spacing-md);
        padding-top: var(--spacing-md);
    }

    .profile-tab .pagination-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .profile-tab .pagination-btn svg {
        width: 18px;
        height: 18px;
    }

    .profile-tab .pagination-number {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    .profile-tab .transactions-empty {
        padding: var(--spacing-lg);
    }

    .profile-tab .transactions-empty h4 {
        font-size: 1rem;
    }

    .profile-tab .transactions-empty p {
        font-size: 0.85rem;
    }
}

@media (max-width: 550px) {
    
    .profile-tab .transaction-item-premium {
        flex-direction: column;
        justify-content: center;
        padding: 5px 6px;
        gap: 6px;
    }

    .profile-tab .transaction-icon-premium{
        display: none;
    }

    .profile-tab .transaction-id-column{
        border-left: none;
    }
    
}

/* أجهزة تسجيل الدخول - موبايل */
@media (max-width: 768px) {
    .device-item {
        flex-direction: column;
        align-items: stretch;
        position: relative;
        padding-top: 2.5rem;
    }

    .device-item .device-icon {
        align-self: center;
    }

    .device-item .current-badge {
        position: absolute;
        top: 0.5rem;
        left: 0.5rem;
        margin: 0;
        margin-right: 0;
    }
    
    .profile-main {
        padding: 0px !important;
    }
 }

@media (max-width: 480px) {
    .profile-tab .transactions-section-premium,
    .profile-tab .recharge-requests-section {
        padding: 0.5rem;
        max-width: 100%;
    }

    .profile-tab .section-heading-premium {
        font-size: 1rem;
    }


    .profile-tab .transaction-icon-premium {
        width: 34px;
        height: 34px;
        border-radius: 6px;
        font-size: 0.8rem;
    }

    .profile-tab .transaction-details-premium {
        padding: 0;
    }

    .profile-tab .transaction-date-premium {
        font-size: 0.65rem;
    }

    .profile-tab .transaction-amount-premium {
        font-size: 0.85rem;
    }

    .profile-tab .pagination-btn span {
        display: none;
    }

    .profile-section .back-button {
        font-size: .5rem;
        padding: 5px 10px;
        margin-bottom: 0 !important;
    }

    .profile-section .profile-sidebar {
        gap: 0px !important;
        padding: 10px !important;
    }

    .profile-section .user-avatar-container {
        margin-bottom: 0px !important;
    }

    .profile-section .user-avatar {
        width: 80px !important;
        height: 80px !important;
    }

    .profile-section .user-avatar i {
        font-size: 80px !important;
    }

    .profile-section .profile-title {
        font-size: 1.3rem;
    }

    .profile-section .profile-tab {
        padding: 10px !important;
    }

    .profile-section .course-codes-intro {
        flex-direction: column !important;
        align-items: center;
        padding: 5px 10px !important
    }
    

    .profile-section .wallet-card-content-digital{
        padding: 20px 5px !important;
    }

    .profile-section .wallet-card-content-digital i{
        font-size: 2rem !important;
    }

    .profile-section .btn-wallet-digital i{
        font-size: 1rem !important;
    }
    

    .profile-section .wallet-card-content-digital .btn-wallet-digital{
        padding: 5px 30px !important;
    }


    .profile-section .wallet-card-content-digital .btn-title-digital{
        font-size: 1rem !important;
    }


    
    .profile-section .security-section .device-item {
        gap: 0px !important;
        padding-top: 0px !important;
    }

    /* نموذج الملف الشخصي (ID، الاسم، الهاتف، البريد، المدينة، الدولة) - مضغوط للموبايل */
    .profile-section .profile-form {
        margin-top: 10px !important;
    }

    .profile-section .profile-form .form-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        margin-bottom: 1rem !important;
    }

    .profile-section .profile-form .form-group {
        margin-bottom: 0;
    }

    .profile-section .profile-form .form-group label {
        font-size: 0.85rem !important;
        margin-bottom: 4px !important;
    }

    .profile-section .profile-form .form-input {
        padding: 8px 10px !important;
        font-size: 0.9rem !important;
    }

    /* قسم تغيير كلمة المرور - مضغوط للموبايل */
    .profile-section .security-section {
        padding: 12px 14px !important;
        margin-bottom: 1rem;
    }

    .profile-section .security-heading {
        font-size: 1rem !important;
        margin-bottom: 10px !important;
        gap: 6px;
    }

    .profile-section .security-heading i {
        font-size: 1.1rem !important;
    }

    .profile-section .security-form {
        max-width: 100%;
    }

    .profile-section .security-form .form-group {
        margin-bottom: 8px !important;
    }

    .profile-section .security-form .form-group label {
        font-size: 0.85rem;
    }

    .profile-section .security-form .form-input {
        padding: 8px 10px !important;
        font-size: 0.9rem !important;
    }

    .profile-section .security-form .btn {
        padding: 8px 16px !important;
        font-size: 0.9rem !important;
        width: 100%;
    }
}