.invoice-wrapper {
    width: 92%;
    max-width: 95%;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: var(--invoice-shadow);
}

.invoice-title {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: 35px;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

.product-input-area {
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px; 
    align-items: flex-end; 
}

.input-group-custom {
    flex: 1; 
    min-width: 150px; 
    display: flex;
    flex-direction: column;
}

.input-group-custom input[type="text"],
.input-group-custom input[type="number"] {
    padding: 12px 15px;
    border: 1px solid var(--input-border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1em;
    font-family:'Peyda';
    color: var(--text-color-dark);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    box-sizing: border-box; 
}

.input-group-custom input[type="text"]:focus,
.input-group-custom input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--input-focus-shadow);
}

.input-group-custom input[readonly] {
    background-color: var(--light-color);
    color: var(--gray-dark);
    cursor: default;
}

.product-input-area .input-group-custom.position-relative {
  position: relative;
}

.add-product-btn {
    background-color: var(--primary);
    color: white;
    padding: 13px 15px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 1em;
    font-family:'Peyda';
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    text-align: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.add-product-btn:hover {
    background-color: var(--primary-hover-color);
    transform: translateY(-1px);
}

.add-product-btn:active {
    transform: translateY(0);
}

.product-suggestions-dropdown {
    position: absolute;
    z-index: 9999;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid var(--invoice-border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--dropdown-shadow);
    max-height: 200px;
    overflow-y: auto;
    width: calc(100% - 2px);
    margin-top: -1px; 
    display: none; 
}

.product-suggestions-dropdown.show{
  display: block;
}

.product-suggestions-dropdown div {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-suggestions-dropdown div:last-child {
    border-bottom: none;
}

.product-suggestions-dropdown div:hover {
    background-color: #e9ecef;
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--gray-light);
    color: var(--gray-dark);
}

.suggestion-item:last-child {
    border-bottom: none;
}
        
.suggestion-item:hover {
    background-color: var(--primary);
    color: var(--primary);
}

.invoice-table {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0 8px; 
    margin-top: 10px;
}

.invoice-table thead th {
    background-color: var(--primary);
    color: white;
    font-weight: 600;
    padding: 15px 10px;
    border: 1px solid var(--invoice-border-color); 
    text-align: center;
    vertical-align: middle;
    position: sticky; 
    top: 0;
    z-index: 500;
}

.invoice-table thead th:first-child,
.invoice-table tbody td:first-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.invoice-table thead th:last-child,
.invoice-table tbody td:last-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.invoice-table tbody td {
    background-color: #fff;
    padding: 10px;
    border: 1px solid var(--invoice-border-color); 
    color: var(--text-color-dark);
    font-size: 0.95em;
    text-align: center;
}
        
.invoice-table tbody tr {
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--invoice-border-color); 
}

.invoice-table tbody tr:hover {
    background-color: var(--table-row-hover-bg);
}

.invoice-table td.product-name-col {
    font-weight: 500;
    text-align: right;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.quantity-controls button {
    background-color: var(--gray-light);
    border: 1px solid var(--medium-color);
    padding: 5px 10px;
    font-size: 1.1em;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    line-height: 1; 
}

.quantity-controls button:hover {
    background-color: var(--gray-medium);
}

.quantity-controls span {
    min-width: 35px;
    display: inline-block;
    text-align: center;
    font-weight: 600;
    color: var(--dark-color);
}

.delete-item-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--danger-color);
    font-size: 1.3em;
    transition: color 0.2s ease, transform 0.2s ease;
}
        
.delete-item-btn:hover {
    color: var(--danger-hover-color);
    transform: scale(1.1);
}

.total-summary-section {
    width: 92%;
    max-width: 95%;
    margin: 20px auto;
    padding: 20px;
    background-color: var(--total-bg);
    border-radius: 8px;
    border: 1px solid var(--invoice-border-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
}

.summary-left, .summary-right {
    display: flex;
    flex-direction: column; 
    text-align: center; 
    justify-content: center;
    flex: 1; 
    min-width: 180px; 
}

.summary-item {
    display: flex;
    align-items: center; 
    justify-content: space-between;
    margin-bottom: 10px;
}

.dividerr {
    width: 1px; 
    background-color: var(--gray-medium); 
    height: 100%;
    margin-left: 20px;
}

.summary-label {
    font-weight: 500;
    color: var(--gray-dark);
    margin-bottom: 5px;
    font-size: 0.9em;
    margin-right: 20px;
}

.summary-value {
    font-weight: 500;
    font-size: 0.9em;
    color: var(--primary);
    margin-left: 20px;
}

.summary-value.total-sum-val {
    color: var(--dark-color);
    font-size: 0.9em;
}

.summary-value.payable-amount-val {
    color: var(--success-color);
    font-size: 0.9em;
    text-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.create-invoice-action {
    margin-top: 20px;
    text-align: center;
    width: 100%;
    margin: 0 auto;
}

.create-invoice-btn {
    width: 95%;
    margin: 0 auto;
    padding: 10px 0;
    font-family: Peyda;
    font-size: 1.0em;
    font-weight: 700;
    border-radius: 8px;
    background-color: var(--success-color);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(40, 167, 69, 0.4);
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    display: inline-flex;                
    align-items: center;          
    justify-content: center;      
    gap: 10px;
    flex-direction: row-reverse;
}
        
.create-invoice-btn:hover {
    background-color: var(--success-hover-color);
    box-shadow: 0 8px 16px rgba(33, 135, 56, 0.4);
    transform: translateY(-2px);
}
        
.create-invoice-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 8px rgba(33, 135, 56, 0.3);
}
   
.create-invoice-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    flex-shrink: 0;
    display: block;
}

.icon-svg {
    display: inline-block;
    vertical-align: middle;
    fill: currentColor; 
}

.modal-overlay{
    position:fixed;
    top:0;
    right:0;
    width:100%;
    height:100%;
    background:rgba(0,0,0,0.6);
    display:none;
    justify-content:center;
    align-items:center;
    z-index:9999;
}

.modal-box{
    width:520px;
    background:#fff;
    border-radius:14px;
    overflow:hidden;
    animation:fadeIn 0.2s ease-in-out;
}

.modal-header{
    background:#1d4ed8;
    color:#fff;
    padding:12px;
    display:flex;
    justify-content:space-between;
    align-items:center;
}

.modal-header h3{
    margin:0;
    font-size:16px;
}

.close-btn{
    cursor:pointer;
    font-size:22px;
}

.modal-body{
    padding:20px;
}

.modal-body input{
    width:95%;
    padding:12px;
    margin-bottom:10px;
    border:1px solid #ddd;
    border-radius:8px;
    font-family: 'Peyda';
}

.modal-footer{
    padding:15px;
    text-align:center;
}

.modal-footer button{
    width:100%;
    padding:12px;
    background:#16a34a;
    color:#fff;
    border:none;
    border-radius:6px;
    cursor:pointer;
    font-family: 'Peyda';
}

@keyframes fadeIn{
    from{transform:scale(0.9);opacity:0;}
    to{transform:scale(1);opacity:1;}
}

#toast{
    position:fixed;
    top:20px;
    left:20px;
    min-width:320px;
    padding:16px 20px;
    border-radius:14px;
    color:#fff;
    font-size:15px;
    backdrop-filter:blur(12px);
    box-shadow:0 10px 30px rgba(0,0,0,.25);
    opacity:0;
    transform:translateY(-30px);
    transition:.35s;
    z-index:999999;
}

#toast.show{
    opacity:1;
    transform:translateY(0);
}

#toast.success{
    background:rgba(22,163,74,.95);
}

#toast.error{
    background:rgba(220,38,38,.95);
}

#toast.warning{
    background:rgba(245,158,11,.95);
}

.qty-box{
    display:flex;
    align-items:center;
    justify-content:center;
    background:#f8f8f8;
    border:1px solid #e6e6e6;
    border-radius:50px;
    padding:4px;
    width:120px;
    margin:auto;
}

.plus-btn,
.minus-btn{
    width:30px;
    height:30px;
    border:none;
    border-radius:50%;
    background:#fff;
    color:#333;
    font-size:20px;
    font-weight:bold;
    cursor:pointer;
    transition:.2s;
    box-shadow:0 2px 8px rgba(0,0,0,.08);
}

.plus-btn:hover{
    transform:scale(1.08);
    background:#1ea362;
    color:#fff;
}

.minus-btn:hover{
    transform:scale(1.08);
    background:#d63031;
    color:#fff;
}

.qty-input{
    width:40px;
    border:none;
    outline:none;
    background:transparent;
    text-align:center;
    font-size:17px;
    font-weight:700;
    color:#222;
    pointer-events:none;
    font-family: 'Peyda';
}

.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button{
    -webkit-appearance:none;
    margin:0;
}

.qty-input{
    -moz-appearance:textfield;
}

.delete-btn{
    cursor: pointer;
}

html,
body{
    overflow-x:hidden;
}

.table-responsive{
    width: 95%;
    margin: 0 auto;
}

/* =======================
   Responsive Mobile
======================= */
@media (max-width:768px){

    .product-input-area {
        flex-direction: column; 
        align-items: stretch;
    }
    .input-group-custom {
        min-width: auto;
        width: 100%;
    }
    .add-product-btn, .create-invoice-btn {
        width: 100%; 
        justify-content: center;
    }
    .total-summary-section > div {
        min-width: auto; 
        width: 100%; 
        margin-bottom: 15px;
    }
    .total-summary-section > div:last-child {
        margin-bottom: 0;
    }

    .invoice-wrapper{
        width:87%;
        padding:15px 10px;
    }

    .invoice-title{
        font-size:18px;
        line-height:30px;
        margin-bottom:20px;
    }

    .product-input-area{
        display:flex;
        flex-direction:column;
        gap:12px;
        padding:0;
    }

    .input-group-custom{
        width:100%;
        min-width:100%;
    }

    .add-product-btn{
        width:100%;
    }


    /* جدول موبایل */

    .invoice-table{
        width:100%;
        border-spacing:0;
    }

    .invoice-table thead{
        display:none;
    }

    .invoice-table,
    .invoice-table tbody,
    .invoice-table tr,
    .invoice-table td{
        display:block;
        width:100%;
        box-sizing:border-box;
    }

    .invoice-table tr{
        background:#fff;
        border:1px solid #e5e5e5;
        border-radius:12px;
        margin-bottom:15px;
        padding:12px;
        box-shadow:0 3px 10px rgba(0,0,0,.08);
    }

    .invoice-table td{
        border:none;
        border-bottom:1px dashed #eee;
        padding:10px 0;
        position:relative;
        padding-right:50px;
        min-height:50px;
        text-align:left;
        display:flex;
        align-items:stretch;
        justify-content:flex-start;
        padding:0;
        margin:0;
        overflow:hidden;
        overflow-wrap:anywhere; 
        word-break:break-word;
    }

    .invoice-table td:last-child{
        border-bottom:none;
    }

    .invoice-table td::before{
        position:absolute;
        top:0;
        right:0;
        bottom:0;
        width:95px;
        background:var(--primary);
        color:#fff;
        display:flex;
        align-items:center;     
        justify-content:center;  
        text-align:center;
        padding:8px;
        font-size:12px;
        font-weight:500;
        line-height:18px;
        white-space:normal;     
        word-break:break-word;
        border-radius:6px 0 0 6px;
    }

    .invoice-table td:not(:has(.qty-box)){
        direction:ltr;
        text-align:left;
        font-weight:500;
    }

    .invoice-table td:nth-child(1)::before{
        content:"ردیف";
    }

    .invoice-table td:nth-child(2)::before{
        content:"نام کالا";
    }

    .invoice-table td:nth-child(3)::before{
        content:"واحد";
    }

    .invoice-table td:nth-child(4)::before{
        content:"تعداد";
    }

    .invoice-table td:nth-child(5)::before{
        content:"قیمت واحد";
    }

    .invoice-table td:nth-child(6)::before{
        content:"ارزش افزوده";
    }

    .invoice-table td:nth-child(7)::before{
        content:"جمع کل";
    }

    .invoice-table td:nth-child(8)::before{
        content:"حذف";
    }

    .invoice-table tbody td {
        padding-right: 100px;
    }

    .qty-box{
        margin:0;
        margin-right:auto;
        margin-left:0;
    }

    .plus-btn,
    .minus-btn{
        width:30px;
        height:30px;
        border:none;
        border-radius:50%;
        background:#fff;
        color:#333;
        font-size:20px;
        font-weight:bold;
        cursor:pointer;
        transition:.2s;
        box-shadow:0 2px 8px rgba(0,0,0,.08);
    }

    .plus-btn:hover{
        transform:scale(1.08);
        background:#1ea362;
        color:#fff;
    }

    .minus-btn:hover{
        transform:scale(1.08);
        background:#d63031;
        color:#fff;
    }

    .qty-input{
        width:40px;
        border:none;
        outline:none;
        background:transparent;
        text-align:center;
        font-size:17px;
        font-weight:700;
        color:#222;
        pointer-events:none;
    }

    .qty-input::-webkit-inner-spin-button,
    .qty-input::-webkit-outer-spin-button{
        -webkit-appearance:none;
        margin:0;
    }

    .qty-input{
        -moz-appearance:textfield;
    }

    /* جمع کل */

    .total-summary-section{
        width:85%;
        display:flex;
        flex-direction:column;
        gap:20px;
        padding:15px;
    }

    .summary-left,
    .summary-right{
        width:100%;
    }

    .summary-item{
        flex-direction:column;
        gap:6px;
        text-align:center;
    }

    .summary-label,
    .summary-value{
        margin:0;
    }

    .dividerr{
        width:100%;
        height:1px;
        margin:0;
    }

    .create-invoice-btn{
        width:100%;
        padding:14px;
    }

    /* مودال */

    .modal-box{
        width:95%;
        margin:15px;
    }

    .modal-body{
        padding:15px;
    }

    .modal-body input{
        width:100%;
        box-sizing:border-box;
    }

    /* Toast */

    #toast{
        left:10px;
        right:10px;
        top:10px;
        min-width:auto;
        width:auto;
    }

}

html,
body{
    -ms-overflow-style: none;
    scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar{
    display: none;
}