/* Wyceny module */

/* Textarea uwagi do wyceny pod towar/ilość */
.uwagi-wyceny-textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.4;
    color: #334155;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 44px;
}

.uwagi-wyceny-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.uwagi-wyceny-textarea.readonly,
.uwagi-wyceny-textarea[readonly] {
    background: #f8fafc;
    color: #64748b;
    cursor: default;
}

/* Tabela wycen — responsywne kolumny */
.data-table {
    table-layout: auto;
}

.data-table th,
.data-table td {
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
}

/* Stackowane wiersze cenowe w osobnych td */
.ip-row {
    padding: 4px 8px;
}

.ip-row:not(:last-child) {
    border-bottom: 1px dashed #e2e8f0;
}

/* Mini-tabelka cenowa wewnątrz komórki */
.inner-pricing {
    width: 100%;
    border-collapse: collapse;
}

.inner-pricing thead th {
    padding: 4px 10px;
    font-weight: 600;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
    background: #f8fafc;
}

.inner-pricing tr:not(:last-child) td {
    border-bottom: 1px dashed #e2e8f0;
}

.inner-pricing td {
    padding: 6px 10px;
    font-size: 13px;
    color: #5a6c7d;
    vertical-align: middle;
    text-align: center;
    white-space: nowrap;
}

.inner-pricing td.ip-stawka {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.inner-pricing td.ip-rodzaj {
}

.inner-pricing td.ip-uwagi {
}

.ip-uwagi-icon {
    color: #f59e0b;
    font-size: 15px;
    cursor: help;
}

.ip-uwagi-icon:hover {
    color: #d97706;
}

.ip-uwagi-empty {
    color: #cbd5e1;
}

.inner-pricing td.ip-logistyk {
    font-size: 12px;
    color: #1a4a7a;
}

.handlowiec-cell {
    white-space: nowrap !important;
    font-size: 12px;
}

/* Kolumna uwagi do wyceny w tabeli */
.uwagi-cell {
    max-width: 200px;
    padding: 4px 8px !important;
    vertical-align: middle;
    white-space: normal !important;
}

.uwagi-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    font-size: 12px;
    color: #475569;
    word-break: break-word;
}

/* Przycisk toggle uwag w wierszu cenowym */
.uwagi-toggle-group {
    display: flex;
    align-items: flex-end;
    min-width: 36px;
    max-width: 36px;
}

.btn-uwagi-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    padding: 0;
}

.btn-uwagi-toggle:hover {
    background: #e2e8f0;
    color: #3b82f6;
    border-color: #93c5fd;
}

.btn-uwagi-toggle.active {
    background: #dbeafe;
    color: #2563eb;
    border-color: #93c5fd;
}

.btn-uwagi-toggle.has-content {
    background: #dcfce7;
    color: #16a34a;
    border-color: #86efac;
}

.btn-uwagi-toggle.has-content:hover {
    background: #bbf7d0;
    color: #15803d;
    border-color: #4ade80;
}

/* Pole uwagi rozwijane pod wierszem cenowym */
.price-row-uwagi {
    padding: 4px 0 8px 0;
}

.price-row-uwagi textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.4;
    color: #334155;
    background: #f8fafc;
    transition: border-color 0.2s;
}

.price-row-uwagi textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
}

.price-row-uwagi textarea[readonly] {
    background: #f1f5f9;
    cursor: default;
}

.cell-main {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.cell-sub {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.3;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.autocomplete-sub {
    color: #6c7a89;
    font-size: 12px;
}

/* Sekcje w dropdown adresowym */
.address-dropdown {
    max-height: 350px;
}

.address-section-label {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 1;
}

.address-section-label i {
    margin-right: 6px;
    font-size: 11px;
}

.autocomplete-item.warehouse-item {
    border-left: 3px solid #2d5a27;
}

.autocomplete-item.nominatim-item {
    border-left: 3px solid #3b82f6;
}

.autocomplete-item.warehouse-item:hover {
    background: #f0fdf4;
}

.autocomplete-item.nominatim-item:hover {
    background: #eff6ff;
}

/* Animacja modala wycen — spadanie z góry */
#wycenaModal .modal-content,
#deleteModal .modal-content {
    transform: translateY(-100vh);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

#wycenaModal.active .modal-content,
#deleteModal.active .modal-content {
    transform: translateY(0);
    opacity: 1;
}

/* Zamykanie — spadanie w dół */
#wycenaModal.closing .modal-content,
#deleteModal.closing .modal-content {
    transform: translateY(100vh) !important;
    opacity: 0 !important;
    transition: transform 0.45s cubic-bezier(0.55, 0.055, 0.675, 0.19), opacity 0.3s ease !important;
}

/* Pasek odległości */
.distance-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    border: 1px solid #7dd3fc;
    border-radius: 10px;
    color: #0369a1;
    font-size: 14px;
    font-weight: 600;
    animation: fadeInDistance 0.4s ease-out;
}

.distance-bar i {
    font-size: 16px;
    color: #0284c7;
}

.distance-bar .distance-loading {
    color: #64748b;
    font-weight: 400;
    font-style: italic;
}

@keyframes fadeInDistance {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-group select {
    padding: 10px 14px;
    border: 1px solid #e8ecef;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #2c3e50;
    transition: all 0.2s ease;
    background: #fff;
}

.form-group select:focus {
    outline: none;
    border-color: #2d5a27;
    box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.1);
}

.form-group select.readonly,
.form-group select:disabled {
    background: #f7fafc;
    color: #5a6c7d;
}

/* Badge czasu - kolumna "Ile czasu" */
.time-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}

.time-badge.time-done {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.time-badge.time-fast {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.time-badge.time-pending {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.time-badge.time-pending i {
    font-size: 10px;
    animation: pulse-clock 1.5s ease-in-out infinite;
}

@keyframes pulse-clock {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Nagłówek modala - prawy blok z badge czasu i przyciskiem zamknięcia */
.modal-header .modal-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.header-time-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0369a1;
    border: 1px solid #7dd3fc;
    white-space: nowrap;
}

.header-time-badge i {
    font-size: 13px;
}

.header-time-badge .time-badge {
    padding: 0;
    border: none;
    background: transparent;
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
}

.header-time-badge .time-badge.time-pending {
    color: #92400e;
    background: transparent;
    border: none;
}

.header-time-badge .time-badge.time-done {
    color: #166534;
    background: transparent;
    border: none;
}

.header-time-badge .time-badge.time-fast {
    color: #065f46;
    background: transparent;
    border: none;
}

/* Badge ceny orientacyjnej */
.header-price-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #fcd34d;
    white-space: nowrap;
}

.header-price-badge i {
    font-size: 13px;
}

.header-price-badge strong {
    font-weight: 800;
}

.header-price-badge .price-soon {
    font-style: italic;
    font-weight: 400;
}

/* Sekcja cenowa wyceny */
.wycena-price-section {
    position: relative;
    margin-bottom: 8px;
}

.wycena-price-row {
    position: relative;
}

.wycena-extra-row {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #e2e8f0;
    animation: fadeInRow 0.3s ease-out;
}

@keyframes fadeInRow {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.btn-add-price-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.btn-add-price-row:hover {
    border-color: #2d5a27;
    color: #2d5a27;
    background: #f0fdf4;
}

.btn-remove-price-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    border-radius: 6px;
    background: #fef2f2;
    color: #ef4444;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    margin-top: 4px;
    align-self: flex-start;
}

.btn-remove-price-row:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Waluta select - zw\u0119\u017cona */
#wycenaModal .form-group select#wycenaWaluta,
#wycenaModal .form-group .extra-waluta {
    padding: 10px 6px;
    text-align: center;
    min-width: 60px;
}

/* Extra row inputs */
.wycena-extra-row .form-group {
    margin-bottom: 0;
}

.wycena-extra-row .form-group label {
    visibility: hidden;
    height: 0;
    margin: 0;
    padding: 0;
    line-height: 0;
    font-size: 0;
}

.wycena-extra-row .form-row {
    align-items: end;
}

/* Firma + przycisk usuwania w jednym wierszu */
.extra-firma-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.extra-firma-wrapper .autocomplete-wrapper {
    flex: 1;
    min-width: 0;
}

.extra-firma-wrapper input {
    flex: 1;
    min-width: 0;
}

.extra-firma-wrapper .btn-remove-price-row {
    margin-top: 0;
    flex-shrink: 0;
}

/* Autocomplete-wrapper — input pełna szerokość */
#wycenaModal .autocomplete-wrapper input {
    width: 100%;
    padding-right: 32px;
    cursor: pointer;
}

/* Firma transportowa dropdown */
.firma-dropdown {
    max-height: 280px;
}

.firma-dropdown .autocomplete-no-results {
    padding: 10px 14px;
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
}

.firma-dropdown .firma-item {
    border-left: 3px solid #f59e0b;
}

.firma-dropdown .firma-item:hover {
    background: #fffbeb;
}

.firma-dropdown .firma-add-item {
    border-left: 3px solid #2d5a27;
    color: #2d5a27;
    font-size: 13px;
    cursor: pointer;
    padding: 10px 14px;
    transition: background 0.15s;
}

.firma-dropdown .firma-add-item:hover {
    background: #f0fdf4;
}

.firma-dropdown .firma-add-item i {
    margin-right: 6px;
}

/* Extra firma dropdown pozycjonowanie */
.extra-firma-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 40px;
    z-index: 1000;
}
