/* ===== TRIP ALLOCATION PAGE STYLES ===== */

/* --- Override panel overflow so STO dropdown is not clipped --- */
.alloc-sto-panel {
    overflow: visible !important;
    position: relative;
    z-index: 50;
}

.alloc-sto-select-wrapper {
    position: relative;
    z-index: 300;
}

/* --- Alert --- */
.alloc-alert {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--dash-radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.838rem;
    font-weight: 500;
    animation: dash-fadeUp 0.3s ease-out;
    position: relative;
}

.alloc-alert.show {
    display: flex;
}

.alloc-alert-icon svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.alloc-alert-text {
    flex: 1;
}

.alloc-alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
}

.alloc-alert-close:hover {
    opacity: 1;
}

.alloc-alert-success {
    background: var(--dash-success-light);
    color: var(--dash-success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.alloc-alert-error {
    background: var(--dash-danger-light);
    color: var(--dash-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alloc-alert-warning {
    background: var(--dash-warning-light);
    color: var(--dash-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alloc-alert-info {
    background: var(--dash-info-light);
    color: var(--dash-info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* --- Form Grid --- */
.alloc-form-section {
    margin-bottom: 2rem;
}

.alloc-section-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--dash-border);
}

.alloc-section-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.alloc-section-icon svg {
    width: 18px;
    height: 18px;
}

.alloc-section-icon.primary {
    background: var(--dash-primary-light);
    color: var(--dash-primary);
}

.alloc-section-icon.success {
    background: var(--dash-success-light);
    color: var(--dash-success);
}

.alloc-section-icon.info {
    background: var(--dash-info-light);
    color: var(--dash-info);
}

.alloc-section-icon.warning {
    background: var(--dash-warning-light);
    color: var(--dash-warning);
}

.alloc-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dash-text);
}

.alloc-section-subtitle {
    font-size: 0.75rem;
    color: var(--dash-text-muted);
    font-weight: 500;
}

.alloc-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
}

/* --- Field --- */
.alloc-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
    min-width: 0;
}

.alloc-field-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dash-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.alloc-field-label svg {
    width: 14px;
    height: 14px;
    color: var(--dash-primary);
    opacity: 0.7;
}

.alloc-input {
    background: var(--dash-surface-2);
    border: 1.5px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    color: var(--dash-text);
    font-size: 0.838rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    padding: 0.625rem 0.875rem;
    outline: none;
    transition: var(--dash-transition);
    width: 100%;
}

.alloc-input:focus {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
}

.alloc-input:read-only {
    background: var(--dash-surface-3);
    color: var(--dash-text-secondary);
    cursor: default;
}

.alloc-input::placeholder {
    color: var(--dash-text-muted);
}

.alloc-input-group {
    display: flex;
    align-items: stretch;
}

.alloc-input-group .alloc-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.alloc-input-suffix {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    background: var(--dash-surface-3);
    border: 1.5px solid var(--dash-border);
    border-left: none;
    border-radius: 0 var(--dash-radius-sm) var(--dash-radius-sm) 0;
    font-size: 0.688rem;
    font-weight: 700;
    color: var(--dash-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* --- Select --- */
.alloc-select {
    background: var(--dash-surface-2);
    border: 1.5px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    color: var(--dash-text);
    font-size: 0.838rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    padding: 0.625rem 2.25rem 0.625rem 0.875rem;
    outline: none;
    transition: var(--dash-transition);
    cursor: pointer;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.alloc-select:focus {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
}

.alloc-select option {
    background: var(--dash-surface);
    color: var(--dash-text);
    padding: 8px;
}

/* --- STO Searchable Dropdown --- */
.alloc-sto-select-wrapper {
    position: relative;
}

.alloc-sto-search {
    background: var(--dash-surface-2);
    border: 1.5px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    color: var(--dash-text);
    font-size: 0.838rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
    outline: none;
    transition: var(--dash-transition);
    width: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem center;
}

.alloc-sto-search:focus {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
}

.alloc-sto-search::placeholder {
    color: var(--dash-text-muted);
    font-weight: 400;
}

.alloc-sto-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    max-height: 260px;
    overflow-y: auto;
    z-index: 500;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.alloc-sto-dropdown.open {
    display: block;
    animation: dash-fadeUp 0.2s ease-out;
}

.alloc-dropdown-item {
    padding: 0.625rem 1rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--dash-border);
}

.alloc-dropdown-item:last-child {
    border-bottom: none;
}

.alloc-dropdown-item:hover {
    background: var(--dash-primary-light);
}

.alloc-dropdown-item-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 2px;
}

.alloc-dropdown-sto-no {
    font-size: 0.838rem;
    font-weight: 700;
    color: var(--dash-text);
}

.alloc-dropdown-transporter {
    font-size: 0.688rem;
    font-weight: 600;
    color: var(--dash-cyan);
    background: var(--dash-cyan-light);
    padding: 2px 6px;
    border-radius: 4px;
}

.alloc-dropdown-item-sub {
    font-size: 0.75rem;
    color: var(--dash-text-muted);
}

.alloc-dropdown-empty {
    padding: 1.25rem;
    text-align: center;
    color: var(--dash-text-muted);
    font-size: 0.813rem;
}

/* --- Loading inline --- */
.alloc-loader {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
}

.alloc-loader-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--dash-primary);
    border-radius: 50%;
    animation: sto-spin 0.8s linear infinite;
}

.alloc-loader-text {
    font-size: 0.813rem;
    color: var(--dash-text-muted);
    font-weight: 500;
}

@keyframes sto-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes alloc-fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-8px);
        height: 0;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
}

/* =============================================
   TRIP ROW CARDS (Dynamic add/remove)
   ============================================= */
.alloc-trip-rows-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alloc-trip-row-count {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--dash-primary-light);
    color: var(--dash-primary);
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.alloc-trip-row-count svg {
    width: 12px;
    height: 12px;
}

.alloc-trip-row {
    background: var(--dash-surface-2);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
    overflow: visible;
    /* Changed to visible to let dropdown menus escape the row box */
    margin-bottom: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.alloc-trip-row:hover {
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.08);
}

.alloc-trip-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--dash-surface-3);
    border-bottom: 1px solid var(--dash-border);
    border-radius: calc(var(--dash-radius) - 1px) calc(var(--dash-radius) - 1px) 0 0;
}

.alloc-trip-row-badge {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.alloc-trip-row-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    background: linear-gradient(135deg, var(--dash-primary), var(--dash-violet));
    color: white;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    box-shadow: 0 2px 8px var(--dash-primary-glow);
}

.alloc-trip-row-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dash-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.alloc-trip-remove-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: 1px solid transparent;
    color: var(--dash-text-muted);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.688rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--dash-transition);
}

.alloc-trip-remove-btn:hover {
    background: var(--dash-danger-light);
    color: var(--dash-danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.alloc-trip-remove-btn svg {
    width: 13px;
    height: 13px;
}

.alloc-trip-row-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Grid rows inside trip card */
.alloc-line-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* --- Add Trip Buttons --- */
.alloc-add-trip-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.alloc-btn-add {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--dash-radius-sm);
    font-size: 0.813rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--dash-transition);
    border: 1.5px dashed var(--dash-primary);
    background: rgba(99, 102, 241, 0.05);
    color: var(--dash-primary);
}

.alloc-btn-add:hover:not(:disabled) {
    background: var(--dash-primary-light);
    border-style: solid;
    transform: translateY(-1px);
}

.alloc-btn-add:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: var(--dash-border);
    color: var(--dash-text-muted);
    transform: none;
}

.alloc-btn-add svg {
    width: 16px;
    height: 16px;
}

.alloc-btn-duplicate {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--dash-radius-sm);
    font-size: 0.813rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--dash-transition);
    border: 1.5px dashed var(--dash-cyan);
    background: rgba(6, 182, 212, 0.05);
    color: var(--dash-cyan);
}

.alloc-btn-duplicate:hover:not(:disabled) {
    background: var(--dash-cyan-light);
    border-style: solid;
    transform: translateY(-1px);
}

.alloc-btn-duplicate:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: var(--dash-border);
    color: var(--dash-text-muted);
    transform: none;
}

.alloc-btn-duplicate svg {
    width: 16px;
    height: 16px;
}

/* --- Empty State --- */
.alloc-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
}

.alloc-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--dash-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.alloc-empty-icon svg {
    width: 24px;
    height: 24px;
    color: var(--dash-text-muted);
}

.alloc-empty-title {
    font-size: 0.938rem;
    font-weight: 700;
    color: var(--dash-text);
    margin-bottom: 0.25rem;
}

.alloc-empty-desc {
    font-size: 0.813rem;
    color: var(--dash-text-muted);
    max-width: 340px;
}

/* --- Action Buttons (bottom bar) --- */
.alloc-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--dash-border);
}

.alloc-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--dash-radius-sm);
    font-size: 0.838rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--dash-transition);
    border: 1.5px solid transparent;
}

.alloc-btn svg {
    width: 16px;
    height: 16px;
}

.alloc-btn-primary {
    background: linear-gradient(135deg, var(--dash-primary), var(--dash-violet));
    color: white;
    border-color: var(--dash-primary);
    box-shadow: 0 4px 16px var(--dash-primary-glow);
}

.alloc-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--dash-primary-glow);
}

.alloc-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.alloc-btn-primary.loading {
    pointer-events: none;
}

.alloc-btn-primary.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: sto-spin 0.7s linear infinite;
    margin-left: 0.25rem;
}

.alloc-btn-secondary {
    background: var(--dash-surface-2);
    color: var(--dash-text-secondary);
    border-color: var(--dash-border);
}

.alloc-btn-secondary:hover {
    border-color: var(--dash-border-hover);
    color: var(--dash-text);
}

/* --- Steps Indicator --- */
.alloc-steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 2rem;
}

.alloc-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--dash-text-muted);
    position: relative;
}

.alloc-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.688rem;
    font-weight: 800;
    background: var(--dash-surface-2);
    border: 1.5px solid var(--dash-border);
    color: var(--dash-text-muted);
    flex-shrink: 0;
}

.alloc-step.active .alloc-step-num {
    background: var(--dash-primary);
    border-color: var(--dash-primary);
    color: white;
}

.alloc-step.active {
    color: var(--dash-primary);
}

.alloc-step-connector {
    width: 40px;
    height: 1.5px;
    background: var(--dash-border);
    flex-shrink: 0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .alloc-form-grid {
        grid-template-columns: 1fr;
    }

    .alloc-line-row {
        grid-template-columns: 1fr;
    }

    .alloc-trip-row-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .alloc-actions {
        flex-direction: column;
    }

    .alloc-btn {
        width: 100%;
        justify-content: center;
    }

    .alloc-add-trip-bar {
        flex-direction: column;
    }

    .alloc-btn-add,
    .alloc-btn-duplicate {
        width: 100%;
        justify-content: center;
    }

    .alloc-steps {
        flex-wrap: wrap;
    }
}

/* --- Light Mode Overrides --- */
[data-theme="light"] .alloc-sto-dropdown {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .alloc-trip-row:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .alloc-select option {
    background: #ffffff;
    color: #0f172a;
}