/* Global Dashboard Styles */
#ks-dashboard-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 99999;
    display: flex; justify-content: center; align-items: center;
    backdrop-filter: blur(5px);
}

.ks-dashboard-container {
    background: #f8f9fa;
    width: 95%;
    max-width: 900px;
    height: 85vh;
    border-radius: 15px;
    display: flex; flex-direction: column;
    overflow: hidden;
    direction: rtl;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.ks-dashboard-header {
    background: #fff;
    padding: 85px 20px 20px 20px; /* Even more top padding to bring it lower */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.ks-dashboard-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    text-align: center;
    flex-grow: 1;
}

#ks-close-dashboard {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f8f9fa;
    color: #555;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

#ks-close-dashboard:hover {
    background: #ff4d4d;
    color: #fff;
    border-color: #ff4d4d;
    transform: rotate(90deg);
}

#ks-close-dashboard svg {
    width: 20px;
    height: 20px;
}

/* Tabs */
.ks-tabs-nav {
    display: flex; background: #eee;
    padding: 10px 10px 0 10px; /* Add padding to container */
    gap: 5px; /* Add gap between tabs */
    border-radius: 15px 15px 0 0; /* Round the container top */
}

.ks-tab-btn {
    flex: 1; border: none; padding: 15px; cursor: pointer;
    font-weight: bold; font-size: 16px; transition: 0.3s;
    background: #e0e0e0; /* Slightly darker than container for inactive tabs */
    border-bottom: none; /* Remove bottom border style */
    border-radius: 12px 12px 0 0; /* Rounded top corners */
    color: #666;
}

.ks-tab-btn:hover {
    background: #d4d4d4;
}

.ks-tab-btn.active {
    background: #dc3545; color: #fff; 
    box-shadow: 0 -2px 10px rgba(220, 53, 69, 0.2); /* Add subtle shadow */
}

.ks-tabs-content { flex: 1; overflow: hidden; padding: 0; background: #fff; display: flex; flex-direction: column; }
.ks-tab-panel { display: none; height: 100%; flex-direction: column; padding: 20px; box-sizing: border-box; overflow: hidden; }
.ks-tab-panel.active { display: flex; }

/* Actions */
.ks-add-btn {
    width: 100%; padding: 12px; background: #28a745; color: #fff;
    border: none; border-radius: 8px; cursor: pointer; font-weight: bold;
    margin-bottom: 20px; font-size: 16px; transition: 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.ks-add-btn:hover { background: #218838; }
.ks-add-btn.ks-danger { background: #dc3545; }
.ks-add-btn.ks-danger:hover { background: #c82333; }

/* Items List */
.ks-items-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex-grow: 1; padding-bottom: 20px; }

.ks-item {
    background: #fdfdfd; border: 1px solid #eee; padding: 12px 15px;
    border-radius: 10px; display: flex; justify-content: space-between; align-items: center;
    transition: 0.2s;
}

.ks-item:hover { background: #f1f1f1; }
.ks-item-hidden { opacity: 0.5; filter: grayscale(1); }

.ks-item-details { display: flex; flex-direction: column; }
.ks-item-name { font-weight: bold; color: #333; font-size: 18px; margin-bottom: 5px; }
.ks-item-meta { 
    font-size: 15px; /* Increased from 13px */
    color: #555; /* Darker color for better visibility */
    margin-top: 4px; 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; /* Increased gap */
    align-items: center; 
    font-weight: 500; /* Slightly bolder */
}
.ks-barcode-display { 
    direction: ltr; 
    display: inline-block; 
    font-family: monospace; 
    background: #e9ecef; /* Slightly darker background */
    padding: 2px 8px; /* More padding */
    border-radius: 4px; 
    font-weight: bold;
    font-size: 14px;
    border: 1px solid #dee2e6;
}

.ks-item-actions { display: flex; gap: 8px; }

.ks-icon-btn {
    background: transparent; border: 1px solid #ddd; border-radius: 6px;
    padding: 6px; cursor: pointer; color: #555; transition: 0.2s;
}

.ks-icon-btn:hover { background: #eee; }
.ks-eye-btn:hover { color: #17a2b8; }
.ks-edit-btn:hover { color: #0073aa; }
.ks-delete-btn:hover { color: #dc3545; }

/* Calculation Panel */
.ks-calc-wrapper { max-width: 500px; margin: 0 auto; text-align: center; }
.ks-calc-results {
    margin-top: 30px; background: #f9f9f9; padding: 20px; border-radius: 12px;
    border: 1px dashed #ccc;
}

.ks-calc-row {
    display: flex; justify-content: space-between; padding: 12px 0; font-size: 18px; font-weight: bold; /* Increased font size and weight */
}

.ks-calc-divider { height: 1px; background: #ddd; margin: 15px 0; }

.ks-final-row { font-weight: bold; color: #0073aa; font-size: 22px; /* Bigger final result */ }
.ks-toman-row { color: #28a745; font-size: 18px; font-weight: bold; }

/* Modal */
#ks-add-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 100000;
    display: flex; justify-content: center; align-items: center;
    direction: rtl;
    backdrop-filter: blur(2px);
}

.ks-modal-content {
    background: #fff;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    overflow: hidden;
    animation: ksSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ksSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.ks-modal-header {
    background: #28a745 !important; /* Force Beautiful Green */
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff !important;
    border-radius: 12px 12px 0 0; /* Rounded top corners */
}

.ks-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: #fff !important;
}

.ks-close-modal {
    font-size: 32px; /* Bigger close icon */
    cursor: pointer;
    color: #fff !important; /* White close icon */
    line-height: 1;
    transition: 0.2s;
    width: 40px; /* Bigger touch area */
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
}

.ks-close-modal:hover {
    color: #fff;
    background: rgba(255,255,255,0.2);
}

.ks-modal-body {
    padding: 25px;
}

.ks-form-group { margin-bottom: 20px; }
.ks-form-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #555; font-size: 14px; }
.ks-form-group input[type="text"],
.ks-form-group input[type="number"],
.ks-form-group input[type="tel"] { 
    width: 100%; 
    padding: 12px; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    transition: all 0.2s ease;
    font-size: 15px;
    background: #fdfdfd;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
    box-sizing: border-box; /* Ensure padding doesn't affect width */
}

/* Specific styling for barcode to ensure LTR */
.ks-form-group input[name="barcode"] {
    text-align: left;
    direction: ltr;
}

.ks-form-group input:focus {
    border-color: #28a745;
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

/* Checkbox Styling */
.ks-checkbox-wrapper {
    margin-top: 10px;
    margin-bottom: 5px;
}

.ks-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    justify-content: flex-start;
    gap: 10px;
    white-space: nowrap; /* Prevent breaking into multiple lines */
}

.ks-checkbox-label input[type="checkbox"] {
    margin: 0;
    width: 18px;
    height: 18px;
    accent-color: #28a745;
    cursor: pointer;
}

.ks-checkbox-text {
    user-select: none;
}

/* Live Calc Result */
.ks-live-calc {
    font-size: 16px; /* Increased font size */
    color: #0073aa;
    margin-top: 8px;
    font-weight: 800; /* Bolder */
    background: #e7f5ff;
    padding: 10px 15px; /* More padding */
    border-radius: 6px;
    display: inline-block;
    width: 100%;
    text-align: center;
    border: 1px solid #bde4ff;
    box-sizing: border-box;
}

.ks-submit-btn {
    width: 100%; padding: 14px; background: #28a745; color: #fff;
    border: none; border-radius: 8px; cursor: pointer; font-weight: bold; 
    transition: 0.2s; font-size: 16px;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}
.ks-submit-btn:hover { background: #218838; transform: translateY(-1px); }

.ks-calc-info {
    text-align: center;
    font-size: 13px;
    color: #777;
    margin-top: 20px;
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ks-hidden { display: none !important; }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .ks-tabs-nav { flex-wrap: wrap; }
    .ks-tab-btn { flex: 1; padding: 10px 5px; font-size: 14px; white-space: nowrap; }
    .ks-dashboard-container { 
        height: 100vh; /* Full height on mobile */
        border-radius: 0; 
        width: 100%; 
        max-width: 100%;
        top: 0;
        margin: 0;
    }
    
    .ks-dashboard-header {
        padding-top: 50px; /* Adjust for mobile if needed */
    }

    .ks-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .ks-item-actions {
        width: 100%;
        justify-content: flex-end;
        border-top: 1px solid #eee;
        padding-top: 8px;
    }
}

.ks-header-count {
    font-weight: bold;
    color: #333;
    font-size: 14px;
    width: 100px;
    text-align: right;
}

/* Tashim Styles */
.ks-tashim-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.ks-tashim-input-total {
    text-align: left !important;
    direction: ltr !important;
    font-size: 20px !important;
    font-weight: bold !important;
    color: #0073aa !important;
}

.ks-tashim-percent-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 10px;
    background: #fdfdfd;
}

.ks-percent-symbol {
    font-weight: bold;
    color: #666;
    margin-right: 5px;
}

.ks-tashim-percent-wrapper input {
    border: none !important;
    box-shadow: none !important;
    flex-grow: 1;
    padding: 10px 0 !important;
}

.ks-secondary-btn {
    background: #2271b1 !important;
}

#ks-tashim-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 100000;
    display: flex; justify-content: center; align-items: center;
    direction: rtl;
    backdrop-filter: blur(2px);
}

.ks-items-list {
    counter-reset: row-num;
}

.ks-item {
    position: relative;
    padding-right: 40px; /* Space for number */
}

.ks-item::before {
    counter-increment: row-num;
    content: counter(row-num);
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #eee;
    color: #555;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-size: 12px;
    font-weight: bold;
}
/* Tashim Buttons Row */
.ks-tashim-buttons-row {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.ks-tashim-buttons-row button {
    margin: 0 !important; /* Reset margins to ensure flex works nicely */
    flex: 1; /* Equal width */
}

/* Adjust button height or padding if needed to match */
.ks-tashim-add-btn {
    padding: 14px !important; /* Match ks-submit-btn padding */
    font-size: 14px !important; /* Ensure font size matches if needed */
}

/* Fix conflicts with Nagzare/Sidemenu */
body.ks-dashboard-open .naghzareh-isolated-sidebar,
body.ks-dashboard-open .nagzar-mobile-nav,
body.ks-dashboard-open .naghzareh-nav-trigger-container {
    display: none !important;
    z-index: -1 !important;
    visibility: hidden !important;
}
