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

:root {
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: #ffffff;
    --bg-messages: #f5f5f5;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
    --bg-primary: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    --bg-secondary: #2d3748;
    --bg-messages: #1a202c;
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --border-color: #4a5568;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.ngrok-hint {
    background: rgba(102, 126, 234, 0.95);
    color: #fff;
    padding: 8px 12px;
    text-align: center;
    font-size: 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.4;
}

@media (min-width: 640px) {
    .ngrok-hint {
        padding: 10px 16px;
        font-size: 14px;
        gap: 12px;
    }
}
.ngrok-hint-text {
    flex: 1;
    text-align: center;
}
.ngrok-hint-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    flex-shrink: 0;
}
.ngrok-hint-close:hover {
    opacity: 1;
}
body.has-ngrok-hint { padding-top: 40px; }
@media (min-width: 640px) {
    body.has-ngrok-hint { padding-top: 48px; }
}
[data-theme="dark"] .ngrok-hint { background: rgba(45, 55, 72, 0.98); }

.reload-hint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    z-index: 10000;
    box-shadow: var(--shadow);
    max-width: 90%;
}
.reload-hint p { margin: 0 0 12px; color: var(--text-primary); }
.reload-hint #reload-button {
    margin-top: 12px;
    padding: 12px 24px;
    font-size: 16px;
    cursor: pointer;
    background: var(--bg-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
}
.reload-hint #reload-button:hover { opacity: 0.9; }

html {
    height: 100%;
    height: -webkit-fill-available;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    height: 100vh;
    height: -webkit-fill-available;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    transition: background 0.3s ease;
    overflow: hidden;
    position: fixed;
    width: 100%;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Предотвращаем выделение текста на мобильных */
@media (max-width: 640px) {
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    input, textarea {
        -webkit-user-select: text;
        user-select: text;
    }
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    height: -webkit-fill-available;
    max-height: 100vh;
    background: var(--bg-secondary);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

/* Десктопная версия */
@media (min-width: 640px) {
    html, body {
        position: relative;
        overflow: auto;
    }
    body {
        padding: 20px;
        position: relative;
    }
    .chat-container {
        height: 90vh;
        border-radius: 20px;
        box-shadow: var(--shadow);
        max-height: 90vh;
    }
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    -webkit-app-region: drag;
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-chip-button {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: white;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 18px;
    cursor: pointer;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-icon-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    touch-action: manipulation;
}

.header-icon-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header-chip-button:hover {
    background: rgba(255, 255, 255, 0.24);
}

.user-info {
    font-size: 10px;
    opacity: 0.9;
    display: none;
}

@media (min-width: 640px) {
    .chat-header {
        padding: 20px;
    }
    .chat-header h1 {
        font-size: 24px;
    }
    .user-info {
        font-size: 12px;
        display: block;
    }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    background: var(--bg-messages);
    transition: background 0.3s ease, padding-bottom 0.3s ease;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

@media (min-width: 640px) {
    .chat-messages {
        padding: 12px 14px;
    }
}

.message {
    margin-bottom: 8px;
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

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

.user-message {
    justify-content: flex-end;
}

.bot-message {
    justify-content: flex-start;
    flex-direction: column;
    align-items: flex-start;
}

.message-content {
    max-width: 82%;
    padding: 7px 10px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.32;
    font-size: 13px;
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
    cursor: text;
}

@media (min-width: 640px) {
    .message-content {
        max-width: 76%;
        padding: 8px 12px;
        font-size: 13px;
    }
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bot-message .message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: background 0.3s ease, color 0.3s ease;
}

[data-theme="dark"] .bot-message .message-content {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
    animation: typingPulse 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 80%, 100% {
        opacity: 0.25;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-1px);
    }
}

/* Inline кнопки под сообщениями (как в Telegram) */
.inline-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    padding: 0 2px;
}

.inline-button {
    padding: 5px 9px;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 14px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s;
    touch-action: manipulation;
    white-space: nowrap;
}

.inline-button:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
}

.inline-button:active {
    transform: scale(0.98);
    background: rgba(102, 126, 234, 0.25);
}

.restaurant-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.restaurant-option {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.restaurant-option.selected {
    border-color: #667eea;
    box-shadow: inset 0 0 0 1px rgba(102, 126, 234, 0.25);
}

.restaurant-option span {
    font-size: 11px;
    color: var(--text-secondary);
}

.chat-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    width: min(100%, 340px);
}

.chat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.chat-card.form-card,
.chat-card.menu-item-card,
.chat-card.cart-item-card,
.chat-card.menu-list-card {
    width: 100%;
}

.menu-list-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.compact-menu-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 7px 8px;
    background: rgba(102, 126, 234, 0.03);
}

.compact-menu-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.compact-menu-main {
    min-width: 0;
    flex: 1;
}

.compact-menu-title-row {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px;
}

.compact-menu-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.compact-menu-description {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.25;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.compact-menu-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.compact-menu-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.compact-add-button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 9px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
}

.compact-add-button:disabled {
    background: rgba(160, 160, 160, 0.4);
    color: rgba(255, 255, 255, 0.85);
    cursor: not-allowed;
}

.compact-details-toggle {
    margin-top: 5px;
    border: none;
    background: transparent;
    color: #667eea;
    font-size: 12px;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.compact-menu-details {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
}

.compact-qty-row {
    margin-top: 0;
    margin-bottom: 6px;
}

.compact-chip-group {
    gap: 6px;
}

.compact-modifier-chip {
    padding: 5px 8px;
    font-size: 11px;
}

.compact-comment {
    min-height: 44px;
    font-size: 12px;
}

.compact-detail-add {
    margin-top: 8px;
    width: 100%;
}

.compact-menu-stock {
    font-size: 11px;
    font-weight: 700;
    color: #a66300;
    white-space: normal;
    line-height: 1.25;
    max-width: 96px;
    text-align: right;
}

.stop-listed-card {
    border-color: rgba(231, 76, 60, 0.55);
    background: rgba(231, 76, 60, 0.06);
}

[data-theme="dark"] .chat-card {
    background: rgba(255, 255, 255, 0.08);
}

.chat-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chat-card-description,
.chat-card-meta {
    font-size: 12px;
    line-height: 1.28;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.cart-editor-label {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

.cart-item-card {
    padding: 8px;
}

.cart-item-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.cart-item-summary-main {
    min-width: 0;
    flex: 1;
}

.cart-item-title {
    margin-bottom: 2px;
    font-size: 13px;
}

.cart-item-summary-meta {
    margin-bottom: 0;
    font-size: 11px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-summary-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.cart-item-qty-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.12);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

.cart-item-price {
    font-size: 13px;
}

.cart-item-editor {
    margin-top: 6px;
    border-top: 1px dashed var(--border-color);
    padding-top: 6px;
}

.cart-item-editor-toggle {
    list-style: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    color: #667eea;
}

.cart-item-editor-toggle::-webkit-details-marker {
    display: none;
}

.cart-item-editor-body {
    margin-top: 6px;
}

.chat-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 6px;
}

.chat-card-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.chat-card-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 11px;
    font-weight: 600;
}

.chat-card-badge.stop {
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
}

.chat-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
}

.chat-card-action {
    border: none;
    border-radius: 10px;
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(102, 126, 234, 0.12);
    color: var(--text-primary);
    cursor: pointer;
}

.chat-card-action.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
}

.modifier-chip {
    border: 1px solid rgba(102, 126, 234, 0.25);
    background: rgba(102, 126, 234, 0.08);
    color: var(--text-primary);
    border-radius: 999px;
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.modifier-chip.selected {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.55);
}

.card-text-input,
.card-textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    margin-top: 7px;
}

.card-textarea {
    min-height: 56px;
    resize: vertical;
}

.cart-edit-textarea {
    min-height: 44px;
    margin-top: 6px;
}

.qty-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 7px;
}

.qty-button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 9px;
    background: rgba(102, 126, 234, 0.12);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.qty-value {
    min-width: 24px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.cart-qty-row {
    margin-top: 8px;
    margin-bottom: 4px;
}

.cart-editor-actions {
    justify-content: space-between;
}

[data-theme="dark"] .inline-button {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.4);
    color: var(--text-primary);
}

[data-theme="dark"] .inline-button:hover {
    background: rgba(102, 126, 234, 0.3);
}

@media (min-width: 640px) {
    .inline-button {
        padding: 6px 10px;
        font-size: 12px;
    }
}

.chat-input-container {
    border-top: 1px solid var(--border-color);
    padding: 6px 10px max(8px, env(safe-area-inset-bottom));
    background: var(--bg-secondary);
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.chat-input-container.main-input-active .menu-buttons-row {
    display: none;
}

/* Поднимаем поле ввода над клавиатурой на мобильных */
@media (max-width: 640px) {
    .chat-container {
        --keyboard-height: 0px;
    }
    
    /* Поле ввода фиксируем над клавиатурой: bottom = высота клавиатуры */
    .chat-input-container.keyboard-visible {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: var(--keyboard-height, 0) !important;
        top: auto !important;
        width: 100% !important;
        z-index: 9999 !important;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
        background: var(--bg-secondary);
        transform: none !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }

    .chat-input-container.card-field-active {
        display: none;
    }
    
    .chat-container.keyboard-visible {
        padding-bottom: 0;
    }
    
    /* Область сообщений: отступ снизу = высота поля ввода + клавиатура, чтобы контент не прятался */
    .chat-messages.keyboard-visible {
        padding-bottom: calc(88px + var(--keyboard-height, 280px)) !important;
        margin-bottom: 0;
        -webkit-overflow-scrolling: touch;
    }
    
    .chat-container.keyboard-visible .chat-messages {
        max-height: calc(100vh - var(--keyboard-height, 280px) - 60px) !important;
        overflow-y: auto !important;
    }
    
    #message-input:focus {
        scroll-margin-bottom: 100px;
    }
}

@media (min-width: 640px) {
    .chat-input-container {
        padding: 8px 14px 10px;
    }
}

.menu-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
    padding: 0 2px;
}

.menu-button {
    flex: 1 1 calc(50% - 8px);
    padding: 6px 9px;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s;
    touch-action: manipulation;
}

.menu-button:active {
    background: rgba(102, 126, 234, 0.15);
    transform: scale(0.98);
}

@media (min-width: 640px) {
    .menu-buttons-row {
        gap: 8px;
        margin-bottom: 8px;
    }
    .menu-button {
        padding: 7px 12px;
        font-size: 12px;
        font-weight: 600;
    }
}

.menu-button:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

[data-theme="dark"] .menu-button {
    background: rgba(102, 126, 234, 0.2);
    border-color: #4a5568;
}

.orders-modal[hidden] {
    display: none;
}

.orders-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
}

.orders-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(4px);
}

.orders-modal-sheet {
    position: absolute;
    inset: 16px;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.orders-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12), rgba(118, 75, 162, 0.08));
}

.orders-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.orders-modal-subtitle {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-secondary);
}

.orders-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.orders-refresh-button {
    color: var(--text-primary);
    background: rgba(102, 126, 234, 0.12);
    border-color: rgba(102, 126, 234, 0.2);
}

.orders-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: var(--bg-messages);
}

.orders-modal-footer {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.orders-exit-button {
    width: 100%;
    justify-content: center;
}

.orders-empty-state {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    padding: 16px;
    border: 1px dashed var(--border-color);
    border-radius: 14px;
    color: var(--text-secondary);
    text-align: center;
    background: var(--bg-secondary);
}

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

.order-summary-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.order-summary-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.order-summary-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.order-summary-meta {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.order-status-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(102, 126, 234, 0.12);
    color: #5b66d6;
    white-space: nowrap;
}

.order-items-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.order-item-row {
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
}

.order-item-row:first-child {
    padding-top: 0;
    border-top: none;
}

.order-item-main {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-size: 12px;
    color: var(--text-primary);
}

.order-item-qty {
    font-weight: 700;
    flex-shrink: 0;
}

.order-item-modifiers {
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.3;
    color: var(--text-secondary);
}

@media (max-width: 640px) {
    .orders-modal-sheet {
        inset: 0;
        border-radius: 0;
    }

    .orders-modal-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .orders-modal-body {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .orders-modal-footer {
        padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    }
}

.buttons-row {
    display: none; /* Скрываем старую панель кнопок - теперь они inline */
}

.action-button {
    display: none; /* Старые кнопки больше не используются */
}

.input-row {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    background: var(--bg-secondary);
    border-radius: 24px;
    padding: 4px;
    border: 1px solid var(--border-color);
}

.attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(102, 126, 234, 0.06);
}

.attachment-preview-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.attachment-preview-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.attachment-preview-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.attachment-preview-remove {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .input-row {
        gap: 6px;
        padding: 4px;
    }
}

.attach-button,
.voice-button,
.send-button {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    touch-action: manipulation;
    flex-shrink: 0;
    background: transparent;
    color: var(--text-secondary);
}

.attach-button:active,
.voice-button:active,
.send-button:active {
    transform: scale(0.95);
    background: rgba(102, 126, 234, 0.1);
}

.voice-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.voice-button:hover {
    opacity: 0.9;
}

.send-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.send-button:hover:not(:disabled) {
    opacity: 0.9;
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (min-width: 640px) {
    .attach-button,
    .voice-button,
    .send-button {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
}

.icon-button:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

#message-input {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 18px;
    font-size: 14px;
    outline: none;
    transition: background 0.2s;
    background: transparent;
    color: var(--text-primary);
    min-width: 0;
    line-height: 1.3;
    max-height: 96px;
    resize: none;
    overflow-y: auto;
}

#message-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

#message-input:focus {
    background: rgba(102, 126, 234, 0.05);
}

@media (min-width: 640px) {
    #message-input {
        padding: 8px 12px;
        font-size: 14px;
    }
}

#message-input:focus {
    border-color: #667eea;
}

/* Стили для send-button теперь в .send-button выше */

#send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Скроллбар */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}
