/* Orders Page Styles */
.orders-page-wrapper {
    background: #f4f5f7;
    min-height: calc(100vh - 60px);
    padding: 20px 0;
    display: flex;
    justify-content: center;
}

.orders-container {
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: 80vh; /* Уменьшил высоту до 80% окна */
    min-height: 600px;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

/* Sidebar */
.orders-sidebar {
    width: 350px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.order-list {
    flex: 1;
    overflow-y: auto;
}

.order-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f9f9f9;
    cursor: pointer;
    transition: background 0.2s;
}

.order-item:hover {
    background: #f8f9fa;
}

.order-item.active {
    background: #fff4ed;
    border-left: 4px solid #FA6400;
}

.order-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.order-id {
    font-weight: 600;
    color: #1a1a1a;
}

.order-date {
    font-size: 12px;
    color: #808080;
}

.order-last-msg {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Content */
.order-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden; /* Прячем внешний скролл */
}

.order-details-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    flex-shrink: 0; /* Шапка не должна сжиматься */
}

.order-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-item label {
    display: block;
    font-size: 11px;
    color: #808080;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.info-item span {
    font-weight: 500;
    color: #1a1a1a;
}

/* Timeline */
.order-timeline {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    position: relative;
    padding: 0 10px;
}

.order-timeline::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: #e0e0e0;
    z-index: 1;
}

.timeline-step {
    position: relative;
    z-index: 2;
    text-align: center;
    width: 80px;
}

.step-circle {
    width: 22px;
    height: 22px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    margin: 0 auto 8px;
    transition: all 0.3s;
}

.step-label {
    font-size: 10px;
    color: #808080;
    font-weight: 500;
}

.timeline-step.active .step-circle {
    background: #FA6400;
    border-color: #FA6400;
    box-shadow: 0 0 0 4px rgba(250, 100, 0, 0.1);
}

.timeline-step.active .step-label {
    color: #1a1a1a;
}

.timeline-step.completed .step-circle {
    background: #00c853;
    border-color: #00c853;
}

.timeline-step.completed .step-circle::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    line-height: 18px;
}

/* Chat */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f9fafc;
    overflow: hidden; /* Важно для внутреннего скролла */
}

.chat-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.chat-toggle {
    display: flex;
    background: #f0f0f0;
    padding: 3px;
    border-radius: 8px;
    width: 180px;
}

.toggle-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 5px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
}

.toggle-btn.active {
    background: #fff !important;
    color: #FA6400 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px; /* Увеличил отступ между группами сообщений */
}

.msg-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 600px;
}

.msg-wrapper.user {
    align-self: flex-end;
}

.msg-wrapper.other {
    align-self: flex-start;
}

.msg-sender {
    font-size: 11px;
    font-weight: 700;
    color: #808080;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.msg-wrapper.user .msg-sender {
    text-align: right;
    color: #FA6400;
}

.msg {
    width: fit-content;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    position: relative;
    line-height: 1.4;
    word-break: break-word;
}

.msg.user {
    align-self: flex-end;
    background: #FA6400; /* Цвет Win-Buy оранжевый */
    color: #fff;
    border-bottom-right-radius: 2px;
}

.msg.other {
    align-self: flex-start;
    background: #fff;
    color: #1a1a1a;
    border-bottom-left-radius: 2px;
    border: 1px solid #e0e0e0;
}

.msg.system {
    align-self: center;
    /* background: #f0f0f0; */
    color: #666;
    font-size: 12px;
    padding: 5px 15px;
    border-radius: 20px;
    max-width: 90%;
}

.msg-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
    font-size: 10px;
}

.msg-time {
    opacity: 0.7;
}

.msg-status {
    display: flex;
    align-items: center;
}

.msg-status i {
    font-size: 11px;
}

.msg-wrapper.pending {
    opacity: 0.7;
    animation: msgPulse 1.5s infinite;
}

@keyframes msgPulse {
    0% { opacity: 0.5; }
    50% { opacity: 0.8; }
    100% { opacity: 0.5; }
}

.msg-attachments {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.att-photo {
    width: 150px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
}

.att-file {
    background: rgba(0,0,0,0.05);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}

/* Input Area */
.chat-input-area {
    background: #fff;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
}

.input-warning {
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #856404;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    margin-bottom: 10px;
    display: none;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f4f5f7;
    padding: 8px 15px;
    border-radius: 25px;
}

.chat-input {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 0;
    font-size: 14px;
    outline: none;
}

.icon-btn {
    background: none;
    border: none;
    color: #808080;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: #FA6400;
}

.btn-send {
    color: #FA6400; /* Win-Buy orange */
}

.att-expiry-hint {
    font-size: 10px;
    color: #ff9800;
    margin-top: 5px;
    font-weight: 600;
}

.msg.user .att-expiry-hint {
    color: #ffe0b2;
}

/* Review Widget */
.msg-review-widget {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    width: 100%;
}

.review-card {
    background: #fff;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.06);
    text-align: center;
    max-width: 500px;
}

.review-card h5 {
    font-weight: 700;
    margin-bottom: 20px;
    font-size: 24px;
}

.review-card .stars {
    font-size: 40px;
    color: #e0e0e0;
    margin-bottom: 20px;
}

.review-card .stars i {
    margin: 0 5px;
    cursor: pointer;
    transition: color 0.2s;
}

.review-card .stars i:hover {
    color: #ffd700;
}

.review-desc {
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    font-weight: 500;
}

/* Dialogue Ended */
.dialog-ended-msg {
    animation: fadeIn 0.5s ease;
}

.dialog-ended-msg h5 {
    color: #FA6400;
}

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

/* Client Orders Redesign */
body.orders-client-page {
    height: 100vh;
    overflow: hidden;
}

body.orders-client-page .orders-page-wrapper {
    background: linear-gradient(180deg, #f2f4f8 0%, #eceff4 100%);
    min-height: calc(100vh - 112px);
    padding: 0;
}

body.orders-client-page .orders-container {
    width: 100%;
    max-width: none;
    height: calc(100vh - 112px);
    min-height: 680px;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid #e6e9ef;
}

body.orders-client-page .orders-sidebar {
    width: 380px;
    border-right: 1px solid #e6e9ef;
    background: #ffffff;
}

body.orders-client-page .sidebar-header {
    padding: 18px 18px 14px;
    border-bottom: 1px solid #eef1f5;
}

body.orders-client-page .sidebar-header h3 {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.2px;
}

body.orders-client-page .order-filter-tabs {
    display: flex;
    gap: 8px;
}

body.orders-client-page .order-filter-tab {
    flex: 1;
    border: 1px solid #e1e5ec;
    background: #f7f9fc;
    color: #5f6b7b;
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

body.orders-client-page .order-filter-tab.active {
    background: #1d2533;
    color: #ffffff;
    border-color: #1d2533;
}

body.orders-client-page .order-filter-count {
    min-width: 22px;
    height: 22px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
}

body.orders-client-page .order-filter-tab:not(.active) .order-filter-count {
    background: #e8edf5;
}

body.orders-client-page .order-item {
    border-bottom: 1px solid #f2f4f8;
    padding: 14px 16px;
}

body.orders-client-page .order-item.active {
    background: #fff6f0;
}

body.orders-client-page .order-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

body.orders-client-page .order-state-badge {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.35px;
    border-radius: 999px;
    padding: 4px 8px;
}

body.orders-client-page .order-state-badge.open {
    background: rgba(34, 197, 94, 0.12);
    color: #1f9c4a;
}

body.orders-client-page .order-state-badge.closed {
    background: rgba(108, 117, 132, 0.14);
    color: #576173;
}

body.orders-client-page .order-total {
    color: #1a1f2b;
    font-size: 12px;
    font-weight: 700;
}

body.orders-client-page .order-main {
    background: #f5f7fb;
}

body.orders-client-page .order-details-header {
    background: #ffffff;
    border-bottom: 1px solid #e8ecf3;
    box-shadow: 0 4px 16px rgba(18, 24, 40, 0.04);
    padding: 18px 20px;
}

body.orders-client-page .order-info-grid {
    margin-bottom: 14px;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

body.orders-client-page .info-item {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #ebeff5;
    padding: 10px 12px;
    box-shadow: 0 4px 14px rgba(13, 22, 37, 0.04);
}

body.orders-client-page .info-item label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.55px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

body.orders-client-page .info-item span {
    font-size: 14px;
    font-weight: 700;
}

body.orders-client-page .order-products-panel {
    margin-bottom: 14px;
    background: #ffffff;
    border: 1px solid #ebeff5;
    border-radius: 16px;
    box-shadow: 0 4px 14px rgba(13, 22, 37, 0.04);
    padding: 12px;
}

body.orders-client-page .order-products-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.55px;
    color: #7a8494;
    margin-bottom: 10px;
}

body.orders-client-page .order-products-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 8px;
}

body.orders-client-page .order-product-card {
    display: grid;
    grid-template-columns: 42px 1fr;
    grid-template-rows: auto auto;
    gap: 2px 10px;
    align-items: center;
    background: #f7f9fc;
    border: 1px solid #ebeff5;
    border-radius: 12px;
    padding: 8px;
    text-decoration: none;
    color: #1b2130;
}

body.orders-client-page .order-product-thumb {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
    grid-row: 1 / span 2;
    background: #eef2f7;
}

body.orders-client-page .order-product-name {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.orders-client-page .order-product-meta {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
}

body.orders-client-page .order-product-paid {
    grid-column: 2;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
    font-size: 10px;
    font-weight: 800;
    color: #0f8f4b;
}

body.orders-client-page .order-timeline {
    margin-top: 0;
}

body.orders-client-page .timeline-step.completed .step-circle::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 7px;
    width: 6px;
    height: 10px;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    transform: rotate(45deg);
}

.msg-status {
    min-width: 20px;
    min-height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}

.status-checks {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    line-height: 1;
}

.status-checks svg {
    width: 11px;
    height: 11px;
}

.status-checks.is-sent {
    color: rgba(255, 255, 255, 0.7);
}

.msg.other .status-checks.is-sent,
.msg.system .status-checks.is-sent {
    color: #9aa4b2;
}

.status-checks.is-read {
    color: #66b7ff;
}

.status-sending {
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
    display: inline-flex;
    align-items: center;
}

@media (max-width: 1100px) {
    body.orders-client-page {
        height: auto;
        overflow: auto;
    }

    body.orders-client-page .orders-page-wrapper {
        min-height: auto;
    }

    body.orders-client-page .orders-container {
        height: auto;
        min-height: 0;
        flex-direction: column;
    }

    body.orders-client-page .orders-sidebar {
        width: 100%;
        max-height: 44vh;
    }

    body.orders-client-page .order-main {
        min-height: 56vh;
    }

    body.orders-client-page .order-products-list {
        grid-template-columns: 1fr;
    }
}

/* Invoice tools (admin/seller + client widget) */
.dialog-invoice-modal {
    position: fixed;
    inset: 0;
    z-index: 3200;
    display: none;
}

.dialog-invoice-modal.open {
    display: block;
}

.dialog-invoice-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.dialog-invoice-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100vw - 24px));
    max-height: min(84vh, 860px);
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid #e8edf4;
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dialog-invoice-head,
.dialog-invoice-foot {
    padding: 14px 16px;
    background: #fbfcfe;
    border-bottom: 1px solid #edf1f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dialog-invoice-foot {
    border-top: 1px solid #edf1f6;
    border-bottom: 0;
    gap: 10px;
    justify-content: flex-end;
}

.dialog-invoice-head h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
}

.dialog-invoice-close {
    border: 0;
    background: transparent;
    color: #7f8794;
    width: 32px;
    height: 32px;
    border-radius: 10px;
}

.dialog-invoice-close:hover {
    background: #f1f4f9;
}

.dialog-invoice-body {
    padding: 14px 16px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dialog-invoice-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialog-invoice-item {
    border: 1px solid #ebeff5;
    background: #f8fafd;
    border-radius: 12px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 18px 1fr auto;
    gap: 10px;
    align-items: center;
}

.dialog-invoice-item input {
    width: 16px;
    height: 16px;
}

.dialog-invoice-item-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dialog-invoice-item-title {
    font-size: 13px;
    font-weight: 700;
    color: #1b2130;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.dialog-invoice-item-sub {
    font-size: 11px;
    color: #7b8492;
}

.dialog-invoice-item-price {
    font-size: 13px;
    font-weight: 800;
    color: #263042;
}

.dialog-invoice-summary {
    border: 1px solid #ebeff5;
    background: #ffffff;
    border-radius: 12px;
    padding: 12px;
}

.dialog-invoice-total {
    font-size: 14px;
    font-weight: 800;
    color: #1d2533;
}

.dialog-invoice-shops {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.dialog-invoice-shops span {
    font-size: 11px;
    color: #5f6b7b;
    background: #f3f6fb;
    border: 1px solid #e8edf5;
    border-radius: 999px;
    padding: 4px 8px;
}

.dialog-invoice-scope {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dialog-invoice-scope label {
    font-size: 11px;
    font-weight: 700;
    color: #6c7583;
    text-transform: uppercase;
}

.dialog-invoice-scope select {
    border: 1px solid #dce3ed;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
}

.invoice-system-msg {
    background: transparent;
    padding: 0;
}

.msg-wrapper.system-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.invoice-widget-card {
    width: min(420px, 92vw);
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #e5ebf3;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(22, 33, 52, 0.08);
    padding: 16px;
}

.invoice-widget-title {
    font-size: 12px;
    font-weight: 800;
    color: #5f6b7b;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.invoice-widget-scope {
    font-size: 14px;
    font-weight: 700;
    color: #1f2a3b;
    margin-top: 6px;
}

.invoice-widget-total {
    font-size: 26px;
    font-weight: 900;
    color: #171d2b;
    margin-top: 8px;
    letter-spacing: -0.5px;
}

.invoice-pay-btn {
    display: block;
    margin-top: 12px;
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: var(--4win-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    padding: 10px 12px;
    text-align: center;
    text-decoration: none;
}

.invoice-pay-note {
    margin-top: 12px;
    font-size: 12px;
    font-weight: 700;
    color: #6c7583;
    text-align: center;
}

.invoice-widget-caption {
    margin-top: 8px;
    font-size: 11px;
    color: #98a1af;
    text-align: center;
}
