/* Direct order modal — centered in viewport */
.order-modal {
    padding: 0;
    border: none;
    border-radius: 16px;
    max-width: min(420px, calc(100vw - 2rem));
    width: min(420px, calc(100vw - 2rem));
    max-height: min(90vh, calc(100vh - 2rem));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-hover);
}

.order-modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.order-modal-inner {
    padding: 1.35rem 1.35rem 1.15rem;
    position: relative;
}

.order-modal-locale-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    padding-right: 2.4rem;
}

.order-modal-locale-toolbar .currency-switch {
    border-color: rgba(18, 18, 18, 0.1);
}

.order-modal-locale-toolbar .currency-btn.active {
    background: var(--accent-color, #4b0082);
    color: #fff;
}

.order-modal-locale-toolbar .lang-toggle-btn {
    background-color: var(--accent-color, #4b0082);
    color: #fff;
    box-shadow: 0 4px 10px rgba(75, 0, 130, 0.22);
}

[data-theme="dark"] .order-modal-locale-toolbar .currency-switch {
    border-color: rgba(255, 255, 255, 0.1);
}

.order-modal-success {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
    margin: 0 0 0.9rem;
    padding: 0.65rem 2.6rem 0.65rem 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(22, 163, 74, 0.35);
    background: rgba(22, 163, 74, 0.1);
    color: var(--text-primary);
}

[data-theme="dark"] .order-modal-success {
    border-color: rgba(74, 222, 128, 0.35);
    background: rgba(34, 197, 94, 0.12);
}

.order-modal-success[hidden] {
    display: none !important;
}

.order-modal-success-text {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.45;
    color: #166534;
}

[data-theme="dark"] .order-modal-success-text {
    color: #bbf7d0;
}

.order-modal-success-dismiss {
    flex: 0 0 auto;
    margin: 0;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    border: 1px solid rgba(22, 163, 74, 0.45);
    background: rgba(255, 255, 255, 0.85);
    color: #166534;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.order-modal-success-dismiss:hover {
    background: #fff;
    border-color: #16a34a;
}

[data-theme="dark"] .order-modal-success-dismiss {
    background: rgba(15, 23, 42, 0.55);
    color: #bbf7d0;
    border-color: rgba(74, 222, 128, 0.4);
}

[data-theme="dark"] .order-modal-success-dismiss:hover {
    background: rgba(15, 23, 42, 0.85);
}

.order-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.order-modal-close:hover {
    background: var(--card-border);
    color: var(--text-primary);
}

.order-modal-title {
    margin: 0 2.25rem 0.35rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.order-modal-sub {
    margin: 0 0 1.1rem;
    font-size: 0.8rem;
    color: #b91c1c;
    font-weight: 500;
    line-height: 1.45;
}

[data-theme="dark"] .order-modal-sub {
    color: #fca5a5;
}

.order-modal-update-hint {
    margin: -0.35rem 0 0.85rem;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    font-size: 0.84rem;
    line-height: 1.45;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(244, 225, 230, 0.35);
    border: 1px solid var(--card-border);
}

[data-theme="dark"] .order-modal-update-hint {
    background: rgba(212, 175, 55, 0.1);
}

.order-modal-duplicate[hidden] {
    display: none !important;
}

.order-modal-duplicate {
    margin: 0 0 1rem;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    border: 1px solid rgba(217, 119, 6, 0.45);
    background: rgba(251, 191, 36, 0.14);
    color: var(--text-primary);
}

[data-theme="dark"] .order-modal-duplicate {
    border-color: rgba(251, 191, 36, 0.35);
    background: rgba(180, 83, 9, 0.18);
}

.order-modal-duplicate-text {
    margin: 0 0 0.75rem;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.45;
    color: #92400e;
}

[data-theme="dark"] .order-modal-duplicate-text {
    color: #fde68a;
}

.order-modal-duplicate-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.order-modal-duplicate-actions .btn {
    min-width: 0;
}

.order-modal-product {
    margin: 0 0 1rem;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    background: rgba(244, 225, 230, 0.3);
    border: 1px solid var(--card-border);
    font-size: 0.9rem;
    font-weight: 500;
}

[data-theme="dark"] .order-modal-product {
    background: rgba(212, 175, 55, 0.08);
}

.order-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.order-field span:first-child {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.order-field input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--bg-color);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.95rem;
}

.order-field input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(75, 0, 130, 0.2);
}

.order-field input:read-only {
    opacity: 0.88;
    cursor: not-allowed;
    border-style: dashed;
}

[data-theme="dark"] .order-field input:focus {
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.order-modal-error {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    font-size: 0.85rem;
    background: rgba(180, 40, 40, 0.1);
    color: #b91c1c;
}

[data-theme="dark"] .order-modal-error {
    color: #fca5a5;
    background: rgba(248, 113, 113, 0.12);
}

.order-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

.order-modal-actions .btn {
    min-width: 6.5rem;
}

/* .btn uses display:inline-flex, which overrides the UA [hidden] rule — force hide when success is shown */
.order-modal #order-modal-submit[hidden] {
    display: none !important;
}

/* My orders (header) — wider dialog, scrollable list */
.my-orders-dialog {
    max-width: min(520px, calc(100vw - 2rem));
    width: min(520px, calc(100vw - 2rem));
}

.my-orders-dialog-inner {
    padding-bottom: 1rem;
}

.my-orders-loading {
    margin: 0.5rem 0 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.my-orders-empty {
    margin: 0.5rem 0 0.75rem;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.my-orders-list {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-height: min(52vh, 22rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.my-orders-item {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 0.65rem;
    align-items: start;
    padding: 0.6rem 0.65rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--bg-color);
}

.my-orders-item-media {
    width: 56px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--card-border);
    flex-shrink: 0;
}

.my-orders-item-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.my-orders-item-media--empty {
    background: linear-gradient(135deg, #e8e4df, #d4cec6);
}

[data-theme="dark"] .my-orders-item-media--empty {
    background: linear-gradient(135deg, #2a2a2a, #3d3d3d);
}

.my-orders-item-body {
    min-width: 0;
}

.my-orders-item-meta {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.my-orders-item-title {
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.my-orders-item-when {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}

.my-orders-item-price {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.my-orders-item-qty {
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.my-orders-dialog-actions {
    margin-top: 0.35rem;
}
