/* MOV-6: Форма комиссий с состояниями */

/* Кнопка "Сделка успешна" всегда видна */
.btn-deal-success { display: inline-block; }

/* Смена лейбла Доступно/Сумма сделки (при активном таймере, вводе суммы или завершённой сделке) */
.label-deal-amount { display: none; }
.currency-block[data-form-state="dealing"] .label-available,
.currency-block[data-form-state="deal_done"] .label-available { display: none; }
.currency-block[data-form-state="dealing"] .label-deal-amount,
.currency-block[data-form-state="deal_done"] .label-deal-amount { display: inline; }

/* Секция вопросов кассиру — только после успешной сделки */
.cashier-section { display: none !important; }
.currency-block[data-form-state="deal_done"] .cashier-section { display: block !important; }

/* Кнопка Сохранить: верхняя видна по умолчанию, нижняя скрыта */
.btn-save-bottom-row { display: none !important; }
/* В deal_done: верхняя скрыта, нижняя видна */
.currency-block[data-form-state="deal_done"] .btn-save-top { display: none !important; }
.currency-block[data-form-state="deal_done"] .btn-save-bottom-row { display: block !important; }

/* Кнопки */
.btn-deal-success {
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}

.btn-deal-success:disabled {
    background: #28a745;
    opacity: 1;
    cursor: default;
}

/* Строка с кнопками Сохранить и Сделка успешна */
.buttons-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-save {
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}

/* Кнопка Сохранить */
button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #ccc;
}

/* Кнопки автозаполнения */
.btn-fill-x1, .btn-fill-x2 {
    padding: 2px 6px;
    font-size: 10px;
    margin-left: 4px;
    cursor: pointer;
}

/* Инлайн-поля для вопроса кассиру */
.cashier-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
    max-width: 246px;
}

.cashier-question {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
    max-width: 100%;
}

.cashier-text {
    font-size: 11px;
    margin-right: 4px;
    flex-shrink: 1;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
}

.inline-input {
    width: 80px;
    font-size: 11px;
}

/* Обычные поля формы */
.input-amount-available,
.input-commission,
.input-rate-diff {
    width: 120px;
    max-width: 120px;
}

/* Таймер */
.timer-display {
    font-family: monospace;
    font-size: 12px;
    color: #666;
    margin-right: 8px;
    min-height: 22px;
    display: flex;
    align-items: center;
}

/* Размеры полей для инлайн-секции */
.input-recovery-hours {
    width: 40px;
}

.commission-form-element {
    display: flex;
    flex-direction: column;
}

.currency-block {
    display: flex;
    flex-direction: column;
}

.commission-form .form-group {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 3px;
    margin: 3px 0;
}

.commission-form .form-group label:first-child,
.commission-form .form-group label:nth-child(2) {
    min-width: 110px;
    max-width: 110px;
}

.commission-form .currency-block + .currency-block {
    padding-left: 8px;
    border-left: 1px solid #f3f0f0;
}

/* Кнопки таймеров */
.btn-timer-start, .btn-timer-stop {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    padding-left: 0;
    margin-left: 0;
}

.btn-timer-start:hover, .btn-timer-stop:hover {
    background: none;
}

/* Обёртка для кнопки и лейбла таймера - фиксированная ширина как у других лейблов */
.timer-label-wrapper {
    display: inline-flex;
    align-items: center;
    min-width: 110px;
    max-width: 110px;
}

/* Компактные строки таймеров */
.timer-row { display: flex; align-items: center; gap: 4px; position: relative; }
.timer-row .timer-label-idle { font-size: 11px; }
.timer-row .timer-label-active { font-size: 11px; display: none; }
.timer-row .timer-display { display: none; }
.timer-row .btn-timer-stop { display: none; }
.timer-row .input-time { width: 70px; }

/* Обёртка для input + overlay таймера */
.timer-row .timer-input-wrapper {
    position: relative;
    display: inline-block;
}

/* Overlay таймера - поверх input с белой подложкой */
.timer-row .timer-display-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    font-family: monospace;
    font-size: 12px;
    color: #2e7d32;
    font-weight: bold;
    text-align: center;
    line-height: 22px;
    border: 1px solid #4CAF50;
    border-radius: 3px;
    box-sizing: border-box;
    pointer-events: none;
}

/* Активный таймер: смена label, показ кнопки стоп и overlay */
.timer-row.active .btn-timer-start { display: none; }
.timer-row.active .timer-label-idle { display: none; }
.timer-row.active .timer-label-active { display: inline; }
.timer-row.active .btn-timer-stop { display: inline-block; }
.timer-row.active .timer-display-overlay { display: block; }

/* Уведомления — вставляются в <html>, не в <body> (body имеет transform: scale) */
.commission-notification {
    position: fixed;
    top: 5vh;
    left: 50%;
    transform: translateX(-50%);
    padding: 16px 28px;
    border-radius: 6px;
    z-index: 10000;
    font-size: 22px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    max-width: 90vw;
    text-align: center;
    animation: notification-slide-in 0.3s ease-out;
}
@keyframes notification-slide-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.commission-notification.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.commission-notification.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.commission-notification.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* === Confirm Popover === */
.confirm-popover-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9998;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: popoverFadeIn 0.2s ease-out;
}

.confirm-popover {
    background: white;
    border: 1px solid #ccc;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
    padding: 18px 24px;
    width: max-content;
    max-width: calc(100vw - 48px);
    animation: popoverFadeIn 0.15s ease-out;
}

.confirm-popover-title {
    margin-bottom: 12px;
    font-size: 20px;
    font-weight: bold;
    line-height: 1.3;
}

.confirm-popover-message {
    margin-bottom: 18px;
    font-size: 21px;
    line-height: 1.4;
}

.confirm-popover-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-popover-btn {
    padding: 9px 24px;
    border-radius: 6px;
    border: 1px solid #ccc;
    cursor: pointer;
    font-size: 21px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
}

.confirm-popover-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.confirm-popover-btn:active {
    transform: translateY(0);
}

.confirm-popover-btn:focus-visible {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

.confirm-popover-btn-yes {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.confirm-popover-btn-yes:hover {
    background: #45a049;
}

.confirm-popover-btn-no {
    background: #f5f5f5;
    color: #333;
}

.confirm-popover-btn-no:hover {
    background: #e0e0e0;
}

/* Loading state: disabled кнопки */
.confirm-popover-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Анимация появления (только opacity, без transform - он используется для центрирования) */
@keyframes popoverFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Accessibility: уменьшенная анимация */
@media (prefers-reduced-motion: reduce) {
    .confirm-popover,
    .confirm-popover-backdrop {
        animation: none;
    }
    .confirm-popover-btn {
        transition: none;
    }
}

/* Mobile: увеличенные touch-targets */
@media (max-width: 480px) {
    .confirm-popover {
        min-width: 180px;
    }
    .confirm-popover-btn {
        min-height: 44px;
        padding: 10px 20px;
    }
}
