* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, 'Arial Hebrew', 'David';
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    direction: rtl;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Compact view while searching */
.search-active header,
.search-active .display-mode-section {
    display: none;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.font-size-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.font-size-control label {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

#fontSizeSlider {
    width: 100px;
    cursor: pointer;
}

#fontSizeValue {
    font-size: 14px;
    color: #667eea;
    font-weight: 500;
    min-width: 45px;
    text-align: center;
}

h1 {
    color: #333;
    font-size: 2em;
}

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    background-color: #ccc;
    border-radius: 34px;
    transition: background-color 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    right: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(-24px);
}

.toggle-label {
    font-size: 16px;
    color: #333;
    user-select: none;
}

.display-mode-section {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.display-mode-section label {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

.display-mode-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.display-mode-btn {
    padding: 10px 20px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.display-mode-btn:hover {
    border-color: #667eea;
    background: #f0f0f0;
    transform: translateY(-2px);
}

.display-mode-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.display-mode-btn.active:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.search-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.font-size-section {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-section input,
.search-section select {
    flex: 1;
    min-width: 200px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    direction: rtl;
    text-align: right;
    background: white;
    cursor: pointer;
}

.search-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.search-section input:focus,
.search-section select:focus {
    outline: none;
    border-color: #667eea;
}

.search-section select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 10px center;
    padding-right: 10px;
    padding-left: 35px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #48bb78;
    color: white;
}

.btn-secondary:hover {
    background: #38a169;
    transform: translateY(-2px);
}

#searchBtn, #clearSearchBtn {
    background: #48bb78;
    color: white;
}

#clearSearchBtn {
    background: #f56565;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.items-grouped {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.group-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.group-title {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    font-weight: 600;
}

.group-title.level-low {
    color: #c53030;
    border-bottom-color: #fed7d7;
}

.group-title.level-normal {
    color: #2c5282;
    border-bottom-color: #bee3f8;
}

.group-title.level-high {
    color: #22543d;
    border-bottom-color: #c6f6d5;
}

.item-card {
    background: white;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

/* Level background colors on item cards */
.item-card.level-low {
    background: #fed7d7;
    border-left: 4px solid #c53030;
}

.item-card.level-normal {
    background: #bee3f8;
    border-left: 4px solid #2c5282;
}

.item-card.level-high {
    background: #c6f6d5;
    border-left: 4px solid #22543d;
}

.item-actions {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.btn-edit,
.btn-delete {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-edit {
    background: #48bb78;
    color: white;
}

.btn-edit:hover {
    background: #38a169;
    transform: scale(1.1);
}

.btn-delete {
    background: #f56565;
    color: white;
}

.btn-delete:hover {
    background: #e53e3e;
    transform: scale(1.1);
}

.item-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #f0f0f0;
}

.item-name {
    font-size: 1em;
    font-weight: bold;
    color: #333;
    margin-bottom: 0;
    line-height: 1.2;
}

.item-category {
    color: #666;
    font-size: 0.85em;
    margin-bottom: 6px;
}

.item-amount {
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
    color: #667eea;
    flex: 1;
    text-align: center;
}

.item-levels {
    font-size: 0.85em;
    color: #666;
    margin: 6px 0;
    padding: 6px;
    background: #f5f5f5;
    border-radius: 5px;
    text-align: center;
}

.level-label {
    font-weight: 500;
}

.level-value {
    font-weight: bold;
}

.level-value.low {
    color: #c53030;
}

.level-value.high {
    color: #22543d;
}

.level-separator {
    margin: 0 8px;
    color: #999;
}


.item-dates {
    font-size: 0.75em;
    color: #999;
    margin: 4px 0;
    line-height: 1.3;
}

.amount-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.amount-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.amount-btn.minus {
    background: #f56565;
    color: white;
}

.amount-btn.plus {
    background: #48bb78;
    color: white;
}

.amount-btn:hover {
    transform: scale(1.1);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.close {
    color: #aaa;
    float: left;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    left: 20px;
    top: 15px;
}

.close:hover {
    color: #000;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    direction: rtl;
    text-align: right;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group button {
    width: 100%;
    margin-top: 10px;
}

#submitBtn {
    width: 100%;
    margin-bottom: 20px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: white;
    font-size: 1.2em;
}

/* Color Settings Modal */
.color-settings-form {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.color-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.color-group label,
.color-label {
    font-weight: 500;
    color: #333;
    font-size: 16px;
    margin-bottom: 5px;
}

.color-picker {
    width: 100%;
    height: 50px;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    padding: 2px;
    background: white;
}

.color-preview-item {
    background: white;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    margin-top: 10px;
}

.clickable-preview {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.clickable-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}

.clickable-preview:active {
    transform: translateY(0);
}

.color-input-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
    border: none;
    padding: 0;
    margin: 0;
}

.color-preview-item .item-name {
    font-size: 1em;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.2;
}

.color-preview-item .item-amount {
    font-size: 1.2em;
    font-weight: bold;
    margin: 8px 0;
    color: #667eea;
    text-align: center;
}

.color-preview-item .item-levels {
    font-size: 0.85em;
    color: #666;
    margin: 6px 0;
    padding: 6px;
    background: #f5f5f5;
    border-radius: 5px;
    text-align: center;
}

.color-preview-item .level-label {
    font-weight: 500;
}

.color-preview-item .level-value {
    font-weight: bold;
}

.color-preview-item .level-separator {
    margin: 0 8px;
    color: #999;
}

.color-preview-background {
    width: 100%;
    height: 100px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ddd;
}

.preview-background-label {
    color: white;
    font-weight: 500;
    font-size: 16px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.color-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.color-buttons button {
    flex: 1;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        padding: 15px 20px;
        margin-bottom: 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    .header-controls {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .font-size-section {
        padding: 12px 15px;
    }

    .font-size-control {
        width: 100%;
        justify-content: space-between;
    }

    #fontSizeSlider {
        flex: 1;
        max-width: 150px;
    }

    .toggle-label {
        font-size: 14px;
    }

    .display-mode-section {
        padding: 10px 15px;
        margin-bottom: 15px;
    }

    .display-mode-section label {
        font-size: 14px;
    }

    .display-mode-btn {
        padding: 8px 15px;
        font-size: 14px;
    }

    .search-section {
        flex-direction: column;
        padding: 15px;
        margin-bottom: 15px;
    }

    .search-section input,
    .search-section select {
        width: 100%;
        min-width: unset;
        padding: 8px;
        font-size: 14px;
    }

    .search-buttons {
        width: 100%;
        display: flex;
        gap: 10px;
    }

    .search-buttons button {
        flex: 1;
        padding: 8px;
        font-size: 14px;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .item-card {
        padding: 12px;
        display: flex;
        flex-direction: column;
    }

    .item-image {
        height: 80px;
        margin-bottom: 8px;
    }

    .item-name {
        font-size: 1.15em;
        margin-bottom: 0;
    }

    .item-category {
        font-size: 0.85em;
        margin-bottom: 5px;
    }

    .item-amount {
        font-size: 1.4em;
        margin: 0;
    }

    .item-levels {
        font-size: 0.75em;
        margin: 5px 0;
        padding: 5px;
    }

    .item-dates {
        font-size: 0.7em;
        margin: 5px 0;
    }

    .amount-controls {
        gap: 10px;
        margin-top: 4px;
    }

    .amount-btn {
        width: 30px;
        height: 30px;
        font-size: 1em;
    }

    .btn-edit,
    .btn-delete {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .item-actions {
        top: 5px;
        left: 5px;
        gap: 5px;
    }

    .group-section {
        padding: 15px;
    }

    .group-title {
        font-size: 1.2em;
        margin-bottom: 15px;
        padding-bottom: 8px;
    }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .item-card {
        padding: 10px;
    }

    .item-name {
        font-size: 1.05em;
    }

    .item-amount {
        font-size: 1.3em;
        margin: 0;
    }

    .amount-btn {
        width: 28px;
        height: 28px;
    }
}

