/* Nafaz Invoice Style - Scoped to avoid conflicts */
.nafaz-invoice-container,
.nafaz-preview-wrapper,
.nafaz-invoices-ui-container {
    --nafaz-primary: #004d40;
    --nafaz-text: #0a1931;
    --nafaz-muted: #8898aa;
    direction: rtl;
    font-family: 'Tajawal', 'Cairo', sans-serif;
}

/* Contenteditable Placeholder */
[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: #6a6b6b;
    pointer-events: none;
    display: inline-block;
}

[contenteditable="true"]:focus:before {
    content: "";
}

.nafaz-invoice-container {
    max-width: 600px;
    margin: 40px auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.nafaz-header {
    background: var(--primary-color);
    color: #fff;
    padding: 20px;
    text-align: center;
    position: relative;
}

.nafaz-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.nafaz-header .verified-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    background: #fff;
    color: var(--primary-color);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.invoice-body {
    padding: 30px;
}

.invoice-detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.invoice-detail-row:last-child {
    border-bottom: none;
}

.label {
    color: #777;
    font-weight: 500;
}

.value {
    font-weight: 700;
    color: var(--text-color);
}

.amount-box {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
}

.amount-title {
    font-size: 14px;
    color: #555;
    margin-bottom: 5px;
}

.amount-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary-color);
}

.qr-section {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px dashed #eee;
}

.qr-code img {
    width: 150px;
    height: 150px;
}

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-box {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.btn-nafaz {
    background: #2b846e;
    /* Nafaz primary */
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
    font-family: inherit;
    font-weight: bold;
}

/* Nafaz Virtual Invoice Shortcode Styles */

.nafaz-preview-wrapper {
    display: flex;
    justify-content: center;
    font-family: 'cairo', sans-serif;
    direction: rtl;
    padding: 20px 0;
    /* Optimization: Prevent expensive layout recalculations */
    contain: content;
}

/* Layer promotion for smoother scrolling */
.nafaz-perf-optimized {
    perspective: 1000px;
    backface-visibility: hidden;
}

.nafaz-preview-card {
    background: #fff;
    width: 100%;
    max-width: 865px;
    border-radius: 20px;
    /* Simplified Shadow: Much lighter on the browser's painting engine */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    padding: 40px;
    box-sizing: border-box;
    position: relative;
    color: #0a1931;
    /* GPU Acceleration: Force layer promotion for smooth scrolling */
    transform: translate3d(0, 0, 0);
    will-change: transform;
    border: 1px solid #f0f0f0;
    transition: box-shadow 0.3s ease;
}

[contenteditable="true"] {
    outline: none;
    padding: 2px 5px;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: text;
}

[contenteditable="true"]:hover {
    background: rgba(69, 167, 135, 0.05);
}

[contenteditable="true"]:focus {
    background: rgba(69, 167, 135, 0.1);
    box-shadow: 0 0 0 1px #45a787;
}

.editable-number::after {
    content: ' ✎';
    font-size: 10px;
    opacity: 0.3;
}


/* Header */
.nafaz-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Center vertically for cleaner look */
    margin-bottom: 40px;
    padding: 0;
}

.nafaz-top-qr-box {
    background: #fff;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #f0f0f0;
    overflow: hidden;
}

.nafaz-top-qr-box img {
    max-width: 100%;
    max-height: 100%;
}

.nafaz-brand-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.nafaz-brand-logo .logo-icon {
    font-size: 28px;
    margin-bottom: 5px;
    color: #45a787;
    /* Greenish */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.icon-b {
    font-weight: 800;
    font-family: serif;
    border: 2px solid #45a787;
    padding: 0 5px;
    border-radius: 4px;
    font-size: 18px;
}

.brand-name {
    color: #45a787;
    font-weight: 700;
    font-family: sans-serif;
    letter-spacing: 0.5px;
    font-size: 14px;
}

.nafaz-invoice-title-box {
    text-align: right;
}

.nafaz-invoice-title-box h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: #0c1c36;
    /* Dark navy */
}

.invoice-number-row {
    margin-top: 5px;
    color: #8898aa;
    font-size: 15px;
    font-weight: 600;
}

.invoice-number-row .num-label {
    margin-left: 5px;
}

/* Company Info - Left Side */
.nafaz-company-info {

    margin-bottom: 20px;
    margin-left: 0;
    margin-right: auto;
    width: fit-content;

}

.nafaz-company-info h3 {
    margin: 0;
    font-size: 18px;
    color: #0a1931;
    text-align: right;
    /* Ensure text aligns left */
}

.nafaz-company-info .tax-number {
    margin: 5px 0 0;
    color: #8898aa;
    font-size: 14px;
    text-align: left;
}

/* Meta & Client Row - 3 Columns */
.nafaz-meta-client-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    border-top: 1px solid #f5f5f5;
    padding-top: 30px;
    gap: 20px;
}

.nafaz-meta-col {
    flex: 1;
    text-align: right;
}

.nafaz-meta-col h5 {
    color: #8898aa;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 15px 0;
}

.meta-field {
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.6;
}

.field-label {
    color: #8898aa;
    /* Lighter gray for label */
    font-weight: 500;
}

.field-value {
    color: #0a1931;
    /* Darker for value */
    font-weight: 700;
}

/* Date column specific alignment */
.nafaz-meta-date {
    text-align: left;
    /* Date is on the far left of the card in RTL layout usually, but image shows it on the left */
}

.nafaz-meta-date .meta-label {
    text-align: left;
}

.nafaz-meta-date .meta-value {
    text-align: left;
    display: block;
}

/* Items Grid (Flexbox replacement for high-performance scrolling) */
.nafaz-items-grid {
    margin-bottom: 30px;
}

.nafaz-grid-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
    color: var(--nafaz-muted);
    font-weight: 600;
    font-size: 14px;
}

.nafaz-grid-row {
    display: flex;
    justify-content: space-between;
    padding: 20px 0;
    border-bottom: 1px solid #f0f0f0;
    color: var(--nafaz-text);
    font-weight: 600;
}

.nafaz-items-grid .col-item {
    flex: 2 !important;
    /* Significantly reduced to give room */
    min-width: 0;
    text-align: right;
}

.nafaz-items-grid .col-price {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.nafaz-items-grid .col-qty {
    flex: 1 !important;
    /* Large space for number + unit select */
    min-width: 0;
    text-align: center;
}

.qty-flex {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 6px;
    padding: 2px 5px;
}

.qty-flex .editable-qty {
    min-width: 30px;
    text-align: center;
}

/* Custom Unit Dropdown - Premium Style (Prefixing to avoid conflicts) */
.nafaz-unit-dropdown {
    position: relative !important;
    display: inline-block !important;
    user-select: none !important;
    direction: rtl !important;
}

.nafaz-unit-toggle {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 6px 12px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #45a787 !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    min-width: 90px !important;
    justify-content: space-between !important;
}

.nafaz-unit-toggle:hover {
    background: #f0fdf9 !important;
    border-color: #45a787 !important;
    box-shadow: 0 4px 12px rgba(69, 167, 135, 0.1) !important;
}

.nafaz-unit-toggle i {
    font-size: 14px !important;
    color: #45a787 !important;
}

.nafaz-unit-toggle .chevron {
    font-size: 10px !important;
    transition: transform 0.3s ease !important;
    opacity: 0.5 !important;
}

.nafaz-unit-dropdown.active .nafaz-unit-toggle .chevron {
    transform: rotate(180deg) !important;
}

.nafaz-unit-menu {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    right: 0 !important;
    z-index: 1000 !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
    width: 160px !important;
    padding: 6px !important;
    display: none !important;
    /* Hidden by default */
    opacity: 0 !important;
    transform: translateY(-10px) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow-y: auto !important;
    max-height: 250px !important;
}

/* Custom Scrollbar for Dropdown */
.nafaz-unit-menu::-webkit-scrollbar {
    width: 5px;
}

.nafaz-unit-menu::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.nafaz-unit-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.nafaz-unit-menu::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.nafaz-unit-dropdown.active .nafaz-unit-menu {
    display: block !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.nafaz-unit-option {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #475569 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-align: right !important;
}

.nafaz-unit-option:hover {
    background: #f0fdf9 !important;
    color: #45a787 !important;
}

.nafaz-unit-option i {
    width: 20px !important;
    text-align: center !important;
    font-size: 15px !important;
    color: #94a3b8 !important;
    transition: color 0.2s ease !important;
}

.nafaz-unit-option:hover i {
    color: #45a787 !important;
}

.nafaz-unit-option.selected {
    background: #f0fdf9 !important;
    color: #45a787 !important;
}

.nafaz-unit-option.selected i {
    color: #45a787 !important;
}

/* Hide original select but keep it for form submission/sync if needed */
.item-unit-hidden {
    display: none !important;
}

.nafaz-items-grid .col-total {
    flex: 1.2;
    min-width: 0;
    text-align: left;
}

/* Prevent editable text from expanding the column */
.nafaz-grid-row {
    position: relative;
    transition: background 0.2s;
}

.nafaz-grid-row:hover {
    background: #fafafa;
}

.btn-remove-row {
    position: absolute;
    right: -35px;
    top: 50%;
    transform: translateY(-50%);
    background: #fee2e2;
    color: #ef4444;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.nafaz-grid-row:hover .btn-remove-row {
    opacity: 1;
    right: -30px;
}

.btn-remove-row:hover {
    background: #ef4444;
    color: #fff;
}

@media (max-width: 991px) {
    .btn-remove-row {
        position: relative;
        right: 0 !important;
        opacity: 1;
        margin-right: 10px;
        order: -1;
    }

    .nafaz-grid-row {
        align-items: center;
    }
}

.nafaz-grid-row [contenteditable="true"] {
    display: block;
    width: 100%;
    white-space: nowrap;
}

.nafaz-add-row-wrapper {
    margin-top: 15px;
    text-align: center;
}

.btn-add-item {
    background: transparent;
    border: 2px dashed #e2e8f0;
    color: #94a3b8;
    padding: 10px 25px;
    border-radius: 12px;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-add-item:hover {
    background: #f0fdf9;
    border-color: #45a787;
    color: #45a787;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(69, 167, 135, 0.1);
}

.btn-add-item:active {
    transform: translateY(0);
    background: #f0fdf9;
    border-color: #45a787;
    color: #45a787;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(69, 167, 135, 0.1);
}

.btn-add-item:disabled {
    background: #f8fafc;
    border-color: #f1f5f9;
    color: #cbd5e1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (max-width: 767px) {
    .nafaz-preview-card {
        padding: 25px 15px;
        border-radius: 12px;
    }

    .nafaz-preview-header {
        gap: 20px;
        margin-bottom: 30px;
    }

    .nafaz-invoice-title-box h2 {
        font-size: 22px;
    }

    .nafaz-meta-client-row {
        flex-direction: column;
        gap: 25px;
        padding-top: 20px;
    }

    .nafaz-meta-col {
        width: 100%;
        text-align: right !important;
    }

    .nafaz-meta-date {
        text-align: right;
    }

    .nafaz-meta-date .meta-value,
    .nafaz-meta-date .meta-label {
        text-align: right;
    }

    .nafaz-grid-header {
        font-size: 11px;
    }

    .nafaz-grid-row {
        font-size: 12px;
        padding: 15px 0;
    }

    .nafaz-preview-footer {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .nafaz-pay-action {
        text-align: center;
        width: 100%;
    }

    .btn-pay {
        width: 100%;
        padding: 12px 20px;
    }

    .nafaz-grand-total {
        font-size: 16px;
    }

    .nafaz-items-grid {
        overflow-x: auto;
        margin-left: -15px;
        margin-right: -15px;
        padding: 0 15px;
        -webkit-overflow-scrolling: touch;
    }

    .nafaz-grid-header,
    .nafaz-grid-row {
        min-width: 450px;
        /* Ensure content doesn't squash too much */
    }
}

/* Totals Section */
.nafaz-totals-section {
    width: 100%;
    max-width: 280px;
}

.nafaz-totals-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 14px;
    color: #525f7f;
    font-weight: 600;
}

.nafaz-grand-total {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    /* No border top in image for total? Or subtle? Let's keep it clean */
    font-weight: 800;
    font-size: 18px;
    color: #0a1931;
}

/* Footer Section */
.nafaz-preview-footer {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    margin-top: 38px;
    flex-direction: row-reverse;
}

.nafaz-qr-box {
    background: #e9ecef;
    width: 90px;
    height: 90px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 12px;
}

.nafaz-pay-action {
    text-align: right;
}

.btn-pay {
    background-color: #45a787;
    /* Green */
    color: #fff;
    border: none;
    padding: 12px 35px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(69, 167, 135, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: 'Tajawal', sans-serif;
}

.btn-pay:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(69, 167, 135, 0.3);
}

.btn-pay:disabled {
    background-color: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.thank-you-msg {
    color: #8898aa;
    font-size: 12px;
    margin-top: 12px;
    font-weight: 500;
    text-align: center;
}

/* --- Nafaz User Invoices List UI --- */

.nafaz-invoices-ui-container {
    max-width: 1200px;
    margin: 40px auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: none !important;
    border: none !important;
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
}

/* Header & Filters */
.nafaz-ui-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    /* Responsive */
    gap: 20px;
    padding: 27px 30px 4px 27px;
    height: 89px;
    /* User Request */
}

/* Tabs: All / Paid / Unpaid */
.nafaz-ui-tabs {
    display: flex;
    background: #f8fafc;
    /* Very light grey */
    padding: 5px;
    border-radius: 12px;
    border: none;
}

.nafaz-tab-link {
    padding: 10px 20px;
    border-radius: 8px;
    color: #64748b;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.nafaz-tab-link:hover {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.5);
}

.nafaz-tab-link.active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Search Bar */
.nafaz-ui-search-form {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.nafaz-ui-search-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 1px solid #E2E8F0;
    border-radius: 17px;
    background: #f8fafc;
    font-family: 'Cairo';
    outline: none;
    transition: all 0.2s;
    height: 46px;
}

.nafaz-ui-search-input:focus {
    background: #fff;
    border-color: #cbd5e1;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.1);
}

.nafaz-search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

/* Table Wrapper */
.nafaz-ui-table-responsive {
    overflow-x: auto;
}

.nafaz-ui-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    /* Force scroll on small screens */
}

/* Table Head */
.nafaz-ui-table thead {
    background: #F8FAFC80;
    /* User Request */
}

.nafaz-ui-table thead th {
    text-align: right;
    color: #64748B;
    font-weight: 700;
    font-size: 16px;
    padding: 15px 20px;
    border-bottom: 1px solid #F8FAFC80;
    border-top: 1px solid #F8FAFC80;
    height: 57px;
}

/* Table Body */
.nafaz-ui-table tbody tr {
    transition: background 0.2s;
    border-bottom: 1px solid #f8fafc;
}

.nafaz-ui-table tbody tr:last-child {
    border-bottom: none !important;
}

.nafaz-ui-table tbody tr:hover {
    background: #f8fafc;
}

.nafaz-ui-table td {
    padding: 20px;
    vertical-align: middle;
    color: #0f172a;
    font-size: 14px;
    font-weight: 600;
}

/* Columns Specifics */
.col-invoice-id {
    font-weight: 700;
    color: #0f172a;
}

.col-date {
    color: #64748b;
    font-weight: 500;
}

.col-customer {
    display: flex;
    align-items: center;
    gap: 10px;
}

.customer-avatar {
    width: 32px;
    height: 32px;
    background: #e0f2f1;
    /* Light green background */
    color: #00695c;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
}

.customer-avatar.blue {
    background: #e0f7fa;
    color: #006064;
}

.customer-avatar.purple {
    background: #f3e5f5;
    color: #7b1fa2;
}


/* Status Badges */
.nafaz-status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.status-paid {
    background: #dcfce7;
    /* Light Green */
    color: #166534;
    /* Dark Green */
}

.status-pending {
    background: #fef9c3;
    /* Light Yellow */
    color: #854d0e;
    /* Dark Yellow/Brown */
}

.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

/* Actions */
.nafaz-ui-actions {
    display: flex;
    gap: 10px;
}

.nafaz-action-btn {
    color: #64748b;
    font-size: 18px;
    text-decoration: none;
    padding: 5px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.nafaz-action-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.nafaz-action-btn img,
.nafaz-action-btn .dashicons {
    pointer-events: none;
    /* Ensure click hits the <a> tag */
}

/* Pagination */
.nafaz-ui-pagination {
    display: flex;
    border-top: none;
    flex-direction: row;
    flex-wrap: nowrap;
    padding: 13px;
    justify-content: space-between;
    align-items: center;
    height: 89px;
}

.pagination-info {
    color: #94a3b8;
    font-size: 13px;
}

.pagination-links {
    display: flex;
    gap: 5px;
}

.pagination-links .page-numbers {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    /* Slightly rounded square */
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.pagination-links .page-numbers.current,
.pagination-links .page-numbers:hover {
    background: #50bda1;
    /* Nafaz Green */
    color: #fff;
    border-color: #50bda1;
}

.pagination-links .next,
.pagination-links .prev {
    padding: 0 10px;
    width: auto;
}

/* --- Nafaz My Account Page --- */

.nafaz-account-container {
    max-width: 800px;
    margin: 40px auto;
    background: #fff;
    border-radius: 20px;
    padding: 60px;
    /* Large padding as per design */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
    position: relative;
    box-sizing: border-box;
}

.nafaz-message {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: 600;
}

.nafaz-message.success {
    background: #dcfce7;
    color: #166534;
}

.nafaz-message.error {
    background: #fee2e2;
    color: #991b1b;
}

.nafaz-acc-section {
    margin-bottom: 40px;
}

.nafaz-acc-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-direction: row;
    justify-content: flex-start;
}

.nafaz-acc-header h3 {
    margin: 0;
    font-size: 18px;
    color: #0f172a;
    font-weight: 700;
}

.acc-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #e0f2f1;
    border-radius: 8px;
    color: #45A787;
}

/* Form Grid */
.nafaz-form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.nafaz-form-group {
    flex: 1 1 45%;
    /* 2 cols */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nafaz-form-group.full-width {
    flex: 1 1 100%;
}

.nafaz-form-group label {
    font-size: 14px;
    color: #64748b;
    font-weight: 600;
}

.nafaz-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #f1f5f9;
    background: #f8fafc;
    border-radius: 12px;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    color: #0f172a;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    font-weight: 600;
}

.nafaz-input:focus {
    border-color: #45A787;
    background: #fff;
}

.input-with-action {
    position: relative;
}

.action-link {
    position: absolute;
    left: 15px;
    /* RTL Left */
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #45A787;
    cursor: pointer;
    font-weight: 700;
}

/* Package Card */
.nafaz-package-card {
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.pkg-icon-box {
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f59e0b;
    /* Star color */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.pkg-details {
    flex-grow: 1;
}

.pkg-details h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #0f172a;
}

.pkg-details p {
    margin: 0;
    font-size: 12px;
    color: #94a3b8;
}

.pkg-status.active {
    background: #dcfce7;
    color: #166534;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

/* Actions Footer */
.nafaz-acc-actions {
    margin-top: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.nafaz-logout-link {
    color: #ef4444;
    /* Red */
    text-decoration: none;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    /* Align right in RTL */
    font-size: 16px;
}

.nafaz-btn-save {
    background: #45A787;
    color: #fff;
    border: none;
    padding: 15px 50px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(69, 167, 135, 0.2);
    transition: transform 0.2s;
    font-family: inherit;
}

.nafaz-btn-save:hover {
    transform: translateY(-2px);
    background: #368f72;
}

.nafaz-secure-badge {
    color: #94a3b8;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .nafaz-account-container {
        padding: 30px 20px;
        margin: 20px auto;
    }

    .nafaz-form-group {
        flex: 1 1 100%;
    }

    .nafaz-acc-actions {
        margin-top: 30px;
    }

    .nafaz-btn-save {
        width: 100%;
        padding: 15px;
    }

    .nafaz-package-card {
        padding: 15px;
        text-align: center;
    }

    .pkg-icon-box {
        margin: 0 auto;
    }

    .pkg-status.active {
        width: fit-content;
        margin: 10px auto 0;
    }
}

/* --- Interactive Invoice Elements --- */

.nafaz-items-grid .col-qty {
    flex: 0.5;
    text-align: center;
}

.nafaz-add-row-wrapper {
    margin-top: 25px;
    text-align: end;
    padding-top: 10px;
}

.btn-add-item {
    background: #fff;
    border: 1px solid #45a787;
    color: #45a787;
    padding: 12px 30px;
    border-radius: 12px;
    /* Pill shape */
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0px 8px 10px -6px #4CAF934D, 0px 20px 25px -5px #4CAF934D;
    outline: none;
    min-width: 200px;
}

.btn-add-item:hover {
    background: #f0fdf9;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(69, 167, 135, 0.15);
}

.btn-add-item:active {
    transform: translateY(0);
}

.btn-add-item:disabled {
    border-color: #e2e8f0;
    color: #94a3b8;
    background: #f8fafc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Notes Section */
.nafaz-invoice-notes-section {
    margin-top: 30px;
    text-align: right;
}

.notes-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #6B7280;
    margin-bottom: 10px;
}

.nafaz-invoice-notes {
    width: 100%;
    min-height: 96px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    color: #0c1c36;
    outline: none;
    resize: vertical;
    transition: all 0.2s;
    background: transparent;
    box-sizing: border-box;
}

.nafaz-invoice-notes:focus {
    border-color: #4CAF93;
    box-shadow: 0 0 0 3px rgba(76, 175, 147, 0.1);
}

.nafaz-invoice-notes::placeholder {
    color: #cbd5e1;
    text-align: right;
}

/* --- Pricing Packages --- */
.nafaz-pricing-container {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
    padding: 40px 10px;
    flex-wrap: wrap;
    font-family: 'Tajawal', sans-serif;
    direction: rtl;
    max-width: 1200px;
    margin: 0 auto;
}

.nafaz-pricing-card {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 30px;
    padding: 25px;
    text-align: center;
    flex: 1;
    min-width: 280px;
    max-width: 360px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.nafaz-pricing-card.featured {
    background: #fff;
    border: 2px solid #50bda1;
    z-index: 2;
}

.nafaz-featured-badge {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: #50bda1;
    color: #fff;
    padding: 4px 20px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.nafaz-plan-title {
    font-size: 19px;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 15px;
}

.nafaz-plan-price {
    display: flex;
    margin-bottom: 20px;
    flex-direction: row-reverse;
    gap: 6px;
    color: #0F172A;
    font-family: 'Cairo', sans-serif;
    align-content: center;
}

.nafaz-plan-price .amount {
    font-size: 36px;
    font-weight: 800;
}

.nafaz-plan-price .currency {
    font-size: 14px;
    color: #475569;
}

.nafaz-plan-features {
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
    text-align: right;
}

.nafaz-plan-features ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nafaz-plan-features li {
    margin-bottom: 8px;
    position: relative;
    padding-right: 18px;
}

.nafaz-plan-features li::before {
    content: '';
    position: absolute;
    right: 0;
    top: 8px;
    width: 5px;
    height: 5px;
    background-color: #50bda1;
    border-radius: 50%;
}

.nafaz-plan-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 54px;
    width: 100%;
    border-radius: 14px;
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
    transition: all 0.2s;
}

.nafaz-plan-btn.primary {
    background: #50bda1;
    color: #fff;
    border: none;
}

.nafaz-plan-btn.outline {
    background: #FFFFFF;
    color: #0F172A;
    border: 1px solid #E2E8F0;
}

@media (max-width: 1024px) {
    .nafaz-pricing-container {
        flex-direction: column;
        align-items: center;
        gap: 30px;
        display: flex !important;
    }

    .nafaz-pricing-card {
        width: 100%;
    }

    /* Strictly enforce the visual order: Featured card should be 2nd */
    .nafaz-pricing-card:nth-child(1) {
        order: 1 !important;
    }

    .nafaz-pricing-card.featured {
        order: 2 !important;
    }

    .nafaz-pricing-card:nth-child(3) {
        order: 3 !important;
    }
}

@media(max-width:600px) {
    .add-unit-box {
        flex-direction: column
    }
}

.nafaz-units-manager {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    margin-top: 15px
}

.nafaz-units-manager .desc {
    color: #64748b;
    margin-bottom: 20px;
    font-size: 14px
}

#custom-units-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 30px
}

.unit-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s
}

.unit-item-row:hover {
    border-color: #45A787;
    background: #f0fdf4
}

.unit-info {
    display: flex;
    align-items: center;
    gap: 10px
}

.unit-info i {
    color: #45A787;
    font-size: 18px;
    width: 24px;
    text-align: center
}

.btn-remove-unit {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px
}

.add-unit-box {
    display: flex;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid #f1f5f9
}

.add-unit-box input,
.add-unit-box select {
    flex: 1
}

/* WhatsApp Diagnostic Modal */
.nafaz-wa-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 25, 49, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    direction: rtl;
    padding: 20px;
}

.nafaz-wa-modal {
    background: #fff;
    width: 100%;
    max-width: 550px;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: nafazFadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes nafazFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.nafaz-wa-modal h3 {
    text-align: center;
    margin: 0 0 25px 0;
    color: #1a202c;
    font-size: 22px;
}

.wa-status-box {
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
}

.wa-status-box.wa-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.wa-status-box.wa-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.wa-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    font-size: 16px;
}

.wa-header i {
    font-size: 24px;
    color: #25D366;
}

.wa-status-box.wa-error .wa-header i {
    color: #ef4444;
}

.wa-body p {
    margin: 0 0 15px 0;
    color: #4a5568;
    line-height: 1.6;
}

.wa-debug-info, .wa-message-preview {
    margin-top: 15px;
    background: rgba(0,0,0,0.03);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.05);
}

.wa-debug-info label, .wa-message-preview label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: #718096;
    margin-bottom: 5px;
    font-weight: bold;
}

.wa-debug-info code {
    display: block;
    word-break: break-all;
    font-family: monospace;
    font-size: 12px;
    color: #2c5282;
    background: none;
    padding: 0;
}

.wa-message-preview blockquote {
    margin: 0;
    font-style: italic;
    font-size: 14px;
    color: #4a5568;
    border-right: 3px solid #cbd5e0;
    padding-right: 12px;
}

.wa-footer {
    text-align: center;
}

.btn-done {
    display: inline-block;
    background: #2d3748;
    color: #fff;
    padding: 12px 30px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: bold;
    transition: background 0.2s;
}

.btn-done:hover {
    background: #1a202c;
    color: #fff;
}