/* Packages Module - Style dla modułu paczek */

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: background 0.4s ease, opacity 0.4s ease, visibility 0.4s ease;
    pointer-events: none;
    perspective: 1200px;
}

.modal.show,
.modal.active {
    visibility: visible;
    opacity: 1;
    background: rgba(0,0,0,0.6);
    pointer-events: auto;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 98%;
    max-width: 1500px;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(0,0,0,0.4);
    transform: rotateX(-90deg);
    transform-origin: top center;
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.3s ease;
}

.modal-content.modal-large {
    max-width: 1600px;
}

/* Style dla form-row z 3 elementami */
.form-row-three {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    align-items: start;
}



@media (max-width: 1200px) {
    .form-row-three {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .form-row-three {
        grid-template-columns: 1fr;
    }
}

.modal.show .modal-content,
.modal.active .modal-content {
    transform: rotateX(0deg);
    opacity: 1;
}

/* Animacja zamykania - flip w dół */
.modal.closing .modal-content {
    transform: rotateX(90deg);
    transform-origin: bottom center;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.55, 0.055, 0.675, 0.19), opacity 0.3s ease;
}

.modal-small {
    max-width: 450px;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.close-btn {
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.modal-confirm {
    z-index: 10001;
}

.warning-text {
    color: #ef4444;
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Klikalny wiersz tabeli */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.clickable-row:hover {
    background-color: #f3f4f6 !important;
}

.clickable-row td {
    color: #374151;
}

/* Stage bar w tabeli */
.stage-bar {
    display: flex;
    width: 180px;
    height: 26px;
    border-radius: 6px;
    overflow: hidden;
    background: #e5e7eb;
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.stage-segment {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    border-right: 1px solid #d1d5db;
    transition: all 0.2s ease;
    position: relative;
}

.stage-segment:last-child {
    border-right: none;
}

.stage-segment:hover {
    background: #d1d5db;
    color: #6b7280;
}

.stage-segment.active {
    background: linear-gradient(135deg, #16a34a 0%, #0f8a3a 100%);
    color: #fff;
    border-right-color: #0f8a3a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 0 0 2px rgba(22, 163, 74, 0.25);
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.stage-segment.completed {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.stage-segment.active:hover,
.stage-segment.completed:hover {
    filter: brightness(1.1);
}

/* Tooltip dla etapu */
.stage-segment::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.stage-segment::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.stage-segment:hover::after,
.stage-segment:hover::before {
    opacity: 1;
}

/* Stage bar w modalu (karta paczki) */
.package-stage-bar {
    display: flex;
    gap: 12px;
    margin: 20px 0;
}

.package-stage-item {
    flex: 1;
    padding: 16px 12px;
    text-align: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.package-stage-item:hover {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.package-stage-item.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-color: #047857;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.package-stage-item.completed {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.package-stage-item .stage-number {
    font-size: 22px;
    font-weight: 800;
    display: block;
    line-height: 1;
}

.package-stage-item .stage-label {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.9;
    margin-top: 6px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Siatka informacji o paczce */
.package-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1200px) {
    .package-info-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .package-info-grid {
        grid-template-columns: 1fr;
    }
    
    .package-stage-bar {
        flex-wrap: wrap;
    }
    
    .package-stage-item {
        flex: 1 1 calc(50% - 6px);
        min-width: 80px;
    }
}

/* Karty umów */
.package-agreement-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.package-agreement-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #cbd5e1;
}

.package-agreement-card h4 {
    margin: 0 0 16px 0;
    color: #374151;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.package-agreement-card h4 i {
    font-size: 18px;
}

.package-agreement-card.purchase {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #3b82f6;
}

.package-agreement-card.purchase h4 {
    border-bottom-color: #3b82f6;
}

.package-agreement-card.purchase h4 i {
    color: #3b82f6;
}

.package-agreement-card.sales {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #10b981;
}

.package-agreement-card.sales h4 {
    border-bottom-color: #10b981;
}

.package-agreement-card.sales h4 i {
    color: #10b981;
}

/* Znacznik statusu podpisania umowy */
.podpisana-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.podpisana-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.podpisana-badge.not-signed {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
    border: 1px solid #ef4444;
}

.podpisana-badge.not-signed:hover {
    background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.podpisana-badge.signed {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #059669;
    border: 1px solid #10b981;
}

.podpisana-badge.signed:hover {
    background: linear-gradient(135deg, #a7f3d0 0%, #6ee7b7 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.podpisana-badge i {
    font-size: 10px;
}

.package-agreement-card.transport {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fbbf24;
}

.package-agreement-card.transport h4 {
    border-bottom-color: #f59e0b;
}

.package-agreement-card.transport h4 i {
    color: #f59e0b;
}

.agreement-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
}

.agreement-detail:last-child {
    border-bottom: none;
}

.agreement-detail-label {
    color: #6b7280;
    font-weight: 500;
}

.agreement-detail-value {
    color: #1f2937;
    font-weight: 600;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

/* Link do numeru umowy */
.agreement-number-link {
    color: #3b82f6;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.agreement-number-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

/* Status etapu w tabeli */
.stage-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stage-badge.stage-1 {
    background: #fef3c7;
    color: #92400e;
}

.stage-badge.stage-2 {
    background: #dbeafe;
    color: #1e40af;
}

.stage-badge.stage-3 {
    background: #e0e7ff;
    color: #3730a3;
}

.stage-badge.stage-4 {
    background: #d1fae5;
    color: #065f46;
}

.stage-badge.stage-5 {
    background: #dcfce7;
    color: #166534;
}

/* Wiersz tabeli z paczką */
.data-table tbody tr.package-row {
    transition: background 0.2s ease;
}

.data-table tbody tr.package-row:hover {
    background: #f0f9ff !important;
}

/* Przycisk akcji w tabeli */
.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 4px;
}

.btn-icon:hover {
    background: #e5e7eb;
    color: #374151;
}

.btn-icon.btn-icon-danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

.btn-icon.btn-icon-primary:hover {
    background: #dbeafe;
    color: #2563eb;
}

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

.package-agreement-card {
    animation: fadeIn 0.3s ease;
}

/* Brak danych */
.empty-message {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px !important;
    font-size: 14px;
}

.empty-message i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    color: #d1d5db;
}

/* Loading */
.loading {
    text-align: center;
    color: #6b7280;
    padding: 40px 20px !important;
}

.loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1024px) {
    .stage-bar {
        width: 150px;
    }
}

@media (max-width: 768px) {
    .stage-bar {
        width: 120px;
        height: 24px;
    }
    
    .stage-segment {
        font-size: 10px;
    }
}

/* Autocomplete dropdown */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f0f9ff;
}

.autocomplete-item strong {
    color: #1f2937;
    font-weight: 700;
}

.autocomplete-no-results {
    padding: 14px;
    color: #9ca3af;
    text-align: center;
    font-size: 13px;
}

/* Filter dropdown */
.filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    z-index: 500;
    display: none;
}

.filter-dropdown.show {
    display: block;
}

.filter-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s ease;
}

.filter-dropdown-item:hover {
    background: #f0f9ff;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    border-radius: 10px;
    background: #1f2937;
    color: white;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 10000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.notification-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.notification-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.notification i {
    font-size: 18px;
}

/* ==================== PRZYCISK DODAJ POD POLEM ==================== */

/* Zielony przycisk pod polem autocomplete - styl jak "Dodaj paczkę" */
.btn-add-below {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 8px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #2d5a27 0%, #1e3d1a 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(45, 90, 39, 0.3);
    white-space: nowrap;
    box-sizing: border-box;
}

.btn-add-below:hover {
    background: linear-gradient(135deg, #3a7332 0%, #2d5a27 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(45, 90, 39, 0.4);
}

.btn-add-below:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(45, 90, 39, 0.3);
}

.btn-add-below i {
    font-size: 11px;
}

/* Sekcja powiązań - wyrównanie elementów */
.form-row-three .form-group {
    display: flex;
    flex-direction: column;
}

.form-row-three .form-group > label {
    margin-bottom: 8px;
}

.form-row-three .form-group .autocomplete-wrapper {
    flex-shrink: 0;
}

/* Kontener zleceń transportowych */
#transportOrdersContainer {
    margin-top: 10px;
}

#addTransportOrderSection {
    flex-shrink: 0;
}

/* ==================== PRZYCISK USUWANIA ZLECENIA TRANSPORTOWEGO ==================== */

.btn-remove-transport {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.btn-remove-transport:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.btn-remove-transport i {
    font-size: 12px;
}

/* Kontener na zlecenia transportowe */
#transportOrdersContainer {
    margin-bottom: 15px;
}

.transport-order-item {
    position: relative;
}

.transport-order-item .package-agreement-card {
    padding-right: 50px;
}

/* ==================== ZWIJANE KARTY ZLECEŃ TRANSPORTOWYCH ==================== */

.package-agreement-card.collapsible {
    position: relative;
}

.package-agreement-card.collapsible.collapsed .transport-details {
    display: none;
}

.btn-expand-transport {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f59e0b;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.btn-expand-transport:hover {
    background: #d97706;
    transform: scale(1.1);
}

/* Przycisk usuwania przesuń w lewo gdy jest strzałka */
.package-agreement-card.collapsible .btn-remove-transport {
    right: 45px;
}

.btn-expand-transport i {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.package-agreement-card.collapsible:not(.collapsed) .btn-expand-transport i {
    transform: rotate(180deg);
}

/* ==================== MODAL Z IFRAME ==================== */

/* Modal iframe - pełnoekranowy */
.modal-content.modal-iframe {
    max-width: 95vw;
    width: 95vw;
    height: 90vh;
    max-height: 90vh;
}

.modal-body-iframe {
    padding: 0 !important;
    flex: 1;
    overflow: hidden;
    display: flex;
}

.modal-body-iframe iframe {
    width: 100%;
    height: 100%;
    border: none;
    flex: 1;
}

/* Wymagane pole */
.required {
    color: #ef4444;
    font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content.modal-iframe {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* ==================== TABELA TRANSPORTÓW W PACZCE ==================== */

.btn-add-transport {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #2d5a27 0%, #1e3d1a 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(45, 90, 39, 0.3);
    white-space: nowrap;
    margin-left: auto;
}

.btn-add-transport:hover {
    background: linear-gradient(135deg, #3a7332 0%, #2d5a27 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(45, 90, 39, 0.4);
}

.btn-add-transport:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(45, 90, 39, 0.3);
}

.btn-add-transport i {
    font-size: 11px;
}

.transports-mini-table {
    font-size: 12px;
}

.transports-mini-table th {
    background: #f8fafc;
    padding: 8px 10px;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    text-align: left;
}

.transports-mini-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.transports-mini-table tbody tr:hover {
    background: #f0f9ff;
}

.transports-mini-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.transports-mini-table tbody tr:active {
    background: #dbeafe;
}

.transports-mini-table .btn-icon-mini {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 11px;
    margin-right: 4px;
}

.transports-mini-table .btn-icon-mini:hover {
    background: #e5e7eb;
    color: #374151;
}

.transports-mini-table .btn-icon-mini.btn-danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

#transportsSection h3 {
    display: flex;
    align-items: center;
}

/* ============== PRZYCISKI AWIZACJI ============== */
.awizacja-row {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #d1d5db;
}

.awizacja-buttons {
    display: flex;
    gap: 8px;
}

.awizacja-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.awizacja-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

/* Przycisk Awizuj - zielony */
.awizacja-btn.awizuj {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #059669;
    border-color: #10b981;
}

.awizacja-btn.awizuj:hover {
    background: linear-gradient(135deg, #a7f3d0 0%, #6ee7b7 100%);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.4);
}

.awizacja-btn.awizuj.active {
    opacity: 1;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.5);
}

/* Przycisk Nie Awizuj - czerwony */
.awizacja-btn.nie-awizuj {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
    border-color: #ef4444;
}

.awizacja-btn.nie-awizuj:hover {
    background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
}

.awizacja-btn.nie-awizuj.active {
    opacity: 1;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    box-shadow: 0 3px 12px rgba(239, 68, 68, 0.5);
}

.awizacja-btn i {
    font-size: 11px;
}

/* ========================================
   Etapy transportu w tabeli (stage badges)
   - okrągłe ikony jak w karcie transportu
   ======================================== */
.transport-stage-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 11px;
    border: 2px solid;
    transition: all 0.3s ease;
}

/* Tabela transportów z auto-dopasowaniem kolumn */
.transports-mini-table {
    width: 100% !important;
    min-width: 100%;
    table-layout: fixed;
}

.transports-mini-table th,
.transports-mini-table td {
    white-space: nowrap;
    padding: 6px 8px !important;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Kolumna 1: Etap - ikona */
.transports-mini-table th:nth-child(1),
.transports-mini-table td:nth-child(1) {
    width: 50px !important;
    text-align: center;
    padding: 6px 4px !important;
}

/* Kolumna 2: Firma Transportowa - szeroka */
.transports-mini-table th:nth-child(2),
.transports-mini-table td:nth-child(2) {
    width: 18% !important;
}

/* Kolumna 3: Data zał. */
.transports-mini-table th:nth-child(3),
.transports-mini-table td:nth-child(3) {
    width: 85px !important;
}

/* Kolumna 4: Data rozł. */
.transports-mini-table th:nth-child(4),
.transports-mini-table td:nth-child(4) {
    width: 85px !important;
}

/* Kolumna 5: Waga zał. - wąska */
.transports-mini-table th:nth-child(5),
.transports-mini-table td:nth-child(5) {
    width: 70px !important;
    text-align: right;
}

/* Kolumna 6: Waga rozł. - wąska */
.transports-mini-table th:nth-child(6),
.transports-mini-table td:nth-child(6) {
    width: 70px !important;
    text-align: right;
}

/* Kolumna 7: Kierowca */
.transports-mini-table th:nth-child(7),
.transports-mini-table td:nth-child(7) {
    width: 14% !important;
}

/* Kolumna 8: Nr rej. ciągnika */
.transports-mini-table th:nth-child(8),
.transports-mini-table td:nth-child(8) {
    width: 110px !important;
}

/* Kolumna 9: Awizo - przycisk */
.transports-mini-table th:nth-child(9),
.transports-mini-table td:nth-child(9) {
    width: 90px !important;
    text-align: right;
    padding-right: 12px !important;
}

.transports-mini-table td:nth-child(9) {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

/* Etap 1 - Wyślij Awizo (szary - nieaktywny) */
.transport-stage-badge.stage-1 {
    background: #e2e8f0;
    color: #94a3b8;
    border-color: #e2e8f0;
}

/* Etap 2 - Awizo Wysłane (niebieski) */
.transport-stage-badge.stage-2 {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Etap 3 - Uzupełnij Wagi (pomarańczowy) */
.transport-stage-badge.stage-3 {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    border-color: #f59e0b;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* Etap 4 - Rozlicz (cyjan) */
.transport-stage-badge.stage-4 {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: #fff;
    border-color: #06b6d4;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

/* Etap 5 - Zakończony (zielony) */
.transport-stage-badge.stage-5 {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border-color: #10b981;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* ========================================
   Przyciski Awizo w tabeli (mini, 4 stany)
   ======================================== */
.btn-awizo-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    white-space: nowrap !important;
}

.btn-awizo-mini:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.btn-awizo-mini i {
    font-size: 9px;
}

/* Stan: Awizo ponownie — zielony */
.btn-awizo-mini.awizo-resend {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.btn-awizo-mini.awizo-resend:hover {
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

/* Stan: Zmiana Awizo — pomarańczowy */
.btn-awizo-mini.awizo-change {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.btn-awizo-mini.awizo-change:hover {
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

/* Stan: Zmiana ponownie — fioletowy */
.btn-awizo-mini.awizo-change-resend {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.btn-awizo-mini.awizo-change-resend:hover {
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

/* Brak danych kierowcy */
.btn-awizo-mini.awizo-no-data {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: default;
}

/* ==================== MODAL KRZYŻOWANIA ==================== */

#crossModal .modal-content {
    max-width: 1100px;
}

#crossModal .form-section h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Przycisk Krzyżuj */
.btn-cross {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border: 2px solid #3b82f6;
    color: #2563eb;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cross:hover {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

/* Custom select dropdown dla krzyżowania */
.cross-select {
    position: relative;
    width: 100%;
}

.cross-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    color: #9ca3af;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 42px;
}

.cross-select-trigger.has-value {
    color: #1f2937;
}

.cross-select-trigger:hover {
    border-color: #2d5a27;
}

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

.cross-select-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cross-select-arrow {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-left: 8px;
    transition: transform 0.2s ease;
}

.cross-select-dropdown.open + .cross-select-trigger .cross-select-arrow,
.cross-select-trigger:has(+ .cross-select-dropdown.open) .cross-select-arrow {
    transform: rotate(180deg);
}

.cross-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    display: none;
    max-height: 320px;
    overflow: hidden;
}

.cross-select-dropdown.open {
    display: flex;
    flex-direction: column;
}

.cross-select-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
}

.cross-select-search i {
    color: #9ca3af;
    font-size: 0.85rem;
}

.cross-select-search input {
    flex: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    color: #1f2937;
    background: transparent;
}

.cross-select-search input::placeholder {
    color: #9ca3af;
}

.cross-select-options {
    overflow-y: auto;
    max-height: 260px;
}

.cross-select-option {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s ease;
}

.cross-select-option:last-child {
    border-bottom: none;
}

.cross-select-option:hover {
    background: #f0f9ff;
}

.cross-select-option.selected {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
}

.cross-select-option-main {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #1f2937;
}

.cross-select-option-main strong {
    color: #1f2937;
    font-weight: 700;
}

.cross-select-option-main span {
    color: #4b5563;
}

.cross-select-option-details {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-top: 2px;
    padding-left: 2px;
}

.cross-select-empty {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
}

/* Wiersz paczki źródłowej */
.cross-source-row {
    display: grid;
    grid-template-columns: 1fr 140px 36px;
    gap: 12px;
    align-items: end;
    padding: 14px 16px;
    background: #f7fafc;
    border: 1px solid #e8ecef;
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.cross-source-row:hover {
    border-color: #cbd5e0;
}

.cross-source-row .form-group {
    margin-bottom: 0;
}

/* Wiersz nowej paczki */
.cross-new-row {
    display: grid;
    grid-template-columns: 1fr 1fr 110px 36px;
    gap: 12px;
    align-items: end;
    padding: 14px 16px;
    background: #f7fafc;
    border: 1px solid #e8ecef;
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.cross-new-row:hover {
    border-color: #cbd5e0;
}

.cross-new-row.cross-invalid {
    background: #fef2f2;
    border-color: #fca5a5;
}

.cross-new-row .form-group {
    margin-bottom: 0;
}

/* Przycisk usuwania wiersza */
.cross-remove-btn {
    background: none;
    border: none;
    color: #cbd5e0;
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cross-remove-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

/* Podsumowanie */
#crossSummary {
    background: #f7fafc;
    border: 1px solid #e8ecef;
    border-radius: 8px;
    padding: 16px;
}

.cross-summary-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cross-summary-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.cross-summary-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cross-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid #e8ecef;
    color: #2c3e50;
}

.cross-summary-item.over-budget {
    background: #fef2f2;
    border-color: #fca5a5;
}

.cross-summary-tonnage {
    font-weight: 600;
    color: #2d5a27;
}

.cross-summary-tonnage.over {
    color: #dc2626;
}

/* Pusty stan */
.cross-empty {
    padding: 24px;
    text-align: center;
    color: #718096;
    font-size: 0.85rem;
}

.cross-empty i {
    margin-right: 6px;
}