:root {
    --color-bg: #dde7ff;
    --color-bg-alt: #f5f5ff;
    --color-surface: rgba(255, 255, 255, 0.78);
    --color-border: #e1dfdd;
    --color-border-strong: #c8c6c4;
    --color-primary: #0f6cbd;
    --color-primary-hover: #115ea3;
    --color-primary-text: #ffffff;
    --color-text: #201f1e;
    --color-text-muted: #605e5c;
    --radius-m: 14px;
    --shadow-m: 0 18px 45px rgba(15, 23, 42, 0.22);
    --shadow-modal: 0 22px 60px rgba(15, 23, 42, 0.35);
}

* {
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    padding: 18px 12px;
    min-height: 100vh;
    background: radial-gradient(circle at 0 0, rgba(147, 197, 253, 0.55), transparent 55%),
                radial-gradient(circle at 100% 100%, rgba(196, 181, 253, 0.6), transparent 55%),
                linear-gradient(135deg, var(--color-bg), var(--color-bg-alt));
    direction: rtl;
    color: var(--color-text);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    background-color: var(--color-surface);
    padding: 18px 18px 22px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-m);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

h1 {
    margin: 0 0 16px;
    text-align: center;
    font-size: 19px;
    font-weight: 600;
}

.top-actions {
    margin-bottom: 12px;
    display: flex;
    justify-content: flex-end;
}

.product-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px 12px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}

input[type="text"],
input[type="number"],
textarea {
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    background-color: #fbfbfb;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
    background-color: #ffffff;
}

textarea {
    resize: vertical;
    min-height: 60px;
}

.form-actions {
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
}

.btn {
    padding: 8px 14px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    min-height: 36px;
    white-space: nowrap;
}

.btn.primary {
    background-color: var(--color-primary);
    color: var(--color-primary-text);
    border-color: var(--color-primary);
    box-shadow: 0 2px 6px rgba(15, 108, 189, 0.35);
}

.btn.primary:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    box-shadow: 0 4px 10px rgba(15, 94, 163, 0.4);
}

.btn.secondary {
    background-color: #f3f2f1;
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn.secondary:hover {
    background-color: #e1dfdd;
}

.btn.danger {
    background-color: #d13438;
    color: #ffffff;
    border-color: #d13438;
}

.btn.danger:hover {
    background-color: #a4262c;
    border-color: #a4262c;
}

.alert {
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 13px;
}

.alert.success {
    background-color: #dff6dd;
    color: #107c10;
    border: 1px solid #c3e6cb;
}

.alert.error {
    background-color: #fde7e9;
    color: #a80000;
    border: 1px solid #f4abab;
}

.search-box {
    margin: 12px 0 6px;
}

.search-box label {
    display: block;
    margin-bottom: 4px;
}

.search-box input {
    width: 100%;
    max-width: 360px;
}

.product-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 4px;
}

.product-card {
    background-color: rgba(255, 255, 255, 0.92);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    padding: 10px 12px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}

.product-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
    border-color: rgba(15, 108, 189, 0.25);
}

.product-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.product-row {
    font-size: 12px;
    color: var(--color-text-muted);
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    flex: 1 1 auto;
    text-align: right;
}

.product-card-main {
    display: flex;
    justify-content: flex-start;
    margin-top: 2px;
}

.product-price {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-primary);
}

.product-card-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 6px 12px;
    margin-top: 4px;
}

.detail-block {
    font-size: 12px;
}

.detail-label {
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.detail-value {
    line-height: 1.5;
}

.product-card.hide-row {
    display: none;
}

.empty-state {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.75);
    text-align: center;
    font-size: 13px;
    color: var(--color-text-muted);
}

.buttons {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

.card-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Modal (Fluent-like) */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.35);
}

.modal-dialog {
    position: relative;
    background-color: var(--color-surface);
    border-radius: var(--radius-m);
    padding: 14px 16px 16px;
    max-width: 640px;
    width: calc(100% - 32px);
    box-shadow: var(--shadow-modal);
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    z-index: 1001;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    color: var(--color-text-muted);
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-subtitle {
    margin: 0;
    font-size: 12px;
    color: var(--color-text-muted);
}

.confirm-body {
    background: radial-gradient(circle at 0 0, rgba(147, 197, 253, 0.45), transparent 55%),
                radial-gradient(circle at 100% 100%, rgba(196, 181, 253, 0.5), transparent 55%),
                linear-gradient(135deg, var(--color-bg), var(--color-bg-alt));
}

.product-list.compact .product-card {
    padding: 8px 10px;
}

.confirm-text {
    margin-top: 12px;
    font-size: 13px;
}

.confirm-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

@media (min-width: 640px) {
    .container {
        padding: 20px 22px 24px;
    }

    h1 {
        font-size: 20px;
    }

    .product-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-actions {
        grid-column: 1 / -1;
    }

    .product-list {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

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

    .container {
        padding: 14px 10px 16px;
    }

    .modal-dialog {
        max-width: 100%;
        width: 100%;
    }

    .modal-body {
        max-height: calc(100vh - 56px);
    }
}
